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 Brian Yee <ye...@gmail.com> on 2017/08/29 15:47:48 UTC

Solr learning to rank features question

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

Fwd: Solr learning to rank features question

Posted by Brian Yee <ye...@gmail.com>.
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

Re: Solr learning to rank features question

Posted by Ryan Yacyshyn <ry...@gmail.com>.
haha.. all good! I'm trying to find my way there now too.

On Wed, Sep 13, 2017, 17:01 Diego Ceccarelli <di...@gmail.com>
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" <ye...@gmail.com> 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 <
> > diego.ceccarelli@gmail.com> 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 <ye...@gmail.com>
> 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
> > > >
> > >
> >
>

Re: Solr learning to rank features question

Posted by Diego Ceccarelli <di...@gmail.com>.
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" <ye...@gmail.com> 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 <
> diego.ceccarelli@gmail.com> 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 <ye...@gmail.com> 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
> > >
> >
>

Re: Solr learning to rank features question

Posted by Brian Yee <ye...@gmail.com>.
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 <
diego.ceccarelli@gmail.com> 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 <ye...@gmail.com> 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
> >
>

Re: Solr learning to rank features question

Posted by Diego Ceccarelli <di...@gmail.com>.
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 <ye...@gmail.com> 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
>