我刚开始使用es,我想知道如何编写查询来执行类似“城市1中的3张床”或“城市1中学校2附近的2个浴室”的搜索。据我所知,我们可以使用同义词处理3张床/床/bd/床房间,但是我如何知道“城市1中的3张床”意味着我需要在beds字段中搜索3,在城市字段中搜索City1?
这是我的样例数据集。
{
Address :
{
City : "City 1",
Zip : 21222
},
Beds : 3,
Baths : 2,
Schools :
[
"School 1",
"School 2"
]
},
{
Address :
{
City : "City 2",
Zip : 21220
},
Beds : 1,
Baths : 1,
Schools :
[
"School 3",
"School 2"
]
}
提前感谢!
发布于 2015-10-08 13:24:02
query: {
bool: {
must: [{
term: {
address.city : {
value: City1
}
},{
term: {
beds : {
value: 3
}
}]
}}
https://stackoverflow.com/questions/32983261
复制相似问题