我有一个文档,就像下面一样。
{
"_index" : "trigger",
"_type" : "_doc",
"_id" : "urn:trigger:(urn:analyticsplatform:uc4):acxiom_au_attr.done",
"_version" : 45,
"_seq_no" : 420508,
"_primary_term" : 20,
"found" : true,
"_source" : {
"_boostScoreFactor" : 1.0,
"type" : "trigger",
"title" : "acxiom_au_attr.done",
}
}
下面是标题字段的Map。
"title" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
下面是index的设置:
{
"trigger" : {
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"total_shards_per_node" : "2"
}
},
"number_of_shards" : "1",
"provided_name" : "trigger",
"creation_date" : "1668526304683",
"unassigned" : {
"node_left" : {
"delayed_timeout" : "15m"
}
},
"analysis" : {
"filter" : {
"discovery_stemmer" : {
"type" : "stemmer",
"language" : "porter2"
},
"discovery_stemmer_possessive" : {
"type" : "stemmer",
"language" : "minimal_english"
},
"discovery_synonym_abbr" : {
"type" : "synonym_graph",
"synonyms" : [
"BN => browse node"
]
}
},
"char_filter" : {
"discovery_charfilter" : {
"type" : "mapping",
"mappings" : [
".=>|",
"_=>|"
]
}
},
"normalizer" : {
"lowercase" : {
"filter" : [
"lowercase"
],
"type" : "custom",
"char_filter" : [ ]
}
},
"analyzer" : {
"discovery_index_analyzer" : {
"filter" : [
"lowercase",
"discovery_synonym_abbr"
],
"char_filter" : [
"discovery_charfilter"
],
"type" : "custom",
"tokenizer" : "standard"
}
}
},
"number_of_replicas" : "2",
"uuid" : "oMzEq9L_Sum8A5ikwLyCdQ",
"version" : {
"created" : "135238227"
}
}
}
}
}
它使用了一个分析器,将分离的标题,它将被分离成多个术语
{
"tokens" : [
{
"token" : "acxiom",
"start_offset" : 0,
"end_offset" : 6,
"type" : "<ALPHANUM>",
"position" : 0
},
{
"token" : "au",
"start_offset" : 7,
"end_offset" : 9,
"type" : "<ALPHANUM>",
"position" : 1
},
{
"token" : "attr",
"start_offset" : 10,
"end_offset" : 14,
"type" : "<ALPHANUM>",
"position" : 2
}
{
"token" : "done",
"start_offset" : 19,
"end_offset" : 23,
"type" : "<ALPHANUM>",
"position" : 4
}
]
}
但我不能用这个词来搜索。
GET trigger/_search
{
"query": {
"match": {
"title": "acxiom"
}
}
}
如果我使用整个标题,它可以工作。
GET trigger/_search
{
"query": {
"match": {
"title": "acxiom_au_attr.done"
}
}
}
我应该怎么做才能让它支持按词搜索?
1条答案
按热度按时间c8ib6hqw1#
因为我可以检查Map,没有指定分析器。默认情况下,Elasticsearch使用Standard analyzer。
这意味着,如果我插入数据与默认设置(与标准分析仪),它将创建以下条款:
回复
它只创建了一个术语,即
acxiom_au_attr.done
。这就是为什么它与整个值匹配,而不是与部分值匹配。您可以使用simple analyzer,这将创建如下条款:
回复
创建Map
插入文件
搜索关键词