Hi, I've never used the LTR module, but I suspect I might know what the error is. I think that the "query" Function Query has parsing limitations on what you pass to it. At least it used to. Try to put the embedded query onto another parameter and then refer to it with a dollar-sign. See the examples here: https://builds.apache.org/job/Solr-reference-guide-master/javadoc/function-queries.html#query-function
Also, I think it's a bit inefficient to wrap a query function query around a geofilt query that exposes a distance as a score. If you want the distance then call the "geodist" function query. Additionally if you dump the full stack trace here, it might be helpful. Getting a RuntimeException suggests we need to do a better of job wrapping/cleaning errors internally. ~ David Smiley Apache Lucene/Solr Search Developer http://www.linkedin.com/in/davidwsmiley On Thu, Mar 14, 2019 at 11:43 PM Kamuela Lau <kamuela....@gmail.com> wrote: > 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? >