【发布时间】:2017-11-22 03:31:29
【问题描述】:
我正在按照以下示例在您键入功能时执行搜索: Edge NGram with phrase matching.
我觉得查询时间与匹配文档的数量有关,即使我只请求前 5 个文档。
我的索引有 3.2 亿份文档。当我的查询是“l”时,600 万个文档与查询匹配,运行查询需要 22 毫秒。但是,当我的查询是“a”时,有 1.33 亿个文档与查询匹配,并且需要 400 毫秒。同样,我只要求前 5 个文件。
请参阅下面的索引定义和查询。
我试图让我的所有查询都少于 100 毫秒。我如何实现这一目标?我错过了什么?
这是我的索引定义:
`
PUT /ss
{
"settings": {
"analysis": {
"filter": {
"english_poss_stemmer": {
"type": "stemmer",
"name": "possessive_english"
},
"edge_ngram": {
"type": "edgeNGram",
"min_gram": "1",
"max_gram": "25",
"token_chars": [
"letter",
"digit"
]
}
},
"analyzer": {
"edge_ngram_analyzer": {
"filter": [
"lowercase",
"english_poss_stemmer",
"edge_ngram"
],
"tokenizer": "standard"
},
"my_standard": {
"filter": [
"lowercase",
"english_poss_stemmer"
],
"tokenizer": "standard"
}
}
}
},
"mappings": {
"ss": {
"_all": {
"enabled": false
},
"properties": {
"name": {
"search_analyzer": "my_standard",
"analyzer": "edge_ngram_analyzer",
"type": "text"
},
"type": {
"search_analyzer": "keyword",
"analyzer": "keyword",
"type": "text"
},
"tax_id": {
"search_analyzer": "keyword",
"analyzer": "keyword",
"type": "text"
}
}
}
}
}
`
这是我的查询:
GET /ss/_search
{
"from": 0,
"size": 5,
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"match_phrase": {
"name": "a"
}
}
}
}
}
【问题讨论】:
标签: elasticsearch elasticsearch-5