@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 testFlattenValue() {
        final Map<String, Object> config = new HashMap<>();

        final GrokExtractor extractor1 = makeExtractor("%{TWOBASENUMS}", config);

        /* Test flatten with a multiple non unique result [ 22, 23 ] */
        Extractor.Result[] result1 = extractor1.run("22 23");
        assertThat(result1)
                .hasSize(2)
                .contains(new Extractor.Result("22 23", "TWOBASENUMS", -1, -1),
                        new Extractor.Result(Arrays.asList("22", "23"), "BASE10NUM", -1, -1));

        /* Test flatten with a multiple but unique result [ 22, 22 ] */
        Extractor.Result[] result2 = extractor1.run("22 22");
        assertThat(result2)
                .hasSize(2)
                .contains(new Extractor.Result("22 22", "TWOBASENUMS", -1, -1),
                        new Extractor.Result("22", "BASE10NUM", -1, -1));
    }