我已经索引了一个包含150多个元数据的单个文档,每个文档都有映射:

"ACTIVE": {
    "type": "text",
    "term_vector": "with_positions_offsets",
    "fields": {
        "autocomplete_analyzed": {
            "type": "text",
            "analyzer": "autocomplete"
            },
        "keyword": {
            "type": "keyword",
            "ignore_above": 256
        }
    }
}

并设置,:

"analysis": {
    "analyzer": {
        "autocomplete": {
            "filter": [
                "lowercase"
            ],
            "tokenizer": "autocomplete"
        }
    },
    "tokenizer": {
        "autocomplete": {
            "min_gram": "3",
            "tokenize_on_chars": [
                "whitespace",
                "letter",
                "digit"
            ],
            "type": "edge_ngram",
            "max_gram": "7"
        }
    }
}

我使用术语 _vector 能够在我的查询中使用快速矢量突出显示 . 我的查询:

{
    "from": 0,
    "size": 24,
    "query": {
        "bool": {
            "should": [
                {
                    "multi_match": {
                        "query": "current",
                        "type": "best_fields",
                        "fields": []
                    }
                },
                {
                    "query_string": {
                        "query": "*current*",
                        "fields": []
                    }
                },
                {
                    "multi_match": {
                        "query": "current",
                        "fuzziness": "1",
                        "fields": []
                    }
                }
            ],
            "minimum_should_match": 1
        }
    },
    "highlight": {
        "type": "fvh",
        "fields": {
            "*": {}
         }
    }
}

我的查询需要模糊性,通配符和短语匹配 . 根据我对后端的要求,禁用或启用模糊和通配符 . 但是在自由文本搜索中,我必须启用它,包括突出显示 .

  • 使用突出显示,我的查询需要超过15000毫秒,但没有突出显示它需要800毫秒

  • 没有模糊和突出显示它需要大约1200毫秒,没有模糊和突出显示它需要大约500毫秒 .

由于模糊和突出显示一起工作,查询缓慢 . 如何突出显示术语矢量索引文档?为什么查询运行得这么慢?是由于我的查询还是由于索引数据?因为,我将处理数百万份文件 . 什么是解决这个时间问题的最佳方法?