Hi,
I need to use multiple search in one field on FTS.
For example;
[{
“categories”:[11,12,13]
},
{
“categories”:[11,12,16]
}]
how to search in categories contains 11 and 12 values.
Thanks.
Hi,
I need to use multiple search in one field on FTS.
For example;
[{
“categories”:[11,12,13]
},
{
“categories”:[11,12,16]
}]
how to search in categories contains 11 and 12 values.
Thanks.
Remember FTS returns “document IDs” as hits for a search request.
{"categories": [11,12,13]}
- then you can simply index categories
as a numeric field and run a conjunction query over it …{
"query": {
"conjuncts": [
{
"field": "categories",
"min": 11,
"max": 11,
"inclusive_min": true,
"inclusive_max": true
},
{
"field": "categories",
"min": 12,
"max": 12,
"inclusive_min": true,
"inclusive_max": true
}
]
}
}
[
{
"categories":[11,12,13]
},
{
"categories":[14,15,16]
}
]
… and you wish to return the document as a hit ONLY if a single array subobject has both 11
and 12
- then this is NOT possible with couchbase FTS at the moment.
This is because FTS flattens arrays and in doing so, it does not save the element position within arrays which is needed to determine which subobject in an array an element belongs to.
I’d recommend looking into N1QL queries with secondary indexes to achieve this. cc @vsr1 .
Hi @abhinav,
Your solution solve my problem.
Thank you.
I use it like this;
int id = Convert.ToInt32(catId);
mustQueries.And(new NumericRangeQuery()
.Field("categories.categoryId")
.Min(id, true)
.Max(id, true))
.Boost(6);