解决此问题的一种方法是像这样在映射中添加文本的原始版本
last: { type: 'string', required : true, include_in_all: true, term_vector: 'yes', index_analyzer: 'ngram_analyzer', search_analyzer: 'standard', "fields": { "raw": { "type": "string" <--- index with standard analyzer } } }, first: { type: 'string', required : true, include_in_all: true, term_vector: 'yes', index_analyzer: 'ngram_analyzer', search_analyzer: 'standard', "fields": { "raw": { "type": "string" <--- index with standard analyzer } } },你也可以把它 精确 与
index : not_analyzed
然后您可以像这样查询
{ "query": { "bool": { "should": [ { "match": { "_all": { "query": "Michael", "fuzziness": 2, "prefix_length": 1 } } }, { "match": { "last.raw": { "query": "Michael", "boost": 5 } } }, { "match": { "first.raw": { "query": "Michael", "boost": 5 } } } ] } }}匹配更多条款的文档得分更高。您可以
boost根据需要指定。



