@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 testIssue5563() {
        // See: https://github.com/Graylog2/graylog2-server/issues/5563
        //      https://github.com/Graylog2/graylog2-server/issues/5704
        final Map<String, Object> config = new HashMap<>();

        config.put("named_captures_only", true);

        patternSet.add(GrokPattern.create("YOLO", "(?<test_field>test)"));
        // Make sure that the user can use a capture name with an "_".
        final GrokExtractor extractor = makeExtractor("%{YOLO}", config);

        assertThat(extractor.run("test"))
                .hasSize(1)
                .containsOnly(
                        new Extractor.Result("test", "test_field", -1, -1)
                );
    }