我只是简化了你的问题,为简单起见,我们假设你只需要1场被称为
title包含了像不同的语言
c,
c++,
c#
f#。
该
title字段的索引设置和映射。
{ "settings": { "index": { "analysis": { "analyzer": { "my_analyzer": { "filter": [ "lowercase" ], "char_filter": [ "pre_mapping" ], "tokenizer": "standard" --> notice `standard` } }, "char_filter": { "pre_mapping": { "type": "mapping", "mappings": [ "++ => plusplus", "c# => csharp", "C# => csharp", "F# => fsharp", "f# => fsharp", ".net => dotnet", ".Net => dotnet", ".NET => dotnet", "( => map_lp", ") => map_rp", "& => and", "# => hash", "+ => plus" ] } } } } }, "mappings": { "properties": { "title": { "type": "text", "analyzer": "my_analyzer" --> using custom analyzer created in settings } } }}为一些文档编制索引
POST / _doc / {doc-is}
{ "title": "c#"}{ "title": "c++"}{ "title": "c"}{ "title": "F#"}搜索查询,这是为您提供的问题中提取包含的所有记录的问题
c。
{ "query": { "bool": { "must": [ { "match": { "title": "c++" } } ] } }, "size": 10}现在对我而言,它仅检索仅包含
c++我的搜索API结果中所示的文档。
"hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 0.9808292, "hits": [ { "_index": "cplus", "_type": "_doc", "_id": "1", "_score": 0.9808292, "_source": { "title": "c++" } } ] }


