Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-16858

Allow KnnQParser to selectively apply filters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 9.6
    • None

    Description

      The KnnQParser is parsing the filter query which limits the rows considered by the vector query with the following method:

      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;
        }
      

      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.

      {!knn f=vector topK=10 fq=$kfq}[...]&kfq=myquery
      

      Attachments

        1. SOLR-16858-1.patch
          28 kB
          Chris M. Hostetter
        2. SOLR-16858.patch
          13 kB
          Chris M. Hostetter

        Issue Links

          Activity

            People

              hossman Chris M. Hostetter
              jbernste Joel Bernstein
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m