# Highlighting matched results on \_all fields

**URL:** <https://discuss.elastic.co/t/highlighting-matched-results-on--all-fields/5983>\
**Category:** Elasticsearch\
**Created:** [November 27, 2011, 3:21pm UTC](https://discuss.elastic.co/t/highlighting-matched-results-on--all-fields/5983 "2011-11-27T15:21:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niranjan](https://avatars.discourse-cdn.com/v4/letter/n/e99b99/32.png) [@Niranjan](https://discuss.elastic.co/u/Niranjan)\
**Post date:** [November 27, 2011, 3:21pm UTC](https://discuss.elastic.co/t/highlighting-matched-results-on--all-fields/5983/1 "2011-11-27T15:21:55Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 28, 2011, 9:06am UTC](https://discuss.elastic.co/t/highlighting-matched-results-on--all-fields/5983/2 "2011-11-28T09:06:37Z")

</div>

The \_all field is a special field, which includes all the other fields. If  
you want to be able to highlight it, you need to store it specifically  
(which will add to the index size). Specific fields can be extracted from  
the "\_source" document stored.

On Sun, Nov 27, 2011 at 5:21 PM, Niranjan [niranjan.u@gmail.com](mailto:niranjan.u@gmail.com) wrote:

> 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](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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:47am UTC](https://discuss.elastic.co/t/highlighting-matched-results-on--all-fields/5983/3 "2017-07-06T03:47:22Z")

</div>


