# Search results: highlight property missing

**URL:** <https://discuss.elastic.co/t/search-results-highlight-property-missing/10389>\
**Category:** Elasticsearch\
**Created:** [January 17, 2013, 12:56pm UTC](https://discuss.elastic.co/t/search-results-highlight-property-missing/10389 "2013-01-17T12:56:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Herman\_Fries](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/herman_fries/32/2529_2.png) [@Herman\_Fries](https://discuss.elastic.co/u/Herman_Fries)\
**Post date:** [January 17, 2013, 12:56pm UTC](https://discuss.elastic.co/t/search-results-highlight-property-missing/10389/1 "2013-01-17T12:56:56Z")

</div>

Hello,

i have trouble getting highlight to work. Here is my script used for  
testing:

init() {  
curl -XDELETE [http://localhost:9200/twitter](http://localhost:9200/twitter)  
echo  
curl -XPUT [http://localhost:9200/twitter](http://localhost:9200/twitter)  
echo

```
curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
    "tweet" : {
        "properties" : {
            "user" : { "type" : "string" },
            "message" : {
                "type" : "string",
                "index": "analyzed",
                "store": "yes",
                "term_vector" : "with_positions_offsets"
             }
        }
    }
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "kimchy",
    "message": "You know, for Search"
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "bar",
    "message": "You know, foo for Search"
}'
echo

sleep 2
echo '-------------------'

```

}

["$1" = "init"] && init

curl -X GET '[http://localhost:9200/twitter/\_search/?pretty=true](http://localhost:9200/twitter/_search/?pretty=true)' -d '{  
"query":{  
"query\_string":{  
"query":"foo"  
}  
}  
},  
"highlight":{  
"pre\_tags": "**",  
"post\_tags": "**",  
"fields" : {  
"message" : {"number\_of\_fragments": 20}  
}  
}  
}'

## and here the output: {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id":"aSAxiJwvTZCiAS0FV4Nnow" ,"\_version":1} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id":"pTYsw0FWQYOUMtzRAD7gSg" ,"\_version":1}

{  
"took" : 6,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 0.09492774,  
"hits" : [ {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "pTYsw0FWQYOUMtzRAD7gSg",  
"\_score" : 0.09492774, "\_source" : {  
"user": "bar",  
"message": "You know, foo for Search"  
}  
} ]  
}  
}%

as you can see there are no errors but the highlight property isn't there,  
too.  
Can someone see my mistake?

Regards,  
Herman Fries

--

---

<div class="post-metadata">

**Author:** ![Herman\_Fries](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/herman_fries/32/2529_2.png) [@Herman\_Fries](https://discuss.elastic.co/u/Herman_Fries)\
**Post date:** [January 17, 2013, 1:05pm UTC](https://discuss.elastic.co/t/search-results-highlight-property-missing/10389/2 "2013-01-17T13:05:21Z")

</div>

OK mistake found. Sorry for the noise.

I had to many closing brackets so highlight part of the query got ignored.  
I didn't know you can add more closing brackets without causing parser  
errors. 🙂

Am Donnerstag, 17. Januar 2013 13:56:56 UTC+1 schrieb Herman Fries:

> Hello,
> 
> i have trouble getting highlight to work. Here is my script used for  
> testing:
> 
> init() {  
> curl -XDELETE [http://localhost:9200/twitter](http://localhost:9200/twitter)  
> echo  
> curl -XPUT [http://localhost:9200/twitter](http://localhost:9200/twitter)  
> echo
> 
> ```
> curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
> "tweet" : {
> "properties" : {
> "user" : { "type" : "string" },
> "message" : {
> "type" : "string",
> "index": "analyzed",
> "store": "yes",
> "term_vector" : "with_positions_offsets"
> }
> }
> }
> }'
> echo
> curl -XPOST http://localhost:9200/twitter/tweet -d '{
> "user": "kimchy",
> "message": "You know, for Search"
> }'
> echo
> curl -XPOST http://localhost:9200/twitter/tweet -d '{
> "user": "bar",
> "message": "You know, foo for Search"
> }'
> echo
> 
> sleep 2
> echo '-------------------'
> 
> ```
> 
> }
> 
> ["$1" = "init"] && init
> 
> curl -X GET '[http://localhost:9200/twitter/\_search/?pretty=true](http://localhost:9200/twitter/_search/?pretty=true)' -d '{  
> "query":{  
> "query\_string":{  
> "query":"foo"  
> }  
> }  
> },  
> "highlight":{  
> "pre\_tags": "**",  
> "post\_tags": "**",  
> "fields" : {  
> "message" : {"number\_of\_fragments": 20}  
> }  
> }  
> }'
> 
> ## and here the output: {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id": "aSAxiJwvTZCiAS0FV4Nnow","\_version":1} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id": "pTYsw0FWQYOUMtzRAD7gSg","\_version":1}
> 
> {  
> "took" : 6,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 0.09492774,  
> "hits" : [ {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "pTYsw0FWQYOUMtzRAD7gSg",  
> "\_score" : 0.09492774, "\_source" : {  
> "user": "bar",  
> "message": "You know, foo for Search"  
> }  
> } ]  
> }  
> }%
> 
> as you can see there are no errors but the highlight property isn't there,  
> too.  
> Can someone see my mistake?
> 
> Regards,  
> Herman Fries

--

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [January 17, 2013, 1:07pm UTC](https://discuss.elastic.co/t/search-results-highlight-property-missing/10389/3 "2013-01-17T13:07:38Z")

</div>

Move the Highlight section above the query:

# curl -X GET '[http://localhost:9200/twitter/\_search/?pretty=true](http://localhost:9200/twitter/_search/?pretty=true)' -d '{

> ```
> "highlight":{
> "pre_tags": "<b>",
> "post_tags": "</b>",
> "fields" : {
> "message" : {"number_of_fragments": 20}
> }
> },
> "query":{
> "query_string":{
> "query":"foo"
> }
> }
> },
> 
> ```
> 
> }'  
> {  
> "took" : 11,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 0.13424811,  
> "hits" : [ {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "mSr21FwJRT-71SDCnRaEKw",  
> "\_score" : 0.13424811, "\_source" : {  
> "user": "bar",  
> "message": "You know, foo for Search"  
> },  
> "highlight" : {  
> "message" : ["know, _foo_ for Search"]  
> }  
> } ]  
> }  
> }

On Thursday, January 17, 2013 7:56:56 AM UTC-5, Herman Fries wrote:

> Hello,
> 
> i have trouble getting highlight to work. Here is my script used for  
> testing:
> 
> init() {  
> curl -XDELETE [http://localhost:9200/twitter](http://localhost:9200/twitter)  
> echo  
> curl -XPUT [http://localhost:9200/twitter](http://localhost:9200/twitter)  
> echo
> 
> ```
> curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
> "tweet" : {
> "properties" : {
> "user" : { "type" : "string" },
> "message" : {
> "type" : "string",
> "index": "analyzed",
> "store": "yes",
> "term_vector" : "with_positions_offsets"
> }
> }
> }
> }'
> echo
> curl -XPOST http://localhost:9200/twitter/tweet -d '{
> "user": "kimchy",
> "message": "You know, for Search"
> }'
> echo
> curl -XPOST http://localhost:9200/twitter/tweet -d '{
> "user": "bar",
> "message": "You know, foo for Search"
> }'
> echo
> 
> sleep 2
> echo '-------------------'
> 
> ```
> 
> }
> 
> ["$1" = "init"] && init
> 
> curl -X GET '[http://localhost:9200/twitter/\_search/?pretty=true](http://localhost:9200/twitter/_search/?pretty=true)' -d '{  
> "query":{  
> "query\_string":{  
> "query":"foo"  
> }  
> }  
> },  
> "highlight":{  
> "pre\_tags": "**",  
> "post\_tags": "**",  
> "fields" : {  
> "message" : {"number\_of\_fragments": 20}  
> }  
> }  
> }'
> 
> ## and here the output: {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id": "aSAxiJwvTZCiAS0FV4Nnow","\_version":1} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id": "pTYsw0FWQYOUMtzRAD7gSg","\_version":1}
> 
> {  
> "took" : 6,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 0.09492774,  
> "hits" : [ {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "pTYsw0FWQYOUMtzRAD7gSg",  
> "\_score" : 0.09492774, "\_source" : {  
> "user": "bar",  
> "message": "You know, foo for Search"  
> }  
> } ]  
> }  
> }%
> 
> as you can see there are no errors but the highlight property isn't there,  
> too.  
> Can someone see my mistake?
> 
> Regards,  
> Herman Fries

