Ranjan
Ranjan

Reputation: 1146

N1QL query issue in Couchbase lite SQL++ for Mobile

I have a couchbase collection called “books” in “cloud” scope. This is the document structure -

{
    "doc_type": "book_item",
    "plumap": {
        "000": {
            "title": "To Kill a Mockingbird"
        },
        "000": {
            "title": "Pride and Prejudice"
        },
    }
}

I want to search for books by title. This query is working in couchbase server.

SELECT *
FROM bucket.cloud.books AS d
WHERE d.doc_type = 'book_item'
  AND ANY v IN OBJECT_VALUES(d.plumap) SATISFIES v.title LIKE '%mock%' 
  END
LIMIT 5

I want to do the same on Android with SQL++ for mobile but I’m getting this error “N1QL syntax error near character 96” which is the parenthesis “(” after OBJECT_VALUES. How can I fix the syntax?

Or if it’s possible to get this through QueryBuilder is also fine.

Upvotes: 2

Views: 44

Answers (2)

J.Zhao
J.Zhao

Reputation: 64

Currently, Couchbase Lite SQL++ does not support function OBJECT_VALUES. Sorry for the unclear message.

Upvotes: 1

Jens Alfke
Jens Alfke

Reputation: 1981

Couchbase Lite only supports a subset of Server N1QL, and unfortunately that doesn't include the OBJECT_VALUES function.

I believe you can just use ANY v IN d.plumap and it will iterate over the values.

Upvotes: 2

Related Questions