Thank @sreeks for being so quick. But I think I did not put my question correctly.
I have a large document and it has an embedded array object, for eg -
{
id : …
name : …
“territory”: [
{
“country”: “GB”,
“selected”: false
},
{
“country”: “US”,
“selected”: true
}
]
}
I am using fts to select for a document that has the country as GB and selected as true. The query is returning me a false positive. Just wanted to understand whether this can be handled by fts indexes.
Also, I came across this link which has a comment by @Gabriel_P1 saying that it can be handled by setting the correct index -
I could not find any concrete examples of how to search for the required combinations in an array of objects in couchbase.
A solution which I was thinking of is to flatten the object and store it in a field
for instance :
{
id : …
name : …
“territory”: [
{
“country”: “GB”,
“selected”: false
"territoryFlattened ": GB, false
},
{
“country”: “US”,
“selected”: true
"territoryFlattened ": US, true
}
]
}
while creating the query, the user could use a query on the flattened field.
And to use regex if he does not provide values for either of the attributes, so the query would be like the search for the match ‘"territoryFlattened ": GB, *’ or ‘"territoryFlattened ": *, false’
What are your thoughts on it, does it look workable?
I would be able to leverage fts completely without moving to GSI or having to write complex queries
Thanks in advance !!