@Override
    protected Result[] run(String value) {
        final Grok grok = grokPatternRegistry.cachedGrokForPattern(this.pattern, this.namedCapturesOnly);

        // the extractor instance is rebuilt every second anyway
        final Match match = grok.match(value);
        final Map<String, Object> matches = match.captureFlattened();
        final List<Result> results = new ArrayList<>(matches.size());

        for (final Map.Entry<String, Object> entry : matches.entrySet()) {
            // never add null values to the results, those don't make sense for us
            if (entry.getValue() != null) {
                results.add(new Result(entry.getValue(), entry.getKey(), -1, -1));
            }
        }

        return results.toArray(new Result[0]);
    }
@Test
    public void testNamedCapturesOnly() {
        final Map<String, Object> config = new HashMap<>();

        final GrokPattern mynumber = GrokPattern.create("MYNUMBER", "(?:%{BASE10NUM})");

        patternSet.add(mynumber);

        config.put("named_captures_only", true);
        final GrokExtractor extractor1 = makeExtractor("%{MYNUMBER:num}", config);

        config.put("named_captures_only", true);
        final GrokExtractor extractor2 = makeExtractor("%{MYNUMBER:num;int}", config);

        config.put("named_captures_only", false);
        final GrokExtractor extractor3 = makeExtractor("%{MYNUMBER:num}", config);

        final GrokExtractor extractor4 = makeExtractor("%{MYNUMBER:num}");

        assertThat(extractor1.run("2015"))
                .hasSize(1)
                .containsOnly(new Extractor.Result("2015", "num", -1, -1));
        assertThat(extractor2.run("2015"))
                .hasSize(1)
                .containsOnly(new Extractor.Result(2015, "num", -1, -1));
        assertThat(extractor3.run("2015"))
                .hasSize(2)
                .containsOnly(
                        new Extractor.Result("2015", "num", -1, -1),
                        new Extractor.Result("2015", "BASE10NUM", -1, -1)
                );
        assertThat(extractor4.run("2015"))
                .hasSize(2)
                .containsOnly(
                        new Extractor.Result("2015", "num", -1, -1),
                        new Extractor.Result("2015", "BASE10NUM", -1, -1)
                );
    }