# A budge in ES hightlight about keyword "before"

**URL:** <https://discuss.elastic.co/t/a-budge-in-es-hightlight-about-keyword-before/88009>\
**Category:** Elasticsearch\
**Created:** [June 2, 2017, 2:14am UTC](https://discuss.elastic.co/t/a-budge-in-es-hightlight-about-keyword-before/88009 "2017-06-02T02:14:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liuguangmin](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@liuguangmin](https://discuss.elastic.co/u/liuguangmin)\
**Post date:** [June 2, 2017, 2:14am UTC](https://discuss.elastic.co/t/a-budge-in-es-hightlight-about-keyword-before/88009/1 "2017-06-02T02:14:42Z")

</div>

ES：5.3.0  
OS：Linux  
java：jdk1.8  
#my mapping is below:  
============my mappings =============  
{  
"zhongxing2": {  
"mappings": {  
"zhongxing2": {  
"\_all": {  
"enabled": false  
},  
"properties": {  
"itemid": {  
"type": "keyword",  
"store": true  
},  
"OriginalLog": {  
"type": "text",  
"store": true,  
"term\_vector": "with\_positions\_offsets",  
"norms": false,  
"index\_options": "offsets",  
"copy\_to": [  
"OriginalLog\_regex"  
],  
"analyzer": "log\_analyzer"  
},  
"OriginalLog\_regex": {  
"type": "text",  
"term\_vector": "with\_positions\_offsets",  
"norms": false,  
"index\_options": "offsets",  
"analyzer": "log\_regex\_analyzer"  
}  
}  
}  
},  
"settings": {  
"index": {  
"analysis": {  
"analyzer": {  
"log\_analyzer": {  
"filter": [  
"synonym",  
"lowercase",  
"log\_snow"  
],  
"type": "custom",  
"tokenizer": "log\_tokenizer"  
},  
"log\_regex\_analyzer": {  
"filter": [  
"lowercase"  
],  
"type": "custom",  
"tokenizer": "log\_tokenizer"  
}  
},  
"tokenizer": {  
"log\_tokenizer": {  
"pattern": "(?=\W)[^-]",  
"type": "pattern"  
}  
}  
}  
}  
}  
}  
}  
========= === ================  
I insert 6 item as below  
===========doc========  
(1) curl -i -X POST -H "'Content-type':'application/json', 'charset':'utf-8', 'Accept': 'text/plain'" -d 'json\_data={"appname":"zhongxing2","log\_list":[{"itemid":"1885469469509","is\_online":"1","detail":"I have a dream","OriginalLog":"017-05-25T14:12:35Z ERROR ops.eps.trans system test in logsearch pythonjava after and search engin"},{"itemid":"1885469469510","is\_online":"1","detail":"I have two dream","OriginalLog":"before before before before"}],"request\_id":"2222"}' [http://123.56.120.196:9449/logpush/zte\_log](http://123.56.120.196:9449/logpush/zte_log)

(2) curl -i -X POST -H "'Content-type':'application/json', 'charset':'utf-8', 'Accept': 'text/plain'" -d 'json\_data={"appname":"zhongxing2","log\_list":[{"itemid":"1885469469507","is\_online":"1","detail":"I have a dream","OriginalLog":"017-05-25T14:12:35Z ERROR ops.eps.trans system test in logsearch gogogo after and search engin"},{"itemid":"1885469469508","is\_online":"1","detail":"I have two dream","OriginalLog":"before before before before"}],"request\_id":"3333"}' [http://123.56.120.196:9449/logpush/zte\_log](http://123.56.120.196:9449/logpush/zte_log)

(3) curl -i -X POST -H "'Content-type':'application/json', 'charset':'utf-8', 'Accept': 'text/plain'" -d 'json\_data={"appname":"zhongxing2","log\_list":[{"itemid":"1885469469505","is\_online":"1","detail":"I have a dream","OriginalLog":"017-05-25T14:12:35Z ERROR ops.eps.trans system test in logsearch before after and search engin"},{"itemid":"1885469469506","is\_online":"1","detail":"I have two dream","OriginalLog":"before before before before"}],"request\_id":"3333"}' [http://123.56.120.196:9449/logpush/zte\_log](http://123.56.120.196:9449/logpush/zte_log)  
============= ==== ====

when I use the query as follow

========my query:===========  
GET zhongxing2/\_search  
{  
"highlight": {  
"pre\_tags": "",  
"fields": {  
"OriginalLog": {  
"number\_of\_fragments": 0,  
"no\_match\_size": 150,  
"require\_field\_match": false,  
"fragment\_size": 150  
}  
},  
"post\_tags": ""  
},  
"query": {  
"bool": {  
"filter": [],  
"should": [],  
"must\_not": [],  
"must": [  
{  
"query\_string": {  
"query": "OriginalLog\_regex:pythonjava",  
"default\_operator": "AND"  
}  
}  
]  
}  
},  
"from": 0,  
"size": 20  
}  
the result is  
"highlight": {  
"OriginalLog": [  
"017-05-25T14:12:35Z ERROR ops.eps.trans system test in logsearch \<color=red\>pythonjava after and search engin"  
]  
}  
the pythonjava is highlight is #pythonjava# ,because if i use the highlight symbol,the color is disappear ,so i use the "#" instand  
========= ======  
#but when I use the follow query  
GET zhongxing2/\_search  
{  
"highlight": {  
"pre\_tags": "",  
"fields": {  
"OriginalLog": {  
"number\_of\_fragments": 0,  
"no\_match\_size": 150,  
"require\_field\_match": false,  
"fragment\_size": 150  
}  
},  
"post\_tags": ""  
},  
"query": {  
"bool": {  
"filter": [],  
"should": [],  
"must\_not": [],  
"must": [  
{  
"query\_string": {  
"query": "OriginalLog\_regex:before",  
"default\_operator": "AND"  
}  
}  
]  
}  
},  
"from": 0,  
"size": 20  
}

the result is  
"highlight": {  
"OriginalLog": [  
"before before before before"  
]  
}  
"highlight": {  
"OriginalLog": [  
"017-05-25T14:12:35Z ERROR ops.eps.trans system test in logsearch before after and search engin"  
]  
}

# what's more I have try many times ,but the "before" is not hightlight ? so I wonder the before is a keyword in es or maybe this a big budge in ES ? I very puzzled

I make a new test as follow  
=============== new doc ====  
curl -i -X POST -H "'Content-type':'application/json', 'charset':'utf-8', 'Accept': 'text/plain'" -d 'json\_data={"appname":"zhongxing2","log\_list":[{"itemid":"1885469469605","is\_online":"1","OriginalLog":"before after more and more"},{"itemid":"1885469469606","is\_online":"1","OriginalLog":"sure before sure pleasure metre centre centimetre"}],"request\_id":"3333"}' [http://123.56.120.196:9449/logpush/zte\_log](http://123.56.120.196:9449/logpush/zte_log)

I find only the keyword "more" and "sure" is hightlight ,the other word for example before ,pleasure ,metre ,centre ,centimetre annot highlight  
this is why?

---

<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:** [June 30, 2017, 2:14am UTC](https://discuss.elastic.co/t/a-budge-in-es-hightlight-about-keyword-before/88009/2 "2017-06-30T02:14:43Z")

</div>

Closed on June 30, 2017, 2:14am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
