需求: 有个字符串集合字段,需要查询出 集合大小 大于等于2 的数据
1、字段mapping
"belong_account": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart","fields": {"keyword": {"type": "keyword","ignore_above": 256}}}
2、实际存储展示
3、DSL查询语句
GET xxxx/_search
{"query": {"script": {"script": "doc['belong_account.keyword'].size() >=2"}}
}
或者
GET xxxx/_search
{"query": {"script": {"script": "doc['belong_account.keyword'].length >=2"}}
}