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 OTH <om...@gmail.com> on 2017/06/07 20:35:16 UTC

Score higher if multiple terms match

Hello,

I have what I would think to be a fairly simple problem to solve, however
I'm not sure how it's done in Solr and couldn't find an answer on Google.

Say I have two documents, "TV" and "TV promotion".  If the search query is
"TV promotion", then, obviously, I would like the document "TV promotion"
to score higher.  However, that is not the case right now.

My syntax is something like this:
http://localhost:8983/solr/sales/select?indent=on&wt=json&fl=*,score&q=name:tv
promotion
(I tried "q=name:tv+promotion (added the '+'), but it made no difference.)

It's not scoring the document "TV promotion" higher than "TV"; in fact it's
scoring it lower.

Thanks

Re: Score higher if multiple terms match

Posted by David Hastings <ha...@gmail.com>.
Agreed, you need to show the debug query info from your original query:


My syntax is something like this:
>> >>> >> http://localhost:8983/solr/sales/select?indent=on&wt=json&
>> >>> >> fl=*,score&q=name:tv
>> >>> >> promotion

and could probably help you get the results you want


On Thu, Jun 8, 2017 at 10:54 AM, Erick Erickson <er...@gmail.com>
wrote:

> bq: I hope that clears the confusion.
>
> Nope, doesn't clear it up at all. It's not clear which query you're
> talking about.... at least to me.
>
> If you're searching for
> name:tv AND name:promotion
>
> and getting back a document that has only "tv" in the name field
> that's simply wrong and you need to find out why.
>
> If you're saying that searching for
> name:tv OR name:promotion
>
> returns both and that docs with both terms score higher, that's likely
> true although it'll be fuzzy. I'm guessing that the name field is
> fairly short so the length norm will be the sam and this will be
> fairly reliable. If the field could have a widely varying number of
> terms it's less reliable.
>
> Best,
> Erick
>
> On Thu, Jun 8, 2017 at 1:41 AM, OTH <om...@gmail.com> wrote:
> > Hi - Sorry it was very late at night for me and I think I didn't pick my
> > wordings right.
> > bq: it is indeed returning documents with only either one of the two
> query
> > terms
> > What I meant was:  Initially, I thought it was only returning documents
> > which contained both 'tv' and 'promotion'.  Then I realized I was
> mistaken;
> > it was also returning documents which contained either 'tv' or
> 'promotion'
> > (as well as documents which contained both, which were scored higher).
> > I hope that clears the confusion.
> > Thanks
> >
> > On Thu, Jun 8, 2017 at 9:04 AM, Erick Erickson <er...@gmail.com>
> > wrote:
> >
> >> bq: it is indeed returning documents with only either one of the two
> query
> >> terms
> >>
> >> Uhm, this should not be true. What's the output of adding debug=query?
> >> And are you totally sure the above is true and you're just not seeing
> >> the other term in the return? Or that you have a synonyms file that is
> >> somehow making docs match? Or ???
> >>
> >> So you're saying you get the exact same number of hits for
> >> name:tv OR name:promotion
> >> and
> >> name:tv AND name:promotion
> >> ??? Definitely not expected unless all docs happen to have both these
> >> terms in the name field either through normal input or synonyms etc.
> >>
> >> You should need something like:
> >> name:tv OR name:promotion OR (name:tv AND name:promotion)^100
> >> to score all the docs with both terms in the name field higher than just
> >> one.
> >>
> >> Best,
> >> Erick
> >>
> >> On Wed, Jun 7, 2017 at 3:05 PM, OTH <om...@gmail.com> wrote:
> >> > I'm sorry, there was a mistake.
> >> >
> >> > I previously wrote:
> >> >
> >> > However, these are returning only those documents which have both the
> >> terms
> >> >> 'tv promotion' in them (there are a few).  It's not returning any
> >> >> document which have only 'tv' or only 'promotion' in them.
> >> >
> >> >
> >> > That's not true at all; it is indeed returning documents with only
> either
> >> > one of the two query terms (so, documents with only 'tv' or only
> >> > 'promotion' in them).  Sorry.  You can disregard my question in the
> last
> >> > email.
> >> >
> >> > Thanks
> >> >
> >> > On Thu, Jun 8, 2017 at 2:03 AM, OTH <om...@gmail.com> wrote:
> >> >
> >> >> Thanks.
> >> >> Both of these are working in my case:
> >> >> name:"tv promotion"   -->  name:"tv promotion"
> >> >> name:tv AND name:promotion --> name:tv AND name:promotion
> >> >> (Although I'm assuming, the first might not have worked if my
> document
> >> had
> >> >> been say 'promotion tv' or 'tv xyz promotion')
> >> >>
> >> >> However, these are returning only those documents which have both the
> >> >> terms 'tv promotion' in them (there are a few).  It's not returning
> any
> >> >> document which have only 'tv' or only 'promotion' in them.
> >> >>
> >> >> That's not an absolute requirement of mine, I could work around it,
> but
> >> I
> >> >> was just wondering, if it were possible to pass a single solr query
> with
> >> >> both the terms 'tv' and 'promotion' in them, and have them return all
> >> the
> >> >> documents which contain either of those terms, but with higher scores
> >> >> attached to those documents with both those terms?
> >> >>
> >> >> Much thanks
> >> >>
> >> >> On Thu, Jun 8, 2017 at 1:43 AM, David Hastings <
> >> >> hastings.recursive@gmail.com> wrote:
> >> >>
> >> >>> sorry, i meant debug query where you would get output like this:
> >> >>>
> >> >>> "debug": {
> >> >>>     "rawquerystring": "name:tv promotion",
> >> >>>     "querystring": "name:tv promotion",
> >> >>>     "parsedquery": "+name:tv +text:promotion",
> >> >>>
> >> >>>
> >> >>> On Wed, Jun 7, 2017 at 4:41 PM, David Hastings <
> >> >>> hastings.recursive@gmail.com
> >> >>> > wrote:
> >> >>>
> >> >>> > well, short answer, use the analyzer to see whats happening.
> >> >>> > long answer
> >> >>> >  theres a difference between
> >> >>> > name:tv promotion   -->  name:tv default_field:promotion
> >> >>> > name:"tv promotion"   -->  name:"tv promotion"
> >> >>> > name:tv AND name:promotion --> name:tv AND name:promotion
> >> >>> >
> >> >>> >
> >> >>> > since your default field most likely isnt name, its going to
> search
> >> only
> >> >>> > the default field for it.  you can alter this behavior using qf
> >> >>> parameters:
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > qf='name^5 text'
> >> >>> >
> >> >>> >
> >> >>> > for example would apply a boost of 5 if it matched the field
> 'name',
> >> and
> >> >>> > only 1 for 'text'
> >> >>> >
> >> >>> > On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:
> >> >>> >
> >> >>> >> Hello,
> >> >>> >>
> >> >>> >> I have what I would think to be a fairly simple problem to solve,
> >> >>> however
> >> >>> >> I'm not sure how it's done in Solr and couldn't find an answer on
> >> >>> Google.
> >> >>> >>
> >> >>> >> Say I have two documents, "TV" and "TV promotion".  If the search
> >> >>> query is
> >> >>> >> "TV promotion", then, obviously, I would like the document "TV
> >> >>> promotion"
> >> >>> >> to score higher.  However, that is not the case right now.
> >> >>> >>
> >> >>> >> My syntax is something like this:
> >> >>> >> http://localhost:8983/solr/sales/select?indent=on&wt=json&
> >> >>> >> fl=*,score&q=name:tv
> >> >>> >> promotion
> >> >>> >> (I tried "q=name:tv+promotion (added the '+'), but it made no
> >> >>> difference.)
> >> >>> >>
> >> >>> >> It's not scoring the document "TV promotion" higher than "TV"; in
> >> fact
> >> >>> >> it's
> >> >>> >> scoring it lower.
> >> >>> >>
> >> >>> >> Thanks
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>>
> >> >>
> >> >>
> >>
>

Re: Score higher if multiple terms match

Posted by Erick Erickson <er...@gmail.com>.
bq: I hope that clears the confusion.

Nope, doesn't clear it up at all. It's not clear which query you're
talking about.... at least to me.

If you're searching for
name:tv AND name:promotion

and getting back a document that has only "tv" in the name field
that's simply wrong and you need to find out why.

If you're saying that searching for
name:tv OR name:promotion

returns both and that docs with both terms score higher, that's likely
true although it'll be fuzzy. I'm guessing that the name field is
fairly short so the length norm will be the sam and this will be
fairly reliable. If the field could have a widely varying number of
terms it's less reliable.

Best,
Erick

On Thu, Jun 8, 2017 at 1:41 AM, OTH <om...@gmail.com> wrote:
> Hi - Sorry it was very late at night for me and I think I didn't pick my
> wordings right.
> bq: it is indeed returning documents with only either one of the two query
> terms
> What I meant was:  Initially, I thought it was only returning documents
> which contained both 'tv' and 'promotion'.  Then I realized I was mistaken;
> it was also returning documents which contained either 'tv' or 'promotion'
> (as well as documents which contained both, which were scored higher).
> I hope that clears the confusion.
> Thanks
>
> On Thu, Jun 8, 2017 at 9:04 AM, Erick Erickson <er...@gmail.com>
> wrote:
>
>> bq: it is indeed returning documents with only either one of the two query
>> terms
>>
>> Uhm, this should not be true. What's the output of adding debug=query?
>> And are you totally sure the above is true and you're just not seeing
>> the other term in the return? Or that you have a synonyms file that is
>> somehow making docs match? Or ???
>>
>> So you're saying you get the exact same number of hits for
>> name:tv OR name:promotion
>> and
>> name:tv AND name:promotion
>> ??? Definitely not expected unless all docs happen to have both these
>> terms in the name field either through normal input or synonyms etc.
>>
>> You should need something like:
>> name:tv OR name:promotion OR (name:tv AND name:promotion)^100
>> to score all the docs with both terms in the name field higher than just
>> one.
>>
>> Best,
>> Erick
>>
>> On Wed, Jun 7, 2017 at 3:05 PM, OTH <om...@gmail.com> wrote:
>> > I'm sorry, there was a mistake.
>> >
>> > I previously wrote:
>> >
>> > However, these are returning only those documents which have both the
>> terms
>> >> 'tv promotion' in them (there are a few).  It's not returning any
>> >> document which have only 'tv' or only 'promotion' in them.
>> >
>> >
>> > That's not true at all; it is indeed returning documents with only either
>> > one of the two query terms (so, documents with only 'tv' or only
>> > 'promotion' in them).  Sorry.  You can disregard my question in the last
>> > email.
>> >
>> > Thanks
>> >
>> > On Thu, Jun 8, 2017 at 2:03 AM, OTH <om...@gmail.com> wrote:
>> >
>> >> Thanks.
>> >> Both of these are working in my case:
>> >> name:"tv promotion"   -->  name:"tv promotion"
>> >> name:tv AND name:promotion --> name:tv AND name:promotion
>> >> (Although I'm assuming, the first might not have worked if my document
>> had
>> >> been say 'promotion tv' or 'tv xyz promotion')
>> >>
>> >> However, these are returning only those documents which have both the
>> >> terms 'tv promotion' in them (there are a few).  It's not returning any
>> >> document which have only 'tv' or only 'promotion' in them.
>> >>
>> >> That's not an absolute requirement of mine, I could work around it, but
>> I
>> >> was just wondering, if it were possible to pass a single solr query with
>> >> both the terms 'tv' and 'promotion' in them, and have them return all
>> the
>> >> documents which contain either of those terms, but with higher scores
>> >> attached to those documents with both those terms?
>> >>
>> >> Much thanks
>> >>
>> >> On Thu, Jun 8, 2017 at 1:43 AM, David Hastings <
>> >> hastings.recursive@gmail.com> wrote:
>> >>
>> >>> sorry, i meant debug query where you would get output like this:
>> >>>
>> >>> "debug": {
>> >>>     "rawquerystring": "name:tv promotion",
>> >>>     "querystring": "name:tv promotion",
>> >>>     "parsedquery": "+name:tv +text:promotion",
>> >>>
>> >>>
>> >>> On Wed, Jun 7, 2017 at 4:41 PM, David Hastings <
>> >>> hastings.recursive@gmail.com
>> >>> > wrote:
>> >>>
>> >>> > well, short answer, use the analyzer to see whats happening.
>> >>> > long answer
>> >>> >  theres a difference between
>> >>> > name:tv promotion   -->  name:tv default_field:promotion
>> >>> > name:"tv promotion"   -->  name:"tv promotion"
>> >>> > name:tv AND name:promotion --> name:tv AND name:promotion
>> >>> >
>> >>> >
>> >>> > since your default field most likely isnt name, its going to search
>> only
>> >>> > the default field for it.  you can alter this behavior using qf
>> >>> parameters:
>> >>> >
>> >>> >
>> >>> >
>> >>> > qf='name^5 text'
>> >>> >
>> >>> >
>> >>> > for example would apply a boost of 5 if it matched the field 'name',
>> and
>> >>> > only 1 for 'text'
>> >>> >
>> >>> > On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:
>> >>> >
>> >>> >> Hello,
>> >>> >>
>> >>> >> I have what I would think to be a fairly simple problem to solve,
>> >>> however
>> >>> >> I'm not sure how it's done in Solr and couldn't find an answer on
>> >>> Google.
>> >>> >>
>> >>> >> Say I have two documents, "TV" and "TV promotion".  If the search
>> >>> query is
>> >>> >> "TV promotion", then, obviously, I would like the document "TV
>> >>> promotion"
>> >>> >> to score higher.  However, that is not the case right now.
>> >>> >>
>> >>> >> My syntax is something like this:
>> >>> >> http://localhost:8983/solr/sales/select?indent=on&wt=json&
>> >>> >> fl=*,score&q=name:tv
>> >>> >> promotion
>> >>> >> (I tried "q=name:tv+promotion (added the '+'), but it made no
>> >>> difference.)
>> >>> >>
>> >>> >> It's not scoring the document "TV promotion" higher than "TV"; in
>> fact
>> >>> >> it's
>> >>> >> scoring it lower.
>> >>> >>
>> >>> >> Thanks
>> >>> >>
>> >>> >
>> >>> >
>> >>>
>> >>
>> >>
>>

Re: Score higher if multiple terms match

Posted by OTH <om...@gmail.com>.
Hi - Sorry it was very late at night for me and I think I didn't pick my
wordings right.
bq: it is indeed returning documents with only either one of the two query
terms
What I meant was:  Initially, I thought it was only returning documents
which contained both 'tv' and 'promotion'.  Then I realized I was mistaken;
it was also returning documents which contained either 'tv' or 'promotion'
(as well as documents which contained both, which were scored higher).
I hope that clears the confusion.
Thanks

On Thu, Jun 8, 2017 at 9:04 AM, Erick Erickson <er...@gmail.com>
wrote:

> bq: it is indeed returning documents with only either one of the two query
> terms
>
> Uhm, this should not be true. What's the output of adding debug=query?
> And are you totally sure the above is true and you're just not seeing
> the other term in the return? Or that you have a synonyms file that is
> somehow making docs match? Or ???
>
> So you're saying you get the exact same number of hits for
> name:tv OR name:promotion
> and
> name:tv AND name:promotion
> ??? Definitely not expected unless all docs happen to have both these
> terms in the name field either through normal input or synonyms etc.
>
> You should need something like:
> name:tv OR name:promotion OR (name:tv AND name:promotion)^100
> to score all the docs with both terms in the name field higher than just
> one.
>
> Best,
> Erick
>
> On Wed, Jun 7, 2017 at 3:05 PM, OTH <om...@gmail.com> wrote:
> > I'm sorry, there was a mistake.
> >
> > I previously wrote:
> >
> > However, these are returning only those documents which have both the
> terms
> >> 'tv promotion' in them (there are a few).  It's not returning any
> >> document which have only 'tv' or only 'promotion' in them.
> >
> >
> > That's not true at all; it is indeed returning documents with only either
> > one of the two query terms (so, documents with only 'tv' or only
> > 'promotion' in them).  Sorry.  You can disregard my question in the last
> > email.
> >
> > Thanks
> >
> > On Thu, Jun 8, 2017 at 2:03 AM, OTH <om...@gmail.com> wrote:
> >
> >> Thanks.
> >> Both of these are working in my case:
> >> name:"tv promotion"   -->  name:"tv promotion"
> >> name:tv AND name:promotion --> name:tv AND name:promotion
> >> (Although I'm assuming, the first might not have worked if my document
> had
> >> been say 'promotion tv' or 'tv xyz promotion')
> >>
> >> However, these are returning only those documents which have both the
> >> terms 'tv promotion' in them (there are a few).  It's not returning any
> >> document which have only 'tv' or only 'promotion' in them.
> >>
> >> That's not an absolute requirement of mine, I could work around it, but
> I
> >> was just wondering, if it were possible to pass a single solr query with
> >> both the terms 'tv' and 'promotion' in them, and have them return all
> the
> >> documents which contain either of those terms, but with higher scores
> >> attached to those documents with both those terms?
> >>
> >> Much thanks
> >>
> >> On Thu, Jun 8, 2017 at 1:43 AM, David Hastings <
> >> hastings.recursive@gmail.com> wrote:
> >>
> >>> sorry, i meant debug query where you would get output like this:
> >>>
> >>> "debug": {
> >>>     "rawquerystring": "name:tv promotion",
> >>>     "querystring": "name:tv promotion",
> >>>     "parsedquery": "+name:tv +text:promotion",
> >>>
> >>>
> >>> On Wed, Jun 7, 2017 at 4:41 PM, David Hastings <
> >>> hastings.recursive@gmail.com
> >>> > wrote:
> >>>
> >>> > well, short answer, use the analyzer to see whats happening.
> >>> > long answer
> >>> >  theres a difference between
> >>> > name:tv promotion   -->  name:tv default_field:promotion
> >>> > name:"tv promotion"   -->  name:"tv promotion"
> >>> > name:tv AND name:promotion --> name:tv AND name:promotion
> >>> >
> >>> >
> >>> > since your default field most likely isnt name, its going to search
> only
> >>> > the default field for it.  you can alter this behavior using qf
> >>> parameters:
> >>> >
> >>> >
> >>> >
> >>> > qf='name^5 text'
> >>> >
> >>> >
> >>> > for example would apply a boost of 5 if it matched the field 'name',
> and
> >>> > only 1 for 'text'
> >>> >
> >>> > On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:
> >>> >
> >>> >> Hello,
> >>> >>
> >>> >> I have what I would think to be a fairly simple problem to solve,
> >>> however
> >>> >> I'm not sure how it's done in Solr and couldn't find an answer on
> >>> Google.
> >>> >>
> >>> >> Say I have two documents, "TV" and "TV promotion".  If the search
> >>> query is
> >>> >> "TV promotion", then, obviously, I would like the document "TV
> >>> promotion"
> >>> >> to score higher.  However, that is not the case right now.
> >>> >>
> >>> >> My syntax is something like this:
> >>> >> http://localhost:8983/solr/sales/select?indent=on&wt=json&
> >>> >> fl=*,score&q=name:tv
> >>> >> promotion
> >>> >> (I tried "q=name:tv+promotion (added the '+'), but it made no
> >>> difference.)
> >>> >>
> >>> >> It's not scoring the document "TV promotion" higher than "TV"; in
> fact
> >>> >> it's
> >>> >> scoring it lower.
> >>> >>
> >>> >> Thanks
> >>> >>
> >>> >
> >>> >
> >>>
> >>
> >>
>

Re: Score higher if multiple terms match

Posted by Erick Erickson <er...@gmail.com>.
bq: it is indeed returning documents with only either one of the two query terms

Uhm, this should not be true. What's the output of adding debug=query?
And are you totally sure the above is true and you're just not seeing
the other term in the return? Or that you have a synonyms file that is
somehow making docs match? Or ???

So you're saying you get the exact same number of hits for
name:tv OR name:promotion
and
name:tv AND name:promotion
??? Definitely not expected unless all docs happen to have both these
terms in the name field either through normal input or synonyms etc.

You should need something like:
name:tv OR name:promotion OR (name:tv AND name:promotion)^100
to score all the docs with both terms in the name field higher than just one.

Best,
Erick

On Wed, Jun 7, 2017 at 3:05 PM, OTH <om...@gmail.com> wrote:
> I'm sorry, there was a mistake.
>
> I previously wrote:
>
> However, these are returning only those documents which have both the terms
>> 'tv promotion' in them (there are a few).  It's not returning any
>> document which have only 'tv' or only 'promotion' in them.
>
>
> That's not true at all; it is indeed returning documents with only either
> one of the two query terms (so, documents with only 'tv' or only
> 'promotion' in them).  Sorry.  You can disregard my question in the last
> email.
>
> Thanks
>
> On Thu, Jun 8, 2017 at 2:03 AM, OTH <om...@gmail.com> wrote:
>
>> Thanks.
>> Both of these are working in my case:
>> name:"tv promotion"   -->  name:"tv promotion"
>> name:tv AND name:promotion --> name:tv AND name:promotion
>> (Although I'm assuming, the first might not have worked if my document had
>> been say 'promotion tv' or 'tv xyz promotion')
>>
>> However, these are returning only those documents which have both the
>> terms 'tv promotion' in them (there are a few).  It's not returning any
>> document which have only 'tv' or only 'promotion' in them.
>>
>> That's not an absolute requirement of mine, I could work around it, but I
>> was just wondering, if it were possible to pass a single solr query with
>> both the terms 'tv' and 'promotion' in them, and have them return all the
>> documents which contain either of those terms, but with higher scores
>> attached to those documents with both those terms?
>>
>> Much thanks
>>
>> On Thu, Jun 8, 2017 at 1:43 AM, David Hastings <
>> hastings.recursive@gmail.com> wrote:
>>
>>> sorry, i meant debug query where you would get output like this:
>>>
>>> "debug": {
>>>     "rawquerystring": "name:tv promotion",
>>>     "querystring": "name:tv promotion",
>>>     "parsedquery": "+name:tv +text:promotion",
>>>
>>>
>>> On Wed, Jun 7, 2017 at 4:41 PM, David Hastings <
>>> hastings.recursive@gmail.com
>>> > wrote:
>>>
>>> > well, short answer, use the analyzer to see whats happening.
>>> > long answer
>>> >  theres a difference between
>>> > name:tv promotion   -->  name:tv default_field:promotion
>>> > name:"tv promotion"   -->  name:"tv promotion"
>>> > name:tv AND name:promotion --> name:tv AND name:promotion
>>> >
>>> >
>>> > since your default field most likely isnt name, its going to search only
>>> > the default field for it.  you can alter this behavior using qf
>>> parameters:
>>> >
>>> >
>>> >
>>> > qf='name^5 text'
>>> >
>>> >
>>> > for example would apply a boost of 5 if it matched the field 'name', and
>>> > only 1 for 'text'
>>> >
>>> > On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:
>>> >
>>> >> Hello,
>>> >>
>>> >> I have what I would think to be a fairly simple problem to solve,
>>> however
>>> >> I'm not sure how it's done in Solr and couldn't find an answer on
>>> Google.
>>> >>
>>> >> Say I have two documents, "TV" and "TV promotion".  If the search
>>> query is
>>> >> "TV promotion", then, obviously, I would like the document "TV
>>> promotion"
>>> >> to score higher.  However, that is not the case right now.
>>> >>
>>> >> My syntax is something like this:
>>> >> http://localhost:8983/solr/sales/select?indent=on&wt=json&
>>> >> fl=*,score&q=name:tv
>>> >> promotion
>>> >> (I tried "q=name:tv+promotion (added the '+'), but it made no
>>> difference.)
>>> >>
>>> >> It's not scoring the document "TV promotion" higher than "TV"; in fact
>>> >> it's
>>> >> scoring it lower.
>>> >>
>>> >> Thanks
>>> >>
>>> >
>>> >
>>>
>>
>>

Re: Score higher if multiple terms match

Posted by OTH <om...@gmail.com>.
I'm sorry, there was a mistake.

I previously wrote:

However, these are returning only those documents which have both the terms
> 'tv promotion' in them (there are a few).  It's not returning any
> document which have only 'tv' or only 'promotion' in them.


That's not true at all; it is indeed returning documents with only either
one of the two query terms (so, documents with only 'tv' or only
'promotion' in them).  Sorry.  You can disregard my question in the last
email.

Thanks

On Thu, Jun 8, 2017 at 2:03 AM, OTH <om...@gmail.com> wrote:

> Thanks.
> Both of these are working in my case:
> name:"tv promotion"   -->  name:"tv promotion"
> name:tv AND name:promotion --> name:tv AND name:promotion
> (Although I'm assuming, the first might not have worked if my document had
> been say 'promotion tv' or 'tv xyz promotion')
>
> However, these are returning only those documents which have both the
> terms 'tv promotion' in them (there are a few).  It's not returning any
> document which have only 'tv' or only 'promotion' in them.
>
> That's not an absolute requirement of mine, I could work around it, but I
> was just wondering, if it were possible to pass a single solr query with
> both the terms 'tv' and 'promotion' in them, and have them return all the
> documents which contain either of those terms, but with higher scores
> attached to those documents with both those terms?
>
> Much thanks
>
> On Thu, Jun 8, 2017 at 1:43 AM, David Hastings <
> hastings.recursive@gmail.com> wrote:
>
>> sorry, i meant debug query where you would get output like this:
>>
>> "debug": {
>>     "rawquerystring": "name:tv promotion",
>>     "querystring": "name:tv promotion",
>>     "parsedquery": "+name:tv +text:promotion",
>>
>>
>> On Wed, Jun 7, 2017 at 4:41 PM, David Hastings <
>> hastings.recursive@gmail.com
>> > wrote:
>>
>> > well, short answer, use the analyzer to see whats happening.
>> > long answer
>> >  theres a difference between
>> > name:tv promotion   -->  name:tv default_field:promotion
>> > name:"tv promotion"   -->  name:"tv promotion"
>> > name:tv AND name:promotion --> name:tv AND name:promotion
>> >
>> >
>> > since your default field most likely isnt name, its going to search only
>> > the default field for it.  you can alter this behavior using qf
>> parameters:
>> >
>> >
>> >
>> > qf='name^5 text'
>> >
>> >
>> > for example would apply a boost of 5 if it matched the field 'name', and
>> > only 1 for 'text'
>> >
>> > On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:
>> >
>> >> Hello,
>> >>
>> >> I have what I would think to be a fairly simple problem to solve,
>> however
>> >> I'm not sure how it's done in Solr and couldn't find an answer on
>> Google.
>> >>
>> >> Say I have two documents, "TV" and "TV promotion".  If the search
>> query is
>> >> "TV promotion", then, obviously, I would like the document "TV
>> promotion"
>> >> to score higher.  However, that is not the case right now.
>> >>
>> >> My syntax is something like this:
>> >> http://localhost:8983/solr/sales/select?indent=on&wt=json&
>> >> fl=*,score&q=name:tv
>> >> promotion
>> >> (I tried "q=name:tv+promotion (added the '+'), but it made no
>> difference.)
>> >>
>> >> It's not scoring the document "TV promotion" higher than "TV"; in fact
>> >> it's
>> >> scoring it lower.
>> >>
>> >> Thanks
>> >>
>> >
>> >
>>
>
>

Re: Score higher if multiple terms match

Posted by OTH <om...@gmail.com>.
Thanks.
Both of these are working in my case:
name:"tv promotion"   -->  name:"tv promotion"
name:tv AND name:promotion --> name:tv AND name:promotion
(Although I'm assuming, the first might not have worked if my document had
been say 'promotion tv' or 'tv xyz promotion')

However, these are returning only those documents which have both the terms
'tv promotion' in them (there are a few).  It's not returning any document
which have only 'tv' or only 'promotion' in them.

That's not an absolute requirement of mine, I could work around it, but I
was just wondering, if it were possible to pass a single solr query with
both the terms 'tv' and 'promotion' in them, and have them return all the
documents which contain either of those terms, but with higher scores
attached to those documents with both those terms?

Much thanks

On Thu, Jun 8, 2017 at 1:43 AM, David Hastings <hastings.recursive@gmail.com
> wrote:

> sorry, i meant debug query where you would get output like this:
>
> "debug": {
>     "rawquerystring": "name:tv promotion",
>     "querystring": "name:tv promotion",
>     "parsedquery": "+name:tv +text:promotion",
>
>
> On Wed, Jun 7, 2017 at 4:41 PM, David Hastings <
> hastings.recursive@gmail.com
> > wrote:
>
> > well, short answer, use the analyzer to see whats happening.
> > long answer
> >  theres a difference between
> > name:tv promotion   -->  name:tv default_field:promotion
> > name:"tv promotion"   -->  name:"tv promotion"
> > name:tv AND name:promotion --> name:tv AND name:promotion
> >
> >
> > since your default field most likely isnt name, its going to search only
> > the default field for it.  you can alter this behavior using qf
> parameters:
> >
> >
> >
> > qf='name^5 text'
> >
> >
> > for example would apply a boost of 5 if it matched the field 'name', and
> > only 1 for 'text'
> >
> > On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:
> >
> >> Hello,
> >>
> >> I have what I would think to be a fairly simple problem to solve,
> however
> >> I'm not sure how it's done in Solr and couldn't find an answer on
> Google.
> >>
> >> Say I have two documents, "TV" and "TV promotion".  If the search query
> is
> >> "TV promotion", then, obviously, I would like the document "TV
> promotion"
> >> to score higher.  However, that is not the case right now.
> >>
> >> My syntax is something like this:
> >> http://localhost:8983/solr/sales/select?indent=on&wt=json&
> >> fl=*,score&q=name:tv
> >> promotion
> >> (I tried "q=name:tv+promotion (added the '+'), but it made no
> difference.)
> >>
> >> It's not scoring the document "TV promotion" higher than "TV"; in fact
> >> it's
> >> scoring it lower.
> >>
> >> Thanks
> >>
> >
> >
>

Re: Score higher if multiple terms match

Posted by David Hastings <ha...@gmail.com>.
sorry, i meant debug query where you would get output like this:

"debug": {
    "rawquerystring": "name:tv promotion",
    "querystring": "name:tv promotion",
    "parsedquery": "+name:tv +text:promotion",


On Wed, Jun 7, 2017 at 4:41 PM, David Hastings <hastings.recursive@gmail.com
> wrote:

> well, short answer, use the analyzer to see whats happening.
> long answer
>  theres a difference between
> name:tv promotion   -->  name:tv default_field:promotion
> name:"tv promotion"   -->  name:"tv promotion"
> name:tv AND name:promotion --> name:tv AND name:promotion
>
>
> since your default field most likely isnt name, its going to search only
> the default field for it.  you can alter this behavior using qf parameters:
>
>
>
> qf='name^5 text'
>
>
> for example would apply a boost of 5 if it matched the field 'name', and
> only 1 for 'text'
>
> On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:
>
>> Hello,
>>
>> I have what I would think to be a fairly simple problem to solve, however
>> I'm not sure how it's done in Solr and couldn't find an answer on Google.
>>
>> Say I have two documents, "TV" and "TV promotion".  If the search query is
>> "TV promotion", then, obviously, I would like the document "TV promotion"
>> to score higher.  However, that is not the case right now.
>>
>> My syntax is something like this:
>> http://localhost:8983/solr/sales/select?indent=on&wt=json&
>> fl=*,score&q=name:tv
>> promotion
>> (I tried "q=name:tv+promotion (added the '+'), but it made no difference.)
>>
>> It's not scoring the document "TV promotion" higher than "TV"; in fact
>> it's
>> scoring it lower.
>>
>> Thanks
>>
>
>

Re: Score higher if multiple terms match

Posted by David Hastings <ha...@gmail.com>.
well, short answer, use the analyzer to see whats happening.
long answer
 theres a difference between
name:tv promotion   -->  name:tv default_field:promotion
name:"tv promotion"   -->  name:"tv promotion"
name:tv AND name:promotion --> name:tv AND name:promotion


since your default field most likely isnt name, its going to search only
the default field for it.  you can alter this behavior using qf parameters:



qf='name^5 text'


for example would apply a boost of 5 if it matched the field 'name', and
only 1 for 'text'

On Wed, Jun 7, 2017 at 4:35 PM, OTH <om...@gmail.com> wrote:

> Hello,
>
> I have what I would think to be a fairly simple problem to solve, however
> I'm not sure how it's done in Solr and couldn't find an answer on Google.
>
> Say I have two documents, "TV" and "TV promotion".  If the search query is
> "TV promotion", then, obviously, I would like the document "TV promotion"
> to score higher.  However, that is not the case right now.
>
> My syntax is something like this:
> http://localhost:8983/solr/sales/select?indent=on&wt=
> json&fl=*,score&q=name:tv
> promotion
> (I tried "q=name:tv+promotion (added the '+'), but it made no difference.)
>
> It's not scoring the document "TV promotion" higher than "TV"; in fact it's
> scoring it lower.
>
> Thanks
>