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 rhys J <rh...@gmail.com> on 2019/11/18 16:04:22 UTC

using scoring to find exact matches while using a cursormark

I am trying to use scoring to get the expected results at the top of the
stack when doing a Solr query.

I am looking up clt_ref_no: OWL-2924-8^2 OR contract_number: OWL-2924-8^2

If I use the following query:in the browser, I get the expected results at
the top of the returned values from Solr.

{
  "responseHeader":{
    "status":0,
    "QTime":41,
    "params":{
      "q":"( clt_ref_no:OWL-2924-8 ^2 OR contract_number:OWL-2924-8^2 )",
      "indent":"on",
      "fl":"clt_ref_no, score",
      "rows":"1000"}},
  "response":{"numFound":84663,"start":0,"maxScore":25.664566,"docs":[
      {
        "clt_ref_no":"OWL-2924-8",
        "score":25.664566},
      {
        "clt_ref_no":"OWL-2924-8",
        "score":25.664566},
      {
        "clt_ref_no":"OWL-2924-8/73847",
        "score":23.509575},
      {
        "clt_ref_no":"OWL-2924-8/73847",
        "score":23.509575},
      {
        "clt_ref_no":"OWL-2924-8/73847",
        "score":23.509575},
      {
        "clt_ref_no":"U615-2924-8",
        "score":19.244316},
      {
        "clt_ref_no":"M1057-2924-8/88543",
        "score":17.650301},

If I add ihe sorting needed for cursor, my results change
dramatically, and the exact matches are not at the top of the stack.

Example:



{
  "responseHeader":{
    "status":0,
    "QTime":80,
    "params":{
      "q":"( clt_ref_no:OWL-2924-8 ^2 OR contract_number:OWL-2924-8^2 )",
      "indent":"on",
      "fl":"clt_ref_no, score",
      "sort":"score asc, id asc",
      "rows":"1000"}},
  "response":{"numFound":84663,"start":0,"maxScore":25.664566,"docs":[
      {
        "clt_ref_no":"MMRO-1258-13/MMRO-1258-13/8",
        "score":1.3380225},
      {
        "clt_ref_no":"MMMP-151-14/MMMP-151-14/8",
        "score":1.3380225},
      {
        "clt_ref_no":"MMRO-806-14/MMRO-806-14/8",
        "score":1.3380225},
      {
        "clt_ref_no":"MMMP-44-14/MMMP-44-14/8",
        "score":1.3380225},
      {
        "clt_ref_no":"MMRO-45-13/MMRO-45-13/8",
        "score":1.3380225},
      {
        "clt_ref_no":"MMIN-202-14/MMIN-202-14/8",
        "score":1.3380225},
      {
        "clt_ref_no":"MMTC-1457-14/MMTC-1457-14/8",
        "score":1.3380225},
      {

Should I not be sorting on score? I thought sorting on score was how I
would get the exact matches to return?

If I add in sort=score asc to the first query, it does what the second
query does, and not have expected matches floating to the top of the
results.

Thanks,

Rhys

Re: using scoring to find exact matches while using a cursormark

Posted by rhys J <rh...@gmail.com>.
> ...so w/o a score param you're getting the default sort: score "desc"
> (descending)...
>
>
> https://lucene.apache.org/solr/guide/8_3/common-query-parameters.html#CommonQueryParameters-ThesortParameter
>
>         "If the sort parameter is omitted, sorting is performed as though
> the
>         parameter were set to score desc."
>
>
>
Oh my goodness, I didn't realize the default was desc! Thanks for pointing
that out. I adjusted my query, and now it's getting the sorting right.

Thanks so much,

Rhys

Re: using scoring to find exact matches while using a cursormark

Posted by Chris Hostetter <ho...@fucit.org>.
: If I use the following query:in the browser, I get the expected results at
: the top of the returned values from Solr.
: 
: {
:   "responseHeader":{
:     "status":0,
:     "QTime":41,
:     "params":{
:       "q":"( clt_ref_no:OWL-2924-8 ^2 OR contract_number:OWL-2924-8^2 )",
:       "indent":"on",
:       "fl":"clt_ref_no, score",
:       "rows":"1000"}},

...so w/o a score param you're getting the default sort: score "desc" 
(descending)...

https://lucene.apache.org/solr/guide/8_3/common-query-parameters.html#CommonQueryParameters-ThesortParameter

	"If the sort parameter is omitted, sorting is performed as though the 
	parameter were set to score desc."

: If I add ihe sorting needed for cursor, my results change
: dramatically, and the exact matches are not at the top of the stack.
	...
: {
:   "responseHeader":{
:     "status":0,
:     "QTime":80,
:     "params":{
:       "q":"( clt_ref_no:OWL-2924-8 ^2 OR contract_number:OWL-2924-8^2 )",
:       "indent":"on",
:       "fl":"clt_ref_no, score",
:       "sort":"score asc, id asc",

...you've requested sort "asc" (ascendeing) which means you're explicitly 
requesting the lowest scoring documents first.

Did you see some example somewhere suggesting that you needed to sort by 
"score asc" ???? 

(there are only a few niche cases where sorting by "score asc" is ever 
moderately useful)


-Hoss
http://www.lucidworks.com/