[ https://issues.apache.org/jira/browse/SOLR-16858?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chris M. Hostetter updated SOLR-16858: -------------------------------------- Attachment: SOLR-16858.patch Assignee: Chris M. Hostetter (was: Joel Bernstein) Status: Open (was: Open) I've attached a patch that implements the {{fq}} local param change joel suggested when creating this jira, along with some tests proving that it works with one or more values, and/or that an "empty" {{fq}} local param can be used to prevent the use of any of the global {{fq}} params from being wrapped. I think this is good for the users (like me) that want to be able to say "I have very specific filters i want my KNN query to wrap" but i've talked to some folks who think about using KNN very differently then i do, who really like the current behavior of slurping up all of the global {{fq}} params, but they really need the ability to _exclude_ a few fq params based on tags – in the same way that multiselect faceting requires using {{excludeTags}} as you add {{fq}} params for drilldown. Specifically the usecase for these folks is: * Initial Request ** {noformat} ?q={!knn excludeTags=drill_down topK=1000}... &fq=foo &fq=bar &... &facet.field=xxx &facet.field=yyy {noformat} ** where _by default_ any {{fq}} param is used as a pre-filter ensure they get the "fullest" possible {{topK}} * When a user clicks on one or more facet term to drill down ** {noformat} ?q={!knn excludeTags=drill_down topK=1000}... &fq=foo &fq=bar &... &facet.field=xxx &facet.field=yyy &fq={!term tag=drill_down f=xxx}... &fq={!term tag=drill_down f=yyy}... {noformat} ** so that the {{numFound}} starts to decrease, as all of the facet drill down {{fq}} params are applied independently to the {{knn}} I think this would be a nice addition to the flexibility of the {{knn}} QParser, and would be fairly straightforward to implement. I have some nocommit comments / psuedo-code in my patch about how i think we can go about it. Part of my idea is to not only support an {{excludeTags}} localparam, but also an {{includeTags}} param for folks who might have a lot of {{fq}} params that they use in _every_ request (ie: invariants/appends on the handler), and if/when the {{q}} param uses {{knn}} they want a large subset (but not {_}all{_}) of their {{fq}} params to be slurped up by the {{knn}} parser. Next week i'll start work up some test cases for these ideas, and then convert the nocommit psuedo-code into real code to confirm it's actually as easy to support as i think it should be. > 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.patch > > > 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: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org