在這裏,我給我更新的映射如何在elasticsearch中進行完全匹配?
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
}
}
}
}'
我的映射如下
{
"testing": {
"mappings": {
"listings": {
"properties": {
"address": {
"properties": {
"city": {
"type": "string"
},
"line1": {
"type": "string"
},
"line2": {
"type": "string"
},
"line3": {
"type": "string"
},
"location": {
"type": "string",
"index": "not_analyzed"
},
"pincode": {
"type": "string"
}
}
},
"title": {
"type": "string"
}
}
}
}
}
}
但是我的數據不匹配創建的索引。
我的樣本數據是
{
"listings": {
"title": "testing 3",
"address": {
"line1": "3rd cross",
"line2": "6th main",
"line3": "",
"landmark": "",
"location": "k r puram",
"pincode": "",
"city": "Bangalore"
}
}
}
當我給查詢作爲k r puram
我得到了匹配的結果。
但是,當我給查詢爲r r puram
或r k puram
那次我也得到了屬於k r puram
的結果。
在上面的查詢中,我只列出了k r puram
列表中的其他人我沒有列出所以除k r puram
之外它應該給出空的結果。
這是我的查詢:
{
"query": {
"bool": {
"must": [
{
"match": {
"published": true
}
},
{
"match": {
"inActive": false
}
},
{
"range": {
"propertyDetailsCategory.build_up_area": {
"lte": 200
}
}
},
{
"match": {
"type": "commercial"
}
},
{
"match": {
"purpose": "rent"
}
},
{
"range": {
"commercialsCategory.exp_rent": {
"lte": 50000
}
}
},
{
"match": {
"address.location": "k r puram"
}
}
]
}
}
}
1.爲什麼要使用multi_match只針對單場? 2.「address.location」實際包含什麼? 3.如何分析? – 2014-12-19 11:34:23
我也用那場比賽也是同樣的結果來了。 address.location包含位置,'address.location'是列表對象中的字段'。 @OllyCruickshank – 2014-12-19 11:39:06
讓我重新解釋一下我的問題 - 「address.location」是否包含「kr puram」的確切值? – 2014-12-19 11:52:08