我尝试通过更具弹性的搜索来实现位置搜索,例如地址以给定查询字符串开头或包含给定字符串作为单词,但是我尝试了几次但没有给出有效结果 可以请一些下面的查询和索引给我建议最好的方法
查询:
GET locations/locations/_search
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"match_phrase": {
"addressLowerCase": {
"query": "manyata "
}
}
},
{
"match_phrase": {
"addressLowerCase": {
"query": "manyata,"
}
}
},
{
"regexp": {
"addressLowerCase": {
"value": "manyata tech park.*"
}
}
}
]
}
}
]
}
}
}
},
"size": 10
}
索引:
PUT locations
{
"settings": {
"number_of_shards": 15,
"auto_expand_replicas": "0-1"
},
"mappings": {
"locations": {
"properties": {
"centerLat": {"type": "keyword"},
"centerLng": {"type": "keyword"},
"addressLowerCase": {
"type": "text",
"index": "true"
},
"address": {
"type": "keyword",
"index": "false"
},
"name": {"type": "keyword"},
"placeId": {"type": "keyword"},
"creationDate": {
"type": "keyword",
"index": "false"
}
}
}
}
}