--

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [January 17, 2013, 1:08pm UTC](https://discuss.elastic.co/t/search-results-highlight-property-missing/10389/4 "2013-01-17T13:08:43Z")

</div>

Ah, or closing brackets. Whoops! Ignore my response =)

-Zach

On Thursday, January 17, 2013 7:56:56 AM UTC-5, Herman Fries wrote:

> Hello,
> 
> i have trouble getting highlight to work. Here is my script used for  
> testing:
> 
> init() {  
> curl -XDELETE [http://localhost:9200/twitter](http://localhost:9200/twitter)  
> echo  
> curl -XPUT [http://localhost:9200/twitter](http://localhost:9200/twitter)  
> echo
> 
> ```
> curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
> "tweet" : {
> "properties" : {
> "user" : { "type" : "string" },
> "message" : {
> "type" : "string",
> "index": "analyzed",
> "store": "yes",
> "term_vector" : "with_positions_offsets"
> }
> }
> }
> }'
> echo
> curl -XPOST http://localhost:9200/twitter/tweet -d '{
> "user": "kimchy",
> "message": "You know, for Search"
> }'
> echo
> curl -XPOST http://localhost:9200/twitter/tweet -d '{
> "user": "bar",
> "message": "You know, foo for Search"
> }'
> echo
> 
> sleep 2
> echo '-------------------'
> 
> ```
> 
> }
> 
> ["$1" = "init"] && init
> 
> curl -X GET '[http://localhost:9200/twitter/\_search/?pretty=true](http://localhost:9200/twitter/_search/?pretty=true)' -d '{  
> "query":{  
> "query\_string":{  
> "query":"foo"  
> }  
> }  
> },  
> "highlight":{  
> "pre\_tags": "**",  
> "post\_tags": "**",  
> "fields" : {  
> "message" : {"number\_of\_fragments": 20}  
> }  
> }  
> }'
> 
> ## and here the output: {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"acknowledged":true} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id": "aSAxiJwvTZCiAS0FV4Nnow","\_version":1} {"ok":true,"\_index":"twitter","\_type":"tweet","\_id": "pTYsw0FWQYOUMtzRAD7gSg","\_version":1}
> 
> {  
> "took" : 6,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 0.09492774,  
> "hits" : [ {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "pTYsw0FWQYOUMtzRAD7gSg",  
> "\_score" : 0.09492774, "\_source" : {  
> "user": "bar",  
> "message": "You know, foo for Search"  
> }  
> } ]  
> }  
> }%
> 
> as you can see there are no errors but the highlight property isn't there,  
> too.  
> Can someone see my mistake?
> 
> Regards,  
> Herman Fries

--

---

<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, 2:55am UTC](https://discuss.elastic.co/t/search-results-highlight-property-missing/10389/5 "2017-07-06T02:55:56Z")

</div>

Closed on July 6, 2017, 2:55am UTC


