Elasticsearch如何将脚本字段添加到inner_hits中以执行更多嵌套查询

时间:2018-08-17 12:46:04

标签: elasticsearch

就像在同一嵌套路径上执行更多嵌套查询,定义不同的inner_hits使得ES剥离了inner_hits匹配项。示例:

{
       "nested": {
          "inner_hits": {
            "script_fields": {
               "overlap" : {
                  "script": {
                     "source": "................................",
                        "params": {
                           "from": "2012-01-01",
                           "to": "2015-06-30"
                         }
                      }
                   }                
                 } 
          },
          "path": "companies",
          "score_mode": "sum",
          "query": {},

    },
    {
       "nested": {
          "inner_hits": {
            "script_fields": {
               "overlap" : {
                  "script": {
                     "source": "................................",
                        "params": {
                           "from": "2012-01-01",
                           "to": "2015-06-30"
                         }
                      }
                   }                
                 } 
          },
          "path": "companies",
          "score_mode": "sum",
          "query": {},

    } 

如果像这样运行更多的嵌套查询,我将获得正确的匹配项,但不会返回所有预期的inner_hits。我可以获得所有匹配,只给不同的inner_hits随机命名,例如:

"inner_hits": {
   "name": [random name]
   "script_fields": {
      "overlap" : {
         ......
      }
    }
 }   

然后,我获得了正确的点击结果,但有一些缺点。我必须检查重复的结果,因为匹配已添加到不同的结果集中,并且不再唯一。我必须使用正则表达式解析结果以重建统一列表。

这听起来像是个错误吗?

0 个答案:

没有答案