在_all字段上突出显示匹配的结果 [英] Highlighting matched results on _all fields
问题描述
这对我有用:
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屋!