我有以下映射:
"fullName" : {
"type" : "text",
"norms" : false,
"similarity" : "boolean",
"fields" : {
"raw" : {
"type" : "keyword"
},
"terms" : {
"type" : "token_count",
"analyzer" : "standard"
}
}
}我想显示value of terms字段。当我执行以下操作时,我得到的是fullName值,而不是terms值
GET /_search
{"_source": ["fullName","fullName.terms"],
"query": {
"bool" : {
"must" : {
"script" : {
"script" : {
"source": "doc['fullName.terms'].value != 3,
"lang": "painless"
}
}
}
}
}
}我怎么才能得到它呢?
发布于 2018-10-03 18:40:12
您需要将令牌计数配置为已存储- Here documentation
您应该修改您的映射:
"terms" : {
"type" : "token_count",
"analyzer" : "standard",
"store": true
}然后,要检索该值,您需要在查询中显式地请求存储值:( here documentation )
GET /_search
{
"_source": [
"fullName"
],
"stored_fields": [
"fullName.terms"
],
"query": {
"bool": {
"must": {
"script": {
"script": {
"source": "doc['fullName.terms'].value != 3",
"lang": "painless"
}
}
}
}
}
}https://stackoverflow.com/questions/52624518
复制相似问题