我的示例数据如下所示:
{"listings":{"title" : "testing 1", "address" : { "line1" : "3rd cross", "line2" : "6th main", "line3" : "", "landmark" : "", "location" : "k r puram", "pincode" : "", "city" : "Bangalore" },"purpose":"rent","published": true, "inActive": false },
{"listings":{"title" : "testing 2", "address" : { "line1" : "3rd cross", "line2" : "6th main", "line3" : "", "landmark" : "", "location" : "banaswadi", "pincode" : "", "city" : "Bangalore" },"purpose":"sale","published": true, "inActive": false },
{"listings":{"title" : "testing 3", "address" : { "line1" : "3rd cross", "line2" : "6th main", "line3" : "", "landmark" : "", "location" : "tin factory", "pincode" : "", "city" : "Bangalore" },"purpose":"rent","published": true, "inActive": false }
我的索引映射如下所示:
curl -X PUT localhost:9200/testing/listings/_mapping -d '{
"listings" : {
"properties" : {
"address" : {
"properties": {
"location": { "type" : "string",
"index" : "not_analyzed"
}
}
},
"suggest" : {
"type" : "completion",
"index_analyzer" : "simple",
"search_analyzer" : "simple",
"payloads" : true
}
}
}
}'
我根据目的属性值(如租金或销售)访问列表对象。我可以单独访问要出租和出售的对象。我如何访问列表对象以获取租金和销售价值。我使用下面的查询来获取出租和销售列表对象。
{"query":{
"filtered": {
"filter": {
"terms": {
"purpose" : ["rent", "sale"]
}
}
},
"bool":{
"must":[
{"match":{"published":true}},
{"match":{"inActive":false}},
{"match":{"address.city": "bangalore"}}
]
}
}
}
请根据需要提出更改建议。提前致谢。