[ https://issues.apache.org/jira/browse/METRON-1073?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16139014#comment-16139014 ]
ASF GitHub Bot commented on METRON-1073: ---------------------------------------- Github user merrimanr commented on a diff in the pull request: https://github.com/apache/metron/pull/677#discussion_r134860066 --- Diff: metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchDao.java --- @@ -100,7 +107,16 @@ public SearchResponse search(SearchRequest searchRequest) throws InvalidSearchEx searchResponse.setResults(Arrays.stream(elasticsearchResponse.getHits().getHits()).map(searchHit -> { SearchResult searchResult = new SearchResult(); searchResult.setId(searchHit.getId()); - searchResult.setSource(searchHit.getSource()); + Map<String, Object> source; + if (fields.isPresent()) { + source = new HashMap<>(); + searchHit.getFields().forEach((key, value) -> { + source.put(key, value.getValues().size() == 1 ? value.getValue() : value.getValues()); --- End diff -- If there are no results this line doesn't even get called because this code is inside a Stream map function that's iterating over the results. The test case is really simple though so I added it just to be sure. > Add option to limit fields returned from search query > ----------------------------------------------------- > > Key: METRON-1073 > URL: https://issues.apache.org/jira/browse/METRON-1073 > Project: Metron > Issue Type: New Feature > Reporter: Ryan Merriman > Assignee: Ryan Merriman > > We need a way to specify which search index fields should be returned. This > parameter is optional with all fields being returned by default. -- This message was sent by Atlassian JIRA (v6.4.14#64029)