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

Add QParser boolean hint for filter queries

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: search
    • Labels:
      None

      Description

      It would be useful if there was a QParser hint of some kind that indicated that the score isn't needed. This would be set by Solr in QueryComponent when processing the fq param, and some field types could check for this and return more efficient Query implementations from FieldType.getFieldQuery(). For example, a geospatial field could return a ConstantScoreQuery(Filter) implementation when only filtering is needed, or return a query that returns a geospatial distance for a document's score. I think there are probably other opportunities for this flag to have its use but I'm not sure.

      As an example solution, a local param of needScore=false could be added. I should be functionally equivalent to fq=

      {!needScore=false}

      .....

      Here is a modified portion of QueryComponent at line 135 to illustrate what the change would be. I haven't tested it but it compiles.

              for (String fq : fqs) {
                if (fq != null && fq.trim().length()!=0) {
                  QParser fqp = QParser.getParser(fq, null, req);
                  SolrParams localParams = fqp.getLocalParams();
                  SolrParams defaultLocalParams = new MapSolrParams(Collections.singletonMap("needScore","false"));
                  SolrParams newLocalParams = new DefaultSolrParams(localParams,defaultLocalParams);
                  fqp.setLocalParams(newLocalParams);
                  filters.add(fqp.getQuery());
                }
              }
      

      It would probably be best to define the "needScore" constant somewhere better but this is it in a nutshell.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dsmiley@mac.com David Smiley
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: