# Search for specific symbols like %

**URL:** <https://discuss.elastic.co/t/search-for-specific-symbols-like/97350>\
**Category:** Elasticsearch\
**Created:** [August 17, 2017, 6:55am UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350 "2017-08-17T06:55:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur\_Kushman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_kushman/32/21189_2.png) [@Arthur\_Kushman](https://discuss.elastic.co/u/Arthur_Kushman)\
**Post date:** [August 17, 2017, 6:55am UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/1 "2017-08-17T06:55:34Z")

</div>

We are using an ES in our project and can not find the answer or an example, how to search for ints with percent character, ex.:  
we place in query match "50%" ES found the 50 and 50%, as we thought it would be a special character for ES and tried out all the analyzers like whitespace, keyword, escaping character % - nothing helped.

Also, the 2nd problem is that the highlighter doesn't enclose the whole expression into tags, ex.: `<span class="highlight">50</span>%`, but we expect - `<span class="highlight">50%</span>`

Hope somebody have the exact same experience and help, thx.

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [August 17, 2017, 8:21am UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/2 "2017-08-17T08:21:12Z")

</div>

Not sure why it doesn't work for you, but I suspect it is an analysis issue. The below works for me, applying the whitespace analyzer. A query for just "50" returns no hits, but a query for "50%" does, with the correct highlighting: `"foo <em>50%</em> bar"`

```
PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "my_field": {
          "type": "text", 
          "analyzer": "whitespace"
        }
      }
    }
  }
}

PUT test/doc/1
{
  "my_field": "foo 50% bar"
}

# Returns nothing
GET test/_search
{
  "query": {
    "match": {
      "my_field": "50"
    }
  }
}

# Returns the correct doc with correct highlighting
GET test/_search
{
  "query": {
    "match": {
      "my_field": "50%"
    }
  },
  "highlight": {
    "fields": {
      "my_field": {}
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![Arthur\_Kushman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_kushman/32/21189_2.png) [@Arthur\_Kushman](https://discuss.elastic.co/u/Arthur_Kushman)\
**Post date:** [August 18, 2017, 8:13am UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/3 "2017-08-18T08:13:16Z")

</div>

We have an existing index and try to update like this:  
curl -X PUT '[http://localhost:9200/spir/material/\_mapping?ignore\_conflicts=true](http://localhost:9200/spir/material/_mapping?ignore_conflicts=true)' -d   
'{  
"material": {  
"properties": {  
"text": {  
"type": "text",  
"analyzer": "whitespace"  
},  
"headline": {  
"type": "text", "analyzer": "whitespace"  
},  
"lead": {  
"type": "text", "analyzer": "whitespace"  
}  
}  
}  
}'  
{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"request [/spir/material/\_mapping] contains unrecognized parameter: [ignore\_conflicts]"}],"type":"illegal\_argument\_exception","reason":"request [/spir/material/\_mapping] contains unrecognized parameter: [ignore\_conflicts]"},"status":400}%

Then we've tried to update without `ignore_conflicts=true` getting another error about conflicts:  
curl -X PUT '[http://localhost:9200/spir/material/\_mapping?ignore\_conflicts=true](http://localhost:9200/spir/material/_mapping?ignore_conflicts=true)' -d   
'{  
"material": {  
"properties": {  
"text": {  
"type": "text",  
"analyzer": "whitespace"  
},  
"headline": {  
"type": "text", "analyzer": "whitespace"  
},  
"lead": {  
"type": "text", "analyzer": "whitespace"  
}  
}  
}  
}'  
{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"request [/spir/material/\_mapping] contains unrecognized parameter: [ignore\_conflicts]"}],"type":"illegal\_argument\_exception","reason":"request [/spir/material/\_mapping] contains unrecognized parameter: [ignore\_conflicts]"},"status":400}

But there are no types other then material:  
curl -XGET 'localhost:9200/spir?pretty'  
{  
"spir" : {  
"aliases" : { },  
"mappings" : {  
"material" : {  
"properties" : {  
"author\_string" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"genre\_id" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"headline" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"id" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"keywords" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"lang" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"lead" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"location" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"news\_date" : {  
"type" : "long"  
},  
"priority" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"products" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"rubric\_id" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"service\_info" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"slug" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"text" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},  
"type" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
}  
}  
}  
},  
"settings" : {  
"index" : {  
"creation\_date" : "1503043085847",  
"number\_of\_shards" : "5",  
"number\_of\_replicas" : "1",  
"uuid" : "uVQ-lzwqSNOpH2-AhM8tvg",  
"version" : {  
"created" : "5040299"  
},  
"provided\_name" : "spir"  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [August 18, 2017, 8:17am UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/4 "2017-08-18T08:17:03Z")

</div>

You can't dynamically change the analyzer for an existing field on an existing index. You can only define the analyzer when you create an index (or when you add a new field to an index).

---

<div class="post-metadata">

**Author:** ![Arthur\_Kushman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_kushman/32/21189_2.png) [@Arthur\_Kushman](https://discuss.elastic.co/u/Arthur_Kushman)\
**Post date:** [August 18, 2017, 12:19pm UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/5 "2017-08-18T12:19:47Z")

</div>

Relatively to this article I can - [https://gist.github.com/nicolashery/6317643](https://gist.github.com/nicolashery/6317643)

"To update the mappings of this existing index, you need to do it for each type (here we only have the weapons type):"

$ curl -X PUT '[http://localhost:9200/thegame/weapons/\_mapping?ignore\_conflicts=true](http://localhost:9200/thegame/weapons/_mapping?ignore_conflicts=true)' -d   
'{  
"weapons": {  
"properties": {  
"name": {  
"type": "string",  
"analyzer": "full\_name"  
},  
"description": {  
"type": "string"  
},  
"category": {  
"type": "string"  
}  
}  
}  
}'

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [August 18, 2017, 12:45pm UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/6 "2017-08-18T12:45:13Z")

</div>

That guide is for version 0.9. That is a really old version. Not sure what was possible back then, but nowadays it's definitely not possible to change the mapping of existing fields dynamically.

I'd recommend that you check out the official documentation: [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#updating-field-mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#updating-field-mappings)

---

<div class="post-metadata">

**Author:** ![Arthur\_Kushman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_kushman/32/21189_2.png) [@Arthur\_Kushman](https://discuss.elastic.co/u/Arthur_Kushman)\
**Post date:** [August 19, 2017, 2:02pm UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/7 "2017-08-19T14:02:04Z")

</div>

Back then was better, thx.  
Hate ES documentation it is like waterfall of needless words.

---

<div class="post-metadata">

**Author:** ![Arthur\_Kushman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_kushman/32/21189_2.png) [@Arthur\_Kushman](https://discuss.elastic.co/u/Arthur_Kushman)\
**Post date:** [August 20, 2017, 7:10am UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/8 "2017-08-20T07:10:37Z")

</div>

Found docs in ES5.5 about possible updates to fields:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#updating-field-mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#updating-field-mappings)

It is not about type though.

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [August 20, 2017, 12:40pm UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/9 "2017-08-20T12:40:11Z")

</div>

What you need to do if you want to change the mapping of existing documents is reindex those documents to another index with the correct mapping.

So, first create a new index which you create with the new mapping. Then use the reindex API to get all documents from the old index A into the new index B. As those documents get reindexed, they will get an updated mapping applied to them. More info about the reindex API here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)

---

<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:** [September 17, 2017, 12:40pm UTC](https://discuss.elastic.co/t/search-for-specific-symbols-like/97350/10 "2017-09-17T12:40:21Z")

</div>

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