[ 
https://issues.apache.org/jira/browse/METRON-1585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16502431#comment-16502431
 ] 

ASF GitHub Bot commented on METRON-1585:
----------------------------------------

Github user justinleet commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1050#discussion_r193207415
  
    --- Diff: 
metron-platform/metron-solr/src/main/java/org/apache/metron/solr/dao/SolrRetrieveLatestDao.java
 ---
    @@ -61,10 +70,13 @@ public Document getLatest(String guid, String 
collection) throws IOException {
       public Iterable<Document> getAllLatest(List<GetRequest> getRequests) 
throws IOException {
         Map<String, Collection<String>> collectionIdMap = new HashMap<>();
         for (GetRequest getRequest : getRequests) {
    -      Collection<String> ids = collectionIdMap
    -          .getOrDefault(getRequest.getSensorType(), new HashSet<>());
    -      ids.add(getRequest.getGuid());
    -      collectionIdMap.put(getRequest.getSensorType(), ids);
    +      Optional<String> index = SolrUtilities
    +          .getIndex(config.getIndexSupplier(), getRequest.getSensorType(), 
Optional.empty());
    +      if (index.isPresent()) {
    +        Collection<String> ids = collectionIdMap.getOrDefault(index.get(), 
new HashSet<>());
    +        ids.add(getRequest.getGuid());
    +        collectionIdMap.put(index.get(), ids);
    +      }
    --- End diff --
    
    It means that someone requested something bogus (e.g. a GUID against the 
wrong sensor).  Logging it is a good idea, though.


> SolrRetrieveLatestDao does not use the collection lookup
> --------------------------------------------------------
>
>                 Key: METRON-1585
>                 URL: https://issues.apache.org/jira/browse/METRON-1585
>             Project: Metron
>          Issue Type: Sub-task
>            Reporter: Justin Leet
>            Assignee: Justin Leet
>            Priority: Major
>
> `getLatest` interface has the second arg as "sensorType", but the Solr DAO 
> makes the assumption that it's "collection" and renames the arg and uses it 
> without retrieving the actual collection. 
> https://github.com/apache/metron/blob/feature/METRON-1416-upgrade-solr/metron-platform/metron-solr/src/main/java/org/apache/metron/solr/dao/SolrRetrieveLatestDao.java#L47
> `getAllLatest` at 
> https://github.com/apache/metron/blob/feature/METRON-1416-upgrade-solr/metron-platform/metron-solr/src/main/java/org/apache/metron/solr/dao/SolrRetrieveLatestDao.java#L47
> This can affect other DAOs that defer to this DAO (e.g. update and metaalert)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to