您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在Elasticsearch 2.3.3中添加突出显示不适用于has_child查询

在Elasticsearch 2.3.3中添加突出显示不适用于has_child查询

这与git问题中指定的错误有关。线程中提到的解决方法是在highlight_query

范例:

PUT test
{
   "mappings": {
      "my_parent": {
         "_all": {
            "store": true
         }
      },
      "my_child": {
         "_parent": {
            "type": "my_parent"
         }
      }
   }
}

PUT test/my_parent/1 
{
  "text": "This is a parent document"
}

PUT test/my_child/2?parent=1 
{
  "text": "This is a child document"
}

POST test/my_parent/_search
{
   "query": {
      "bool": {
         "must": [
            {
               "has_child": {
                  "type": "my_child",
                  "query": {
                     "match": {
                        "text": "child document"
                     }
                  }
               }
            },
            {
               "match": {
                  "_all": "parent"
               }
            }
         ]
      }
   },
   "highlight": {
      "fields": {
         "_all": {}
      },
      "highlight_query": {
         "match": {
            "_all": "parent"
         }
      }
   }
}

结果:

  {
            "_index": "test",
            "_type": "my_parent",
            "_id": "1",
            "_score": 1.016466,
            "_source": {
               "text": "This is a parent document"
            },
            "highlight": {
               "_all": [
                  "This is a <em>parent</em> document "
               ]
            }
         }

在Java Client中,您应该可以通过此api实现它

其他 2022/1/1 18:16:52 有466人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