elasticsearch - 如果我得到结果,我可以在 ElasticSearch 中忽略“无法在路径下找到嵌套对象”吗?
问题描述
我们有一个包含嵌套字段的映射索引。在我们的 Java 类中,这些字段是对象列表,有时列表可以是空的(所以在 json 结构中,我们得到例如 {... "some_nested_field": [], ...}。当我们运行查询时,我们会这样做按预期得到结果,但也报错:
"failures": [
{
"shard": 0,
"index": ".kibana",
"node": "ZoEuUdkORpuBSNs7gqiv1Q",
"reason": {
"type": "query_shard_exception",
"reason": """
failed to create query: {
"nested" : {
"query" : {
"bool" : {
"must" : [
{
"match" : {
"foobar.name" : {
"query" : "brlo",
"operator" : "OR",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"path" : "foobar",
"ignore_unmapped" : false,
"score_mode" : "avg",
"boost" : 1.0
}
}
""",
"index_uuid": "xrFCunLNSv6AER_KwNMHSA",
"index": ".kibana",
"caused_by": {
"type": "illegal_state_exception",
"reason": "[nested] failed to find nested object under path [foobar]"
}
}
}
我可以假设此错误是由具有空列表的记录引起的,而忽略它吗?或者这是否表示内部错误并且可能缺少我的查询结果?有没有办法避免这个错误?
更新:
这是我们正在执行的查询的示例:
GET /_search
{
"query": {
"nested": {
"path": "mynested",
"query": {
"bool": {
"should" : [
{ "match" : { "mynested.name": "foo" } },
{ "match" : { "mynested.description": "bar" } },
{ "match" : { "mynested.category": "baz" } }
],
"minimum_should_match" : 1
}
}
}
}
}
来自 ES 的响应报告了 10 个成功的分片和 1 个失败:
{
"took": 889,
"timed_out": false,
"_shards": {
"total": 11,
"successful": 10,
"skipped": 0,
"failed": 1,
"failures": [...]
我们确实得到了回击:
"hits": {
"total": 234450,
"max_score": 11.092936,
"hits": [ ...
解决方案
看起来你已经安装了 Kibana。在错误消息中它说它在indexnested
的路径下找不到,这是 Kibana 使用的路径:foobar
.kibana
"index_uuid": "xrFCunLNSv6AER_KwNMHSA",
"index": ".kibana",
"caused_by": {
"type": "illegal_state_exception",
"reason": "[nested] failed to find nested object under path [foobar]"
}
做简单的时候,GET /_search
所有的 Elasticsearch 索引都会被查询,.kibana
这可能不是你想要的。
要忽略此特定索引,您可以使用多个索引搜索功能并执行如下查询:
GET /*,-.kibana/_search
希望有帮助!
推荐阅读
- scala - 如何使此定期指标收集代码更具功能性(不可变状态)?
- excel - VBA Excel - 在 Outlook 邮件正文中粘贴图表(不是图像)
- java - 无法写入具有权限的 SD 卡
- java - Spring Data Rest:摘录为封闭投影
- html - 如何让我的 CSS Grid 布局响应式?
- c# - 在模拟另一个用户时请求 Kerberos 票证时,安全包中没有凭据
- r - ifelse 测试选择一个值而不是两个
- jquery - 在数据库中插入选中的复选框值并在未选中时将其删除
- angular - 茉莉花测试中是否可以获取模板引用变量?
- windows - 在 awk 中转义嵌套的双引号