elasticsearch - 执行查询和字段折叠
问题描述
当我进行多条件查询并将字段折叠应用于上述索引中的一个字段时,我收到以下错误
no mapping found for `search_type.keyword` in order to collapse on
使用的查询:
GET /_search
{
"query": {
"bool" : {
"must" : [
{
"match" :
{
"id" : "123456"
}
},
{
"terms": {
"_index": ["history"]
}
}
]
}
},
"collapse" : {
"field" : "search_type.keyword",
"inner_hits": {
"name": "terms",
"size": 10
}
}
}
错误跟踪:
{
"shard" : 0,
"index" : "test",
"node" : "UOA44HkATh61krg6ht3paA",
"reason" : {
"type" : "illegal_argument_exception",
"reason" : "no mapping found for `search_type.keyword` in order to collapse on"
}
}
目前,我只对索引应用查询 -历史,但结果对我没有提到的索引抛出异常。请帮助如何缩小字段折叠到特定索引的范围。
解决方案
这似乎是一个错误,但如果您仔细观察结果,在观察到所有此类错误后,您应该能够在最后查看您正在寻找的响应。
但是,为什么不将索引名称添加到前面并修改您的查询,如下所示:
POST history/_search <---- Add index name here
{
"query": {
"bool": {
"must": [
{
"match": {
"id": "123456"
}
}
]
}
},
"collapse" : {
"field" : "search_type.keyword",
"inner_hits": {
"name": "terms",
"size": 10
}
}
}
推荐阅读
- python - yfinance - 隔离股票价格
- javascript - GO_TO_PAGE GOOGLE 表格到表单,如何设置转到页面变量
- javascript - Vue 通知数组
- python - 使用 re.search 搜索文件并将输出保存到新文件
- clickhouse - Clickhouse:runningAccumulate() 不像我预期的那样工作
- d3.js - threejs 在对象上或对象旁边呈现文本
- oracle - 无法在 oracle 的表中获得预期结果值(负记录行)
- memory - “写保护” PAT 内存类型的用例是什么?
- c# - 无法检索用户属性(联系人等集合)
- javascript - 如何查看下载文件的百分比