SQL 类查询的弹性查询
Elastic Query for SQL like query
想在弹性搜索中搜索,就像我们在 SQL query = (age = 25 and name = xyz).
这适用于单个字段和单个数据。
是的,很有可能,就用下面的ES Mapping查询一下:
映射
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"age" :{
"type" : "integer"
}
}
},
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "1"
}
}
}
索引文档
{
"name": "xyz",
"age" : 25
}
查询
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "xyz"
}
},
{
"match": {
"age": 25
}
}
]
}
}
}
除了接受的答案
POST _sql?format=txt {
"query":"SELECT age, name FROM collection WHERE age=25 AND name ='xyz'"
}
想在弹性搜索中搜索,就像我们在 SQL query = (age = 25 and name = xyz).
这适用于单个字段和单个数据。
是的,很有可能,就用下面的ES Mapping查询一下:
映射
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"age" :{
"type" : "integer"
}
}
},
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "1"
}
}
}
索引文档
{
"name": "xyz",
"age" : 25
}
查询
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "xyz"
}
},
{
"match": {
"age": 25
}
}
]
}
}
}
除了接受的答案
POST _sql?format=txt {
"query":"SELECT age, name FROM collection WHERE age=25 AND name ='xyz'"
}