# Elasticsearch | Highlight of integer fields when wildcard is used

**URL:** <https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762>\
**Category:** Elasticsearch\
**Created:** [February 25, 2019, 7:41am UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762 "2019-02-25T07:41:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [February 25, 2019, 7:41am UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762/1 "2019-02-25T07:41:04Z")

</div>

I have indexed a document containing integers .

Mapping of these fields are :

```
"INTEGER_FIELD": {
  "type": "integer",
  "fields": {
	"keyword": {
	  "type": "keyword",
	  "ignore_above": 256
	}
  }
}

```

Search query is :

```
{
  "from": 0,
  "size": 10,
  "query": {
	"bool": {
	  "should": [
		{
		  "query_string": {
			"query": "\"0\"",
			"fields": [
			  "INTEGER_FIELD"
			],
			"boost": "2000"
		  }
		},
		{
		  "query_string": {
			"query": "*0*",
			"analyzer": "whitespace",
			"fields": [
			  "INTEGER_FIELD"
			]
		  }
		}
	  ],
	  "minimum_should_match": 1
	}
  },
  "highlight": {
	"type": "unified",
	"fields": {
	  "INTEGER_FIELD": {}
	}
  }
}

```

My doubts are:

**1.** When the above query is used, "INTEGER\_FIELD" is highlighted,  
The highlight result fetched is :

```
  "highlight": {
    "INTEGER_FIELD": [
      "<em>0</em>"
    ]
  }

```

**2.** When only the first query\_string is used i.e.,

```
{
  "from": 0,
  "size": 10,
  "query": {
	"bool": {
	  "should": [
		{
		  "query_string": {
			"query": "\"0\"",
			"fields": [
			  "INTEGER_FIELD"
			],
			"boost": "2000"
		  }
		}
	  ],
	  "minimum_should_match": 1
	}
  },
  "highlight": {
	"type": "unified",
	"fields": {
	  "INTEGER_FIELD": {}
	}
  }
}

```

The document is retrieved/fetched but there is no highlighting present.

**3.** When only the second query\_string is used i.e.,

```
{
  "from": 0,
  "size": 10,
  "query": {
	"bool": {
	  "should": [
		{
		  "query_string": {
			"query": "*0*",
			"analyzer": "whitespace",
			"fields": [
			  "INTEGER_FIELD"
			]
		  }
		}
	  ],
	  "minimum_should_match": 1
	}
  },
  "highlight": {
	"type": "unified",
	"fields": {
	  "INTEGER_FIELD": {}
	}
  }
}

```

The document is not fetched and hence nothing is highlighted

I am failing to understand the behaviour of highlighting here.  
From what i understand, Elasticsearch provides highlight only for text fields. Why is Integer fields getting highlighted and Why is it getting highlighted only when I am using wildcard character?  
Please let me know if I am going wrong somewhere

---

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [February 26, 2019, 6:05am UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762/2 "2019-02-26T06:05:11Z")

</div>

@elastic Please provide some information

---

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [March 25, 2019, 12:17pm UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762/3 "2019-03-25T12:17:04Z")

</div>

@elastic I have waited a bit longer than expected  
Please provide me a reply

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 25, 2019, 12:33pm UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762/4 "2019-03-25T12:33:22Z")

</div>

May be provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) will give you more chance to get an answer? Please, try to keep the example as simple as possible.

---

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [March 25, 2019, 12:58pm UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762/5 "2019-03-25T12:58:09Z")

</div>

I think I have provided complete script, starting from Mapping file to query and highlight result.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 25, 2019, 1:57pm UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762/6 "2019-03-25T13:57:01Z")

</div>

I can't just copy and paste your "script" and run it so I don't think you did.

---

<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:** [April 22, 2019, 2:03pm UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-integer-fields-when-wildcard-is-used/169762/7 "2019-04-22T14:03:07Z")

</div>

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