es数组包含查询

es中字段A 值是一个list [a, b, c, d],当入参为[a, b, c, d, e] 或 [a, b, c, d] 就可以匹配到;如果是 [a, b, c] 就匹配不到。

复制代码
{
	"query": {
		"bool": {
			"filter": [{
				"script": {
					"script": {
						"source": """ 
                            List<Integer> fieldAValues = Arrays.asList(doc['field_a'].values()); 
                            List<Integer> searchValues = Arrays.asList(params.searchValues); 
                            return searchValues.stream().allMatch(fieldAValues::contains);
    					""",
						"lang": "painless",
						"params": {
							"searchValues": [a, b, c, d]
						}
					}
				}
			}]
		}
	}
}

该方法比较耗cpu。

其他类似方法:

Fingerprint processor | Elasticsearch Guide [8.6] | Elastic

相关推荐
何妨呀~17 小时前
Elasticsearch集群部署
elasticsearch
Z文的博客20 小时前
嵌入式LINUX QT 开发 .gitignore 文件编写指南
linux·git·qt·elasticsearch·嵌入式
青龙小码农20 小时前
milvus+elasticsearch+ollama实现企业级RAG搭建
elasticsearch·milvus·ollama·rga
恼书:-(空寄1 天前
ES性能调优实战指南
elasticsearch
Elastic 中国社区官方博客1 天前
Elasticsearch:智能搜索 - AI builder 及 skills
大数据·人工智能·elasticsearch·搜索引擎·ai·信息可视化·全文检索
Elasticsearch2 天前
向量预处理:让 Elasticsearch VectorDB 更好地为每个向量实现二进制量化工作
elasticsearch
Young soul22 天前
docker-compose安装elasticsearch、kibana、logstash以及ik分词器
elasticsearch·docker·jenkins
Elastic 中国社区官方博客2 天前
Elasticsearch:智能搜索 - AI builder,workflow 及 skills
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
Young soul22 天前
Elasticsearch(v8.5) 常用操作大全
大数据·elasticsearch·jenkins
海兰2 天前
Elastic 基于 Agentic 架构与 MCP 的 Kubernetes 智能可观测性深度解析
elasticsearch·容器·架构·kubernetes