Solr learning to rank features question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Solr learning to rank features question

Brian Yee
Hello,

I have a somewhat complex solr filter query that I am hoping to turn into a
feature for learning to rank, but I am not sure if it's possible. I would
like to OR two fq together for one of my features. I have a cutoff date and
I need to check one field if NOW is before the cutoff, and a different
field if NOW is after the cutoff. Is this possible?

Something to the effect of this:
{
  "name" : "FeatureA",
  "store" : "commonFeatureStore",
  "class" : "org.apache.solr.ltr.feature.SolrFeature",
  "params" : {
    "fq" : [
      "{!frange l=NOW}CutOffDate",
      "{!term f=PreCutOffZones}${zone}"
    ]
    OR
    "fq" : [
      "{!frange u=NOW}CutOffDate",
      "{!term f=PostCutOffZones}${zone}"
    ]
  }
},

Thank you!
Brian Yee
Reply | Threaded
Open this post in threaded view
|

Fwd: Solr learning to rank features question

Brian Yee
Hello,

I have a somewhat complex solr filter query that I am hoping to turn into a
feature for learning to rank, but I am not sure if it's possible. I would
like to OR two fq together for one of my features. I have a cutoff date and
I need to check one field if NOW is before the cutoff, and a different
field if NOW is after the cutoff. Is this possible?

Something to the effect of this:
{
  "name" : "FeatureA",
  "store" : "commonFeatureStore",
  "class" : "org.apache.solr.ltr.feature.SolrFeature",
  "params" : {
    "fq" : [
      "{!frange l=NOW}CutOffDate",
      "{!term f=PreCutOffZones}${zone}"
    ]
    OR
    "fq" : [
      "{!frange u=NOW}CutOffDate",
      "{!term f=PostCutOffZones}${zone}"
    ]
  }
},

Thank you!
Brian Yee
Reply | Threaded
Open this post in threaded view
|

Re: Solr learning to rank features question

Diego Ceccarelli
In reply to this post by Brian Yee
Hi Brian,

The plugin doesn't allow you to express multiple function queries in the
same feature. Maybe in this case you can express both the tw queries in one
unique function query, using the if function.

Something like:

"fq":"if(gt(ms(NOW,mydatefield),0,query(PreCutOffZones:${zone}), query(
PostCutOffZones:${zone}))"


(Function query documentation here:
https://cwiki.apache.org/confluence/display/solr/Function+Queries)

Let me know if it works.

Cheers,
Diego







On Tue, Aug 29, 2017 at 5:47 PM, Brian Yee <[hidden email]> wrote:

> Hello,
>
> I have a somewhat complex solr filter query that I am hoping to turn into a
> feature for learning to rank, but I am not sure if it's possible. I would
> like to OR two fq together for one of my features. I have a cutoff date and
> I need to check one field if NOW is before the cutoff, and a different
> field if NOW is after the cutoff. Is this possible?
>
> Something to the effect of this:
> {
>   "name" : "FeatureA",
>   "store" : "commonFeatureStore",
>   "class" : "org.apache.solr.ltr.feature.SolrFeature",
>   "params" : {
>     "fq" : [
>       "{!frange l=NOW}CutOffDate",
>       "{!term f=PreCutOffZones}${zone}"
>     ]
>     OR
>     "fq" : [
>       "{!frange u=NOW}CutOffDate",
>       "{!term f=PostCutOffZones}${zone}"
>     ]
>   }
> },
>
> Thank you!
> Brian Yee
>
Reply | Threaded
Open this post in threaded view
|

Re: Solr learning to rank features question

Brian Yee
Thank you Diego! This works with some small changes. My feature ended up
looking like this:

{
  "name" : "FeatureA",
  "store" : "commonFeatureStore",
  "class" : "org.apache.solr.ltr.feature.SolrFeature",
  "params" : {
    "q" : "{!func}if(gt(ms(CutoffDate,NOW),0),exists(query({!v=
PreZones:${zone}})),exists(query({!v=PostZones:${zone}})))"
  }
},

On Tue, Aug 29, 2017 at 12:32 PM, Diego Ceccarelli <
[hidden email]> wrote:

> Hi Brian,
>
> The plugin doesn't allow you to express multiple function queries in the
> same feature. Maybe in this case you can express both the tw queries in one
> unique function query, using the if function.
>
> Something like:
>
> "fq":"if(gt(ms(NOW,mydatefield),0,query(PreCutOffZones:${zone}), query(
> PostCutOffZones:${zone}))"
>
>
> (Function query documentation here:
> https://cwiki.apache.org/confluence/display/solr/Function+Queries)
>
> Let me know if it works.
>
> Cheers,
> Diego
>
>
>
>
>
>
>
> On Tue, Aug 29, 2017 at 5:47 PM, Brian Yee <[hidden email]> wrote:
>
> > Hello,
> >
> > I have a somewhat complex solr filter query that I am hoping to turn
> into a
> > feature for learning to rank, but I am not sure if it's possible. I would
> > like to OR two fq together for one of my features. I have a cutoff date
> and
> > I need to check one field if NOW is before the cutoff, and a different
> > field if NOW is after the cutoff. Is this possible?
> >
> > Something to the effect of this:
> > {
> >   "name" : "FeatureA",
> >   "store" : "commonFeatureStore",
> >   "class" : "org.apache.solr.ltr.feature.SolrFeature",
> >   "params" : {
> >     "fq" : [
> >       "{!frange l=NOW}CutOffDate",
> >       "{!term f=PreCutOffZones}${zone}"
> >     ]
> >     OR
> >     "fq" : [
> >       "{!frange u=NOW}CutOffDate",
> >       "{!term f=PostCutOffZones}${zone}"
> >     ]
> >   }
> > },
> >
> > Thank you!
> > Brian Yee
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Solr learning to rank features question

Diego Ceccarelli
Hey man, how's life?
Are you at the conference? I'm going a the reception now, see you there in
case :)

