Solr
  1. Solr
  2. SOLR-4255

Solr 4 spatial- Add a filter=false local-param to just use the distance based valuesource

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      The Solr 4 spatial fields use AbstractSpatialFieldType and by default only filter and supply 1 as the constant score. For sorting or boosting, you can add the local-param score="distance" (or recipDistance) option to have the score of the query be as specified. However this query still filters, and in some cases this is redundant. For example you probably already have a filter query doing the filter portion, and then you are again using the shape reference here for a boost query.

      The change is a simple matter of returning the FunctionQuery and not wrapping it in FilteredQuery.

        Activity

        Hide
        David Smiley added a comment -

        As an example, to boost by the reciprocal distance (scores from 1 down to 0.1 at query shape edge), return the distance, and filter by distance, but not use the 'q' param for the spatial so that it can be used for keyword search, it would look like this:

        http://localhost:8983/solr/collection1/select?
        defType=edismax
        &q.alt=*:*
        &debugQuery=on
        &fl=*,score,distdeg:query({! score=distance filter=false v=$spatialfilter})
        &boost=query({! score=recipDistance filter=false v=$spatialfilter})
        &fq={! v=$spatialfilter}
        &spatialfilter=geo:"Intersects(Circle(54.729696,-98.525391 d=10))"
        

        That example works on the example data with a "geo" field of type "location_rpt" and a copyField from "store" to "geo".

        Show
        David Smiley added a comment - As an example, to boost by the reciprocal distance (scores from 1 down to 0.1 at query shape edge), return the distance, and filter by distance, but not use the 'q' param for the spatial so that it can be used for keyword search, it would look like this: http://localhost:8983/solr/collection1/select? defType=edismax &q.alt=*:* &debugQuery=on &fl=*,score,distdeg:query({! score=distance filter=false v=$spatialfilter}) &boost=query({! score=recipDistance filter=false v=$spatialfilter}) &fq={! v=$spatialfilter} &spatialfilter=geo:"Intersects(Circle(54.729696,-98.525391 d=10))" That example works on the example data with a "geo" field of type "location_rpt" and a copyField from "store" to "geo".
        Hide
        David Smiley added a comment -

        Attached patch; includes test.

        I intend to commit in a couple days or so.

        Show
        David Smiley added a comment - Attached patch; includes test. I intend to commit in a couple days or so.
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] David Wayne Smiley
        http://svn.apache.org/viewvc?view=revision&revision=1429466

        SOLR-4255: add spatial filter=false local-param option

        Show
        Commit Tag Bot added a comment - [trunk commit] David Wayne Smiley http://svn.apache.org/viewvc?view=revision&revision=1429466 SOLR-4255 : add spatial filter=false local-param option
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] David Wayne Smiley
        http://svn.apache.org/viewvc?view=revision&revision=1429468

        SOLR-4255: (CHANGES.txt) add spatial filter=false local-param option

        Show
        Commit Tag Bot added a comment - [trunk commit] David Wayne Smiley http://svn.apache.org/viewvc?view=revision&revision=1429468 SOLR-4255 : (CHANGES.txt) add spatial filter=false local-param option
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] David Wayne Smiley
        http://svn.apache.org/viewvc?view=revision&revision=1429472

        SOLR-4255: add spatial filter=false local-param option

        Show
        Commit Tag Bot added a comment - [branch_4x commit] David Wayne Smiley http://svn.apache.org/viewvc?view=revision&revision=1429472 SOLR-4255 : add spatial filter=false local-param option

          People

          • Assignee:
            David Smiley
            Reporter:
            David Smiley
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development