首页 > 解决方案 > 无法从 ES 获得任何结果。没有错误

问题描述

我有这样的映射 -

    "type": "nested",
    "include_in_parent": true,
    "properties": {
        "value": {
            "type": "nested",
            "properties": {
                "Technical": {
                    "properties": {
                        "techlocation": {
                            "type": "string"
                        },
                        "techname22": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
},

当我运行 match_all 查询时,我得到了这个 -

"metadata": [
{
  "value": {
      "Technical": [
         {
             "techname22": "test"
         },
         {
             "techlocation": "usa"
         }
      ]
   }
}
],

但我不能用(也试过 Technical.techlocation:(loc)) 和其他方式查询它。dddddddddd -

          "query": {
            "filtered": {
              "query": {
              "query_string" : {
                "query": "metadata.value.Technical.techlocation:(loc)",
                "default_operator": "AND",
                "analyze_wildcard": true
            }
              }
            }
          }
        }

真的没有什么好说的了。谢谢你的帮助!

标签: elasticsearchsearch

解决方案


您似乎使用的是较旧的 ES 版本,因此此查询的实际语法可能会有所不同,但您在搜索字段nested时需要使用该查询:nested

{
  "query": {
    "nested": {
      "path": "metadata.value",
      "query": {
        "query_string": {
          "query": "metadata.value.Technical.techlocation:(usa)",
          "default_operator": "AND",
          "analyze_wildcard": true
        }
      }
    }
  }
}

推荐阅读