在_all字段上突出显示匹配的结果 [英] Highlighting matched results on _all fields

查看:121
本文介绍了在_all字段上突出显示匹配的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要匹配的结果被突出显示。这对我来说如果我提到字段名称,它返回突出显示的文本,但是如果我将该字段作为_all,它不返回任何值。
这对我有用:

  curl -XGEThttp:// localhost:9200 / my_index / my_type / _search ?q = stackoverflow& size = 999-d{
highlight:{
fields:{
my_field:{}
}

}'

这将返回预期值,如下所示:
[highlight ] => stdClass Object([my_field] => Array([0] => stackoverflow 是techies最好的网站))



但是当我这样做:

  curl -XGEThttp:// localhost:9200 / my_index / my_type / _search?q = stackoverflow& ; size = 999-d{
highlight:{
fields:{
_all:{}
}
}
$'

我得到空值/无结果

  [highlight] => stdClass Object([_all] => Array())

任何字段,所以我不必提到字段名称?

解决方案

你需要映射_all字段存储。下面的映射应该做的诀窍。请注意,这将增加索引大小。

  {
my_type:{
_all:{
enabled:true,
store:yes
}
}}


I want the matched results to be highlighted. This works for me if I mention the field name and it returns the highlighted text, however if I give the field as "_all", it is not returning any value. This works for me:

        curl -XGET "http://localhost:9200/my_index/my_type/_search?q=stackoverflow&size=999" -d '{
        "highlight":{
                    "fields":{
                             "my_field":{}
                    }
        }
}'

This returns the expected value as follows: [highlight] => stdClass Object ( [my_field] => Array ( [0] => stackoverflow is the best website for techies ) )

But when I give this:

        curl -XGET "http://localhost:9200/my_index/my_type/_search?q=stackoverflow&size=999" -d '{
        "highlight":{
                    "fields":{
                             "_all":{}
                    }
        }
}'

I get null value/no result.

[highlight] => stdClass Object ( [_all] => Array () )

How do I get it to work on any field so that I don't have to mention the field name?

解决方案

You need to map the _all field as stored. The mapping below should do the trick. Note though that this will add to the index size.

{
  "my_type": {
      "_all": {
        "enabled": true,
        "store": "yes"
      }
  }}

这篇关于在_all字段上突出显示匹配的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