elasticsearch - 为什么elasticsearch中的TermQuery这么慢?
问题描述
我一直在使用 es 5.4.3 进行多索引搜索。我使用配置文件 API 跟踪搜索过程,发现其中一个“TermQuery”耗时超过 160 毫秒!我是 es 和 lucene 的新手,但我听说 lucene 中的 termquery 非常快。即使在我将'fielddata'放入内存之后也会发生这种情况(我将在下面展示我的索引是如何设置的),我对我的映射不太自信,我希望有高手能找出我的错误并解决问题。有什么指示让我找出问题所在吗?这个映射是从 es 2.x 派生的,但是官方文档说它会自动进行转换。
new_mappings = {
"properties": {
"did": {"type": "long", "index": "not_analyzed"},
"title": {"type": "string", "index": "analyzed", "fielddata": {"loading": "eager"}},
"title_embed": {"type": "double", "index": "no"},
"entity": {"type": "string", "index": "not_analyzed", "fielddata": {"loading": "eager"}},
"tag": {"type": "string", "index": "not_analyzed"},
"aliases": {"type": "string", "index": "not_analyzed"},
"entity_with_field": {"type": "string", "index": "not_analyzed", "fielddata": {"loading": "eager"}},
"original_title": {"type": "string", "index": "analyzed", "analyzer": "standard", "fielddata": {"loading": "eager"}},
"did3": {"type": "string", "index": "not_analyzed"},
"title_entity": {"type": "string", "index": "not_analyzed", "fielddata": {"loading": "eager"}},
}
}
{
"type" : "TermQuery",
"description" : "title:cure",
"time" : "163.5755780ms",
"time_in_nanos" : 163575578,
"breakdown" : {
"score" : 72259602,
"build_scorer_count" : 19,
"match_count" : 0,
"create_weight" : 35370852,
"next_doc" : 55374841,
"match" : 0,
"create_weight_count" : 1,
"next_doc_count" : 71435,
"score_count" : 71416,
"build_scorer" : 427412,
"advance" : 0,
"advance_count" : 0
}
},
{
"type" : "TermQuery",
"description" : "title:fever",
"time" : "0.2344140000ms",
"time_in_nanos" : 234414,
"breakdown" : {
"score" : 0,
"build_scorer_count" : 19,
"match_count" : 0,
"create_weight" : 230746,
"next_doc" : 0,
"match" : 0,
"create_weight_count" : 1,
"next_doc_count" : 0,
"score_count" : 0,
"build_scorer" : 3648,
"advance" : 0,
"advance_count" : 0
}
解决方案
推荐阅读
- string - Ansible:意外的模板类型错误:预期的字符串或缓冲区
- c# - C# 8 - 多重继承“抽象类”?
- sql - 强制 sqlite 选择查询不返回任何内容而不是 null
- javascript - 将脚本添加到部分内的 javascripts 块
- ios - 在 UILabel (Swift 4) 中显示来自解码 JSON 的信息
- wagtail - 有没有一种简单的方法可以将复制按钮添加到 wagtail 中非页面模型的 IndexListing 中?
- c# - 迭代不断修改的 List
- excel - ExportAsFixedFormat PDF 停止了 Office 365
- mysql - 无法使用 executeQuery 发出数据操作语句 - 数据工作室/mysql 连接器错误
- matplotlib - Matplotlib key_press_event 永远不会在 macOS 后端触发