elasticsearch - 如何在 ElasticSearch 上使用过滤器(或查询)条件获取所有字段名称?
问题描述
PUT /test-product
{
"mappings": {
"properties": {
"profile": {
"type": "nested"
},
"product": {
"type": "nested"
}
}
}
}
我有一个名为“测试产品”的索引
POST /test-product/_bulk
{ "index" : { "_id" : "1" } }
{ "user":"1", "profile":{"name":"AA", "age": "11", "height": "30"}, "product": {"price": "333", "name": "test", "weight": "10"} }
{ "index" : { "_id" : "2" } }
{ "user":"2", "profile":{"name":"BB", "age": "20"}, "product": {"name": "test"}}
并且该索引有一些文档
我想得到如下结果....
案例1.当我搜索用户时:1
profile.name、profile.age、profile.height、product.price、product.name、product.weight
案例2.当我搜索用户时:2
profile.name、profile.age、product.name
有办法吗?
解决方案
我不确定您对数据的要求是什么,但所有字段都可以使用GET <index>/_mapping
. 也许GET index_name/_mapping?pretty
会更适合你。
推荐阅读
- c - 如何在cmake中根据条件包含目录
- flutter - listview 不能在小部件作为其子项的情况下工作?
- python - Python:如何使用嵌套的 for 循环将值正确存储在数组中(三个循环,三维数组)?
- java - testNg 类启动顺序
- angular - exceljs在Angular中的worksheet.columns = []数组的行中给出错误
- c# - 作为主窗口的一部分打开子窗口
- jenkins - HTTPS 不适用于 GKE Ingress 中启用的 TLS
- python - 如果在使用正则表达式之前已经存在,则查找句子的最后一个单词
- python - Plot - x 必须是标签或位置
- python - TypeError:预期的 str、字节或 os.PathLike 对象,而不是 InMemoryUploadedFile