Hello,

I'm currently using Solr 7.2.2 and trying to use the LTR contrib module to
rerank queries.
For my LTR model, I would like to use a feature that is essentially a
"normalized distance," a value between 0 and 1 which is based on distance.

When using geodist() to define a feature in the feature store, I received a
"failed to parse feature query" error, and thus I am using the below
geofilt query for distance.

    {
      "name":"dist",
      "class":"org.apache.solr.ltr.feature.SolrFeature",
      "params":{"q":"{!geofilt sfield=latlon score=kilometers filter=false
pt=${ltrpt} d=5000}"},
      "store":"ltrFeatureStore"
    }

This feature correctly returns the distance between ltrpt and the sfield
latlon (LatLonPointSpatialField).
As I mentioned previously, I would like a feature which uses this distance
in another function. To test this functionality, I tried to define a
feature which multiplies the distance by two:

    {
      "name":"twoDist",
      "class":"org.apache.solr.ltr.feature.SolrFeature",
      "params":{"q":"{!func}product(2,query({!geofilt v= sfield=latlon
score=kilometers filter=false pt=${ltrpt} d=5000},0.0))"},
      "store":"ltrFeatureStore"
    }

When trying to extract this feature, I receive the following error:

java.lang.RuntimeException: Exception from createWeight for SolrFeature
[name=multDist, params={q={!func}product(2,query({!geofilt v= sfield=latlon
score=kilometers filter=false pt=${ltrpt} d=5000},0.0))}]  missing sfield
for spatial request

However, when I define the following in fl for a regular, non-reranked
query, I find that it is correctly parsed and I receive the correct value,
which is twice the value of geodist() (pt2 is defined in a different part
of the query):
fl=score,geodist(),{!func}product(2,query({!geofilt v= sfield=latlon
score=kilometers filter=false pt=${pt2} d=50000},0.0))

For reference, below is what I have defined in my schema:

   <field name="latlon" type="location" indexed="true" stored="true" />
    <fieldType name="location" class="solr.LatLonPointSpatialField"
docValues="true"/>

Is this the correct, intended behavior? If so, is my query for this
correct, or should I go about extracting this sort of feature a different
way?

Reply via email to