Sergey
41
➜ ~ mysql -v -P9306 -h0 -e "drop table t; create table t(metadata json); insert into t(metadata) values('{\"cpu\": {\"model\": \"Cortex ABC\"}}'); SELECT * FROM t WHERE REGEX(metadata.cpu.model, 'Cortex A.*');"
--------------
drop table t
--------------
--------------
create table t(metadata json)
--------------
--------------
insert into t(metadata) values('{"cpu": {"model": "Cortex ABC"}}')
--------------
--------------
SELECT * FROM t WHERE REGEX(metadata.cpu.model, 'Cortex A.*')
--------------
+---------------------+--------------------------------+
| id | metadata |
+---------------------+--------------------------------+
| 1515388920550916275 | {"cpu":{"model":"Cortex ABC"}} |
+---------------------+--------------------------------+
➜ ~ curl -sX POST http://localhost:9308/search -d '
{
"index":"t",
"query": {
"equals": { "cond": 1 }
},
"expressions": {
"cond": "REGEX(metadata.cpu.model, '\''Cortex A.*'\'')"
}
}'|jq .
{
"took": 0,
"timed_out": false,
"hits": {
"total": 1,
"total_relation": "eq",
"hits": [
{
"_id": "1515388920550916275",
"_score": 1,
"_source": {
"metadata": {
"cpu": {
"model": "Cortex ABC"
}
},
"cond": 1
}
}
]
}
}