oksana
April 17, 2024, 9:33pm
1
Hi guys.
There is rt table with json field “info” that looks like
{
"doctors": [
{
"name": "Ben",
"specializations": [...],
"url": "http://example.com"
},
{
"name": "Rob",
"specializations": [...],
"url": "http://example.com"
},
...
],
... // more fields
}
I want to get list of doctor’s names by http json request. Expect [“Ben”, “Rob”, …] in results.
Seen in documentation functions to work with array like ANY, ALL, etc. but nothing to create and represent array values.
Tried request like
{
"index": "review",
"expressions": {
"doctors": "(doctor.name FOR doctor IN info.doctors)", // wrong expression
},
"_source": {
"includes": ["id", "doctors"]
},
"limit": 100,
}
Any ideas how it can be done?
Sergey
April 18, 2024, 3:06am
2
Manticore can’t return just ["Ben", "Rob"]
. The best you can get is:
➜ ~ mysql -P9306 -h0 -e "drop table if exists review; create table review(doctors json); insert into review values(1, '{ \"name\": \"Ben\", \"specializations\": \"\", \"url\": \"http://example.com\" }'),(2, '{ \"name\": \"Rob\", \"specializations\": \"\", \"url\": \"http://example.com\" }');"
➜ ~ curl -s 0:9308/sql -d "query=select%20doctors.name%20from%20review"|jq .
{
"took": 0,
"timed_out": false,
"hits": {
"total": 2,
"total_relation": "eq",
"hits": [
{
"_score": 1,
"_source": {
"doctors.name": "Ben"
}
},
{
"_score": 1,
"_source": {
"doctors.name": "Rob"
}
}
]
}
}
It shouldn’t be a big deal to make it possible to do smth like this:
"_source": {
"includes": ["doctors.name"]
},
which would result in the same as above, but w/o the need to use the sql endpoint. Feel free to create a feature request here Issues · manticoresoftware/manticoresearch · GitHub