[英]Elasticsearch simple query string and highlighter leads to timeout
Elasticsearch 遇到一個奇怪的問題:
我有這個導致超時的查詢,因為它需要超過 60 秒:
GET /website/_search
{
"query": {
"simple_query_string": {
"query": "mbs regex replace all",
"fields": ["content_primary"],
"default_operator": "and"
}
},
"highlight": {
"fields": {
"content_primary": {}
}
,"fragment_size" : 200
}
}
有 3 個選項可以使查詢工作:
如果我移除熒光筆,查詢會在 9 毫秒內完成。 如果我搜索“mbs regex replace”(沒有單詞“all”並且啟用了突出顯示和運算符 AND),它將在 166 毫秒內完成。 如果我將查詢運算符更改為 OR(啟用突出顯示),它將在 11 毫秒內完成。
但是對於我的應用程序,我需要完全按照指定的所有三個參數,因為查詢“mbs regex replace all”來自用戶,我需要前端的熒光筆,並且我需要運算符是 AND,所以搜索工作就像用戶期望它。
這里有什么問題?
該索引有 96743 個文檔。 Elasticsearch v7.11.2 托管在 cloud.elastic.co
編輯:這是映射:
PUT /website
{
"settings": {
"analysis": {
"filter" : {
"custom_synonym" : {
"type" : "synonym",
"lenient": true,
"synonyms": [ "FM => FileMaker", "DDR => Datenbank Design Report", "DB => Datenbank", "TO, Table Occurence => Tabellenauftreten" ]
},
"german_stemming": {
"type": "stemmer",
"language": "german"
},
"german_stopping": {
"type": "stop",
"stopwords": "_german_"
}
},
"analyzer": {
"custom_german_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "asciifolding", "custom_synonym"]
}
}
}
},
"mappings" : {
"properties" : {
"authors" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"classifications" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"content_primary" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"german" : {
"type": "text",
"analyzer": "custom_german_analyzer"
}
}
},
"date" : {
"type" : "date"
},
"description" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"domain" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"keywords" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"language" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"properties" : {
"properties" : {
"Plugin Komponente" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"osversion" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"softwareversion" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"source" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"title" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"german" : {
"type": "text",
"analyzer": "custom_german_analyzer"
}
}
},
"url" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"urlToImagePreview" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
謝謝!
事實證明, unified
的默認熒光筆存在長文檔問題。 我將切換到速度更快的plain
模式(在我的情況下是 178 毫秒而不是 60 秒)。
另外,我想我會擺脫超長文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.