Elasticsearch

Elasticsearch,第1张

Elasticsearch

您需要为您的

project.name
字段进行以下映射

{  "mappings": {    "vma_docs": {      "properties": {        "client": {          "properties": { "contact": {   "type": "string" }, "name": {   "type": "string" }          }        },        "project": {          "properties": { "end_date": {   "format": "yyyy-MM-dd",   "type": "date" }, "project_type": {   "type": "string" }, "name": {   "type": "string",   "fields": {     "raw": {       "type": "string",       "index": "not_analyzed"     }   } }, "project_manager": {   "index": "not_analyzed",   "type": "string" }, "start_date": {   "format": "yyyy-MM-dd",   "type": "date" }          }        }      }    }  }}

从根本上讲

raw
,这是一个子字段,在其中输入了相同的值
project.name
project.name.raw
但没有触及(进行标记或分析)。然后,您需要使用的查询是:

{  "fields": [    "client.name",    "project.name"  ],  "query": {    "bool": {      "must": {        "match": {          "client.name": { "operator": "and", "query": "ABC systems"          }        }      }    }  },  "aggs": {    "num_projects": {      "cardinality": {        "field": "project.name.raw"      }    }  },  "size": 5}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4909007.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存