You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Kamuela Lau <ka...@gmail.com> on 2019/03/15 03:42:53 UTC
Nested geofilt query for LTR feature
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?
Re: Nested geofilt query for LTR feature
Posted by David Smiley <da...@gmail.com>.
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 <ka...@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?
>
Re: Gather Nodes Streaming
Posted by Joel Bernstein <jo...@gmail.com>.
gatherNodes requires single value fields in the tuples. In certain
scenarios the cartesianProduct streaming expression can be used to explode
a multi-value field into a single field stream. But in the scenario you
describe this might not be possible.
Joel Bernstein
http://joelsolr.blogspot.com/
On Wed, Mar 20, 2019 at 10:58 PM Zheng Lin Edwin Yeo <ed...@gmail.com>
wrote:
> Hi,
>
> What is the fieldType of your 'to field? Which tokenizers/filters is it
> using?
>
> Also, which Solr version are you using?
>
> Regards,
> Edwin
>
> On Thu, 21 Mar 2019 at 01:57, Susmit Shukla <sh...@gmail.com>
> wrote:
>
> > Hi,
> >
> > Trying to use solr streaming 'gatherNodes' function. It is for extracting
> > email graph based on from and to fields.
> > It requires 'to' field to be a single value field with docvalues enabled
> > since it is used internally for sorting and unique streams
> >
> > The 'to' field can contain multiple email addresses - each being a node.
> > How to map multiple comma separated email addresses from the 'to' fields
> as
> > separate graph nodes?
> >
> > Thanks
> >
> >
> >
> > >
> > >
> >
>
Re: Gather Nodes Streaming
Posted by Zheng Lin Edwin Yeo <ed...@gmail.com>.
Hi,
What is the fieldType of your 'to field? Which tokenizers/filters is it
using?
Also, which Solr version are you using?
Regards,
Edwin
On Thu, 21 Mar 2019 at 01:57, Susmit Shukla <sh...@gmail.com> wrote:
> Hi,
>
> Trying to use solr streaming 'gatherNodes' function. It is for extracting
> email graph based on from and to fields.
> It requires 'to' field to be a single value field with docvalues enabled
> since it is used internally for sorting and unique streams
>
> The 'to' field can contain multiple email addresses - each being a node.
> How to map multiple comma separated email addresses from the 'to' fields as
> separate graph nodes?
>
> Thanks
>
>
>
> >
> >
>
Gather Nodes Streaming
Posted by Susmit Shukla <sh...@gmail.com>.
Hi,
Trying to use solr streaming 'gatherNodes' function. It is for extracting
email graph based on from and to fields.
It requires 'to' field to be a single value field with docvalues enabled
since it is used internally for sorting and unique streams
The 'to' field can contain multiple email addresses - each being a node.
How to map multiple comma separated email addresses from the 'to' fields as
separate graph nodes?
Thanks
>
>