On 29 Aug 2017 12:10, "Brian Yee" <[hidden email]> wrote:

> Thank you Diego! This works with some small changes. My feature ended up
> looking like this:
>
> {
>   "name" : "FeatureA",
>   "store" : "commonFeatureStore",
>   "class" : "org.apache.solr.ltr.feature.SolrFeature",
>   "params" : {
>     "q" : "{!func}if(gt(ms(CutoffDate,NOW),0),exists(query({!v=
> PreZones:${zone}})),exists(query({!v=PostZones:${zone}})))"
>   }
> },
>
> On Tue, Aug 29, 2017 at 12:32 PM, Diego Ceccarelli <
> [hidden email]> wrote:
>
> > Hi Brian,
> >
> > The plugin doesn't allow you to express multiple function queries in the
> > same feature. Maybe in this case you can express both the tw queries in
> one
> > unique function query, using the if function.
> >
> > Something like:
> >
> > "fq":"if(gt(ms(NOW,mydatefield),0,query(PreCutOffZones:${zone}), query(
> > PostCutOffZones:${zone}))"
> >
> >
> > (Function query documentation here:
> > https://cwiki.apache.org/confluence/display/solr/Function+Queries)
> >
> > Let me know if it works.
> >
> > Cheers,
> > Diego
> >
> >
> >
> >
> >
> >
> >
> > On Tue, Aug 29, 2017 at 5:47 PM, Brian Yee <[hidden email]> wrote:
> >
> > > Hello,
> > >
> > > I have a somewhat complex solr filter query that I am hoping to turn
> > into a
> > > feature for learning to rank, but I am not sure if it's possible. I
> would
> > > like to OR two fq together for one of my features. I have a cutoff date
> > and
> > > I need to check one field if NOW is before the cutoff, and a different
> > > field if NOW is after the cutoff. Is this possible?
> > >
> > > Something to the effect of this:
> > > {
> > >   "name" : "FeatureA",
> > >   "store" : "commonFeatureStore",
> > >   "class" : "org.apache.solr.ltr.feature.SolrFeature",
> > >   "params" : {
> > >     "fq" : [
> > >       "{!frange l=NOW}CutOffDate",
> > >       "{!term f=PreCutOffZones}${zone}"
> > >     ]
> > >     OR
> > >     "fq" : [
> > >       "{!frange u=NOW}CutOffDate",
> > >       "{!term f=PostCutOffZones}${zone}"
> > >     ]
> > >   }
> > > },
> > >
> > > Thank you!
> > > Brian Yee
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Solr learning to rank features question

Ryan Yacyshyn
haha.. all good! I'm trying to find my way there now too.

On Wed, Sep 13, 2017, 17:01 Diego Ceccarelli <[hidden email]>
wrote:

> Hey man, how's life?
> Are you at the conference? I'm going a the reception now, see you there in
> case :)
>
> On 29 Aug 2017 12:10, "Brian Yee" <[hidden email]> wrote:
>
> > Thank you Diego! This works with some small changes. My feature ended up
> > looking like this:
> >
> > {
> >   "name" : "FeatureA",
> >   "store" : "commonFeatureStore",
> >   "class" : "org.apache.solr.ltr.feature.SolrFeature",
> >   "params" : {
> >     "q" : "{!func}if(gt(ms(CutoffDate,NOW),0),exists(query({!v=
> > PreZones:${zone}})),exists(query({!v=PostZones:${zone}})))"
> >   }
> > },
> >
> > On Tue, Aug 29, 2017 at 12:32 PM, Diego Ceccarelli <
> > [hidden email]> wrote:
> >
> > > Hi Brian,
> > >
> > > The plugin doesn't allow you to express multiple function queries in
> the
> > > same feature. Maybe in this case you can express both the tw queries in
> > one
> > > unique function query, using the if function.
> > >
> > > Something like:
> > >
> > > "fq":"if(gt(ms(NOW,mydatefield),0,query(PreCutOffZones:${zone}), query(
> > > PostCutOffZones:${zone}))"
> > >
> > >
> > > (Function query documentation here:
> > > https://cwiki.apache.org/confluence/display/solr/Function+Queries)
> > >
> > > Let me know if it works.
> > >
> > > Cheers,
> > > Diego
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Tue, Aug 29, 2017 at 5:47 PM, Brian Yee <[hidden email]>
> wrote:
> > >
> > > > Hello,
> > > >
> > > > I have a somewhat complex solr filter query that I am hoping to turn
> > > into a
> > > > feature for learning to rank, but I am not sure if it's possible. I
> > would
> > > > like to OR two fq together for one of my features. I have a cutoff
> date
> > > and
> > > > I need to check one field if NOW is before the cutoff, and a
> different
> > > > field if NOW is after the cutoff. Is this possible?
> > > >
> > > > Something to the effect of this:
> > > > {
> > > >   "name" : "FeatureA",
> > > >   "store" : "commonFeatureStore",
> > > >   "class" : "org.apache.solr.ltr.feature.SolrFeature",
> > > >   "params" : {
> > > >     "fq" : [
> > > >       "{!frange l=NOW}CutOffDate",
> > > >       "{!term f=PreCutOffZones}${zone}"
> > > >     ]
> > > >     OR
> > > >     "fq" : [
> > > >       "{!frange u=NOW}CutOffDate",
> > > >       "{!term f=PostCutOffZones}${zone}"
> > > >     ]
> > > >   }
> > > > },
> > > >
> > > > Thank you!
> > > > Brian Yee
> > > >
> > >
> >
>