@VisibleForTesting
    Set<String> extractFields(List<ResultMessage> hits) {
        Set<String> filteredFields = Sets.newHashSet();

        hits.forEach(hit -> {
            final Message message = hit.getMessage();
            for (String field : message.getFieldNames()) {
                if (!Message.FILTERED_FIELDS.contains(field)) {
                    filteredFields.add(field);
                }
            }
        });

        return filteredFields;
    }
@Test
    public void extractFieldsForTwoMessagesContainingDifferentFields() throws Exception {
        final ResultMessage r1 = mock(ResultMessage.class);
        final Message m1 = mock(Message.class);
        when(m1.getFieldNames()).thenReturn(ImmutableSet.of(
            "message",
            "source",
            "timestamp",
            "http_response",
            "gl2_source_node",
            "_index"
        ));
        when(r1.getMessage()).thenReturn(m1);

        final ResultMessage r2 = mock(ResultMessage.class);
        final Message m2 = mock(Message.class);
        when(m2.getFieldNames()).thenReturn(ImmutableSet.of(
            "message",
            "source",
            "timestamp",
            "took_ms",
            "gl2_source_collector"
        ));
        when(r2.getMessage()).thenReturn(m2);

        final Set<String> result = searchResult.extractFields(ImmutableList.of(r1, r2));

        assertThat(result)
            .isNotNull()
            .isNotEmpty()
            .hasSize(5)
            .containsExactlyInAnyOrder(
                "message",
                "source",
                "timestamp",
                "http_response",
                "took_ms"
            );
    }