我有一个这样的es文档:
{
"_index" : "jobpipeline",
"_type" : "_doc",
"_id" : "xxxx",
"_version" : 19,
"_seq_no" : 417185,
"_primary_term" : 18,
"found" : true,
"_source" : {
"_boostScoreFactor" : 1.0,
"type" : "jobpipeline",
"owner" : [
""
],
"title" : "xxxx",
"watchTriggers" : [
"uc4.abc",
"uc4.abc.done"
],
"touchTriggers" : [
"uc4.abc.done"
],
}
}
如果我使用这样的查询,它不会返回任何内容。
GET jobpipeline/_search
{
"query": {
"wildcard": {
"touchTriggers": "*uc4.abc.done*"
}
}
}
如果我删除'uc4.',它可以命中这个文档。
GET dd-jobpipeline/_search
{
"query": {
"wildcard": {
"touchTriggers": "*abc.done*"
}
}
}
我应该怎么做才能使用'uc4.abc.done'并且它会命中文档?
touchTriggers 字段的映射
"touchTriggers" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
您需要在
wildcard
字段上运行 touchTriggers.keyword
查询。我很惊讶您通过查询文本字段没有收到任何错误。
GET jobpipeline/_search
{
"query": {
"wildcard": {
"touchTriggers.keyword": "*uc4.abc.done*"
} ^^^^^
}
}