[英]Elasticsearch spatial search with terms
我正在對 140+ 百萬個包含空間數據的文檔進行查詢。 純空間查詢非常快(低於 1 秒)。 將通配符添加到相同的幾何圖形會導致查詢耗時約 10-20 秒。 我希望通配符查詢需要一些時間,但我想知道是否有更好的方法來編寫查詢或欺騙 Elasticsearch 將結果過濾為僅幾何形狀,然后查找通配符匹配項。 或者,也許運行空間查詢,然后在生成的文檔 ID 上運行通配符? 任何可能為最終用戶帶來更快結果的想法將不勝感激。
GET parcels/_search
{
"query": {
"bool": {
"must": [
{
"wildcard": {
"name.keyword": {
"value": "*smith*"
}
}
},
{
"bool": {
"filter": [
{
"geo_shape": {
"shape": {
"shape": {
"type": "POLYGON",
"coordinates": [
[
[
-81.09980486601305,
32.063655184739936
],
[
-81.09980486601168,
32.05639855631687
],
[
-81.09128330779276,
32.05639855631687
],
[
-81.09128330779276,
32.06365489826756
],
[
-81.09980486601305,
32.063655184739936
]
]
]
},
"relation": "intersects"
}
}
}
]
}
}
]
}
},
"size": 10000
}
我們對索引的設置:
{
...
"analysis": {
"normalizer": {
"search_normalizer": {
"filter": [
"uppercase"
],
"type": "custom"
}
}
},
"number_of_shards": 8,
"number_of_replicas": 1,
“名稱”字段的映射:
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "search_normalizer"
}
}
},
運行 ES 7.10。 (5 個節點,每個節點有 8GB RAM)
不通過通配符搜索不是一種選擇。
任何幫助表示贊賞。
在keyword
字段上使用帶有前綴通配符的通配符搜索(如*smith*
)是性能殺手!
如果您絕對需要這種功能,則需要利用專門用於這種用途的新wildcard
字段類型。
因此,您可以添加另一個子字段或將keyword
子字段更改為?通配符子字段。
您可以在博客文章中看到它是如何工作的,其中通配符字段在出現時進行了描述。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.