Elasticsearch:无法从关键字字段获取结果
Elasticsearch: Cannot Get Results From Keyword Field
我有一个映射为文本的字段,其中包含另一个映射为关键字(fields 关键字)的字段。我插入数据并确保它可以使用任何查询检索。但是,当我查询附加字段(映射为关键字)时,我根本找不到任何数据。
这是示例(已简化):
POST people/_mapping/_doc
{
"properties": {
"name": {
"type": "text"
},
"bio": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
这是一个查询:
POST people/_search
{
"query": {
"match": {
"bio.keyword": "Portugal"
}
}
}
无论大小写如何(葡萄牙 vs 葡萄牙)都会发生同样的情况。这种行为的原因是什么?
知道了:
Keyword fields are only searchable by their exact value
参考文献:https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html
在 elasticseach 中,如果您有文本类型字段,请说 description
。
描述的一个值是:He likes dog but hate cat.
该字段的还原索引是:He/like/dog/but/hate/cat
还有一个 'keyword' 字段是 description.keyword,正好是 He likes dog but hate cat.
关键字字段要求 100% 匹配。
我有一个映射为文本的字段,其中包含另一个映射为关键字(fields 关键字)的字段。我插入数据并确保它可以使用任何查询检索。但是,当我查询附加字段(映射为关键字)时,我根本找不到任何数据。 这是示例(已简化):
POST people/_mapping/_doc
{
"properties": {
"name": {
"type": "text"
},
"bio": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
这是一个查询:
POST people/_search
{
"query": {
"match": {
"bio.keyword": "Portugal"
}
}
}
无论大小写如何(葡萄牙 vs 葡萄牙)都会发生同样的情况。这种行为的原因是什么?
知道了:
Keyword fields are only searchable by their exact value
参考文献:https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html
在 elasticseach 中,如果您有文本类型字段,请说 description
。
描述的一个值是:He likes dog but hate cat.
该字段的还原索引是:He/like/dog/but/hate/cat
还有一个 'keyword' 字段是 description.keyword,正好是 He likes dog but hate cat.
关键字字段要求 100% 匹配。