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

Alessandro Benedetti commented on SOLR-16858:
---------------------------------------------

I spent some peaceful and not distracted time on this issue and I we are on the 
same page.
I totally agree with:

----
My thinking about this issue is that KnnQParser should support multiple ways of 
defining the pre-filter that exists on the resulting KnnVectorQuery :
(1) When KnnQParser is used for the main query string, FQ params are used to 
build the default pre-filter on the KnnVectorQuery
if you find yourself in a situation where you only want to use some (but not 
all) of the global FQs - you can use includeTags or excludeTags localparams to 
adjust the set of FQ params used
(2) Regardless of where/how you use KnnQParser , a preFilter local param can be 
used to override the default behavior and explicit set the pre-filter on the 
KnnVectorQuery
...ie: there doesn't have to be one and only one way of specifying what gets 
put in KnnVectorQuery.getFilter – we can give the user options (and in some use 
cases, one option will be easier to use then others)
does that make sense?

----
we just need to carefully craft the pull request and the way this is explained 
to users via documentation
I'll wait for your next iteration and then I'll add any additional feedback on 
the PR.
Thanks for your effort!

> Allow KnnQParser to selectively apply filters
> ---------------------------------------------
>
>                 Key: SOLR-16858
>                 URL: https://issues.apache.org/jira/browse/SOLR-16858
>             Project: Solr
>          Issue Type: Bug
>            Reporter: Joel Bernstein
>            Assignee: Chris M. Hostetter
>            Priority: Major
>              Labels: hybrid-search
>         Attachments: SOLR-16858-1.patch, SOLR-16858.patch
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> The KnnQParser is parsing the filter query which limits the rows considered 
> by the vector query with the following method:
> {code:java}
> private Query getFilterQuery() throws SolrException, SyntaxError {
>     boolean isSubQuery = recurseCount != 0;
>     if (!isFilter() && !isSubQuery) {
>       String[] filterQueries = req.getParams().getParams(CommonParams.FQ);
>       if (filterQueries != null && filterQueries.length != 0) {
>         try {
>           List<Query> filters = QueryUtils.parseFilterQueries(req);
>           SolrIndexSearcher.ProcessedFilter processedFilter =
>               req.getSearcher().getProcessedFilter(filters);
>           return processedFilter.filter;
>         } catch (IOException e) {
>           throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
>         }
>       }
>     }
>     return null;
>   }
> {code}
> This is pulling all filter queries from the main query parameters and using 
> them to limit the vector query. This is the automatic behavior of the 
> KnnQParser.
> There are cases where you may want to selectively apply different filters. 
> One such case is SOLR-16857 which involves reRanking a collapsed query.
> Overriding the default filter behavior could be done by adding an "fq" local 
> parameter to the KnnQParser which would override the default filtering 
> behavior.
> {code:java}
> {!knn f=vector topK=10 fq=$kfq}[...]&kfq=myquery
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to