nickwallen commented on a change in pull request #1269: METRON-1879 Allow
Elasticsearch to Auto-Generate the Document ID
URL: https://github.com/apache/metron/pull/1269#discussion_r240814413
##########
File path:
metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchRetrieveLatestDao.java
##########
@@ -102,54 +92,47 @@ public Document getLatest(String guid, String sensorType)
throws IOException {
if (guids == null || guids.isEmpty()) {
return Collections.emptyList();
}
- QueryBuilder query = null;
- IdsQueryBuilder idsQuery;
- if (sensorTypes != null) {
- String[] types = sensorTypes.stream().map(sensorType -> sensorType +
"_doc")
- .toArray(String[]::new);
- idsQuery = QueryBuilders.idsQuery(types);
- } else {
- idsQuery = QueryBuilders.idsQuery();
- }
- for (String guid : guids) {
- query = idsQuery.addIds(guid);
+ // should match any of the guids
+ // the 'guid' field must be of type 'keyword' or this term query will not
match
+ BoolQueryBuilder guidQuery = boolQuery().must(termsQuery(Constants.GUID,
guids));
Review comment:
We can no longer use an id query, since the doc ID is no longer the same as
the GUID.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services