You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ab...@apache.org on 2022/12/20 06:37:55 UTC

[solr] branch jira/SOLR-16567 created (now 88954c8d13d)

This is an automated email from the ASF dual-hosted git repository.

abenedetti pushed a change to branch jira/SOLR-16567
in repository https://gitbox.apache.org/repos/asf/solr.git


      at 88954c8d13d better post-filter check according to review suggestions

This branch includes the following new commits:

     new 88954c8d13d better post-filter check according to review suggestions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[solr] 01/01: better post-filter check according to review suggestions

Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

abenedetti pushed a commit to branch jira/SOLR-16567
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 88954c8d13d3469019c85b217516a0928571d094
Author: Alessandro Benedetti <a....@sease.io>
AuthorDate: Tue Dec 20 07:37:17 2022 +0100

    better post-filter check according to review suggestions
---
 .../java/org/apache/solr/search/neural/KnnQParser.java   | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java b/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java
index a7b7984e042..6f3dc4956a2 100644
--- a/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java
@@ -29,7 +29,7 @@ import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.schema.DenseVectorField;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.SchemaField;
-import org.apache.solr.search.ExtendedQuery;
+import org.apache.solr.search.PostFilter;
 import org.apache.solr.search.QParser;
 import org.apache.solr.search.QueryParsing;
 import org.apache.solr.search.QueryUtils;
@@ -114,13 +114,21 @@ public class KnnQParser extends QParser {
     return null;
   }
 
+  /**
+   * This methods filters out all the post-filters from the filters in input, keeping only the
+   * pre-filters. According to the documentation a filter query is a post-filter if: it implements
+   * {@link PostFilter} and ExtendedQuery.getCost() returns no less than 100
+   *
+   * @param filters filter queries in the knn query request
+   * @return the list of pre-filters
+   */
   private List<Query> acceptPreFiltersOnly(List<Query> filters) {
     return filters.stream()
         .filter(
             q -> {
-              if (q instanceof ExtendedQuery) {
-                ExtendedQuery eq = (ExtendedQuery) q;
-                return eq.getCost() == 0;
+              if (q instanceof PostFilter) {
+                PostFilter filter = (PostFilter) q;
+                return filter.getCost() < 100;
               } else {
                 return true;
               }