SEARCH_META().score behaves different from SEARCH_SCORE() in some N1QL queries

Description

SEARCH_META().score should be the same as SEARCH_SCORE() but in some N1QL queries they behave differently.

I used both "Enterprise Edition 7.0.3 build 7031" and a current Neo build both behave the same.   I load `travel-sample` and then make a full text index as per the attached image.

Consider the two queries they differ only by ASC and DESC, but the behave the same

and

Both return the same thing

and

Not the same ordering and also missing items compared to the next two queries

 

But is we switch from ORDER BY SEARCH_SCORE() ... to ORDER BY SEARCH_META().score ... things look much better.  

and

We get the expected results

and

Components

Affects versions

Fix versions

Labels

Environment

None

Link to Log File, atop/blg, CBCollectInfo, Core dump

None

Release Notes Description

None

Attachments

1

Activity

Show:

Girish Benakappa March 3, 2022 at 12:24 AM

Verified with the fixed build: 7.1.0 build 2409

CB robot February 18, 2022 at 6:01 PM

Build couchbase-server-7.1.0-2344 contains n1fty commit b567f17 with commit message:
: Correct the check for search request's Sort Content

Abhi Dangeti February 18, 2022 at 5:28 PM

Found the issue within N1FTY, here's the fix - https://review.couchbase.org/c/n1fty/+/171035

Abhi Dangeti February 18, 2022 at 5:17 PM

So it does seem like N1QL is handing down the setting to N1FTY ..

It seems some corner case may have been missed within N1FTY.

Abhi Dangeti February 18, 2022 at 3:57 PM
Edited

So ordering with SEARCH_META().score appears to work fine. There seems to be an issue while ORDERING with SEARCH_SCORE though.

For example, these 2 queries return results as expected ..

----
However, the ordering is broken when I use ORDER BY over SEARCH_SCORE() with LIMIT.

That is the results returned by this query

matches the results returned by ..

The ordering with DESC seems right, but the ordering with ASC above fails.

Hey , could this possibly be a N1QL issue?

I've to double check if N1QL is handing down the ORDER BY/LIMIT settings to N1FTY here.

 

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created February 18, 2022 at 3:01 AM
Updated March 3, 2022 at 12:25 AM
Resolved February 18, 2022 at 5:51 PM
Instabug