I’m trying to use the full-text search to find matching ids, from an array.
This works:
SELECT data FROM products_cb289f89_6dd2_4cce_89ec_09b443ce1d17 where id in (3515,3512,1541,1543)
But I’m unable to get the POST /search to work:
{
"query": {
"bool": {
"must": [
{
"equals": {
"any(id)": [
3515,
3512,
1541,
1543
]
}
}
]
}
},
"index": "products_cb289f89_6dd2_4cce_89ec_09b443ce1d17",
"size": 100
}
No matter what I do, the result is always only 2 hits.
Am I using it wrong when searching for matching ids?
Sergey
July 14, 2023, 5:27am
2
Here’s an example with the corrected query:
mysql -P9306 -h0 -e "drop table if exists t; create table t; insert into t(id) values(3515),(3512),(1541),(1543);"
➜ ~ curl -sX POST http://localhost:9308/search -d '
{
"query": {
"in": {
"id": [3515, 3512, 1541, 1543]
}
},
"index": "t",
"size": 100
}' | jq .
{
"took": 0,
"timed_out": false,
"hits": {
"total": 4,
"total_relation": "eq",
"hits": [
{
"_id": "3515",
"_score": 1,
"_source": {}
},
{
"_id": "3512",
"_score": 1,
"_source": {}
},
{
"_id": "1541",
"_score": 1,
"_source": {}
},
{
"_id": "1543",
"_score": 1,
"_source": {}
}
]
}
}
Aah, ok, I got confused by the documentation because I thought only about the first set of search where all of them have the bool and must. And then I was searching for array searches, but i should have searched for Sets as mentioned here: Manticore Search Manual: Searching > Filters
Thanks for the quick reply!