rseitz commented on code in PR #1154:
URL: https://github.com/apache/solr/pull/1154#discussion_r1014646304


##########
solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java:
##########
@@ -590,52 +592,79 @@ private void setFilters(ResponseBuilder rb, Elevation 
elevation) {
       return;
     }
 
-    Map<?, ?> tagMap = (Map<?, ?>) rb.req.getContext().get("tags");
-    if (tagMap == null) {
+    Set<Query> excludeSet = getTaggedQueries(rb, excludeTags);
+    if (excludeSet.isEmpty()) {
       // no filters were tagged
       return;
     }
 
-    // TODO: this code is copied from FacetProcessor#handleFilterExclusions()
-    // duplication could be avoided by placing this code in a common utility 
method, perhaps in
-    // QueryUtils
-    IdentityHashMap<Query, Boolean> excludeSet = new IdentityHashMap<>();
-    for (String excludeTag : excludeTags) {
-      Object olst = tagMap.get(excludeTag);
-      // tagMap has entries of List<String,List<QParser>>, but subject to 
change in the future
-      if (!(olst instanceof Collection)) continue;
-      for (Object o : (Collection<?>) olst) {
-        if (!(o instanceof QParser)) continue;
-        QParser qp = (QParser) o;
-        try {
-          excludeSet.put(qp.getQuery(), Boolean.TRUE);
-        } catch (SyntaxError syntaxError) {
-          // This should not happen since we should only be retrieving a 
previously parsed query
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, 
syntaxError);
-        }
-      }
-    }
-
     List<Query> updatedFilters = new ArrayList<Query>();
 
-    for (Query q : filters) {
-      if (!excludeSet.containsKey(q) || q instanceof 
CollapsingQParserPlugin.CollapsingPostFilter) {
-        updatedFilters.add(q);
+    for (Query filter : filters) {
+      if (!excludeSet.contains(filter) || filter instanceof PostFilter) {

Review Comment:
   Updated the code to throw a SolrException when a collapse filter is tagged 
for exclusion; added a test for that and another test to show that 
FunctionRangeQuery can still be tagged and excluded like other query types. 
(Still working on the other changes concerning FilterQuery, etc.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to