# Ignore malformed part of strings instead of keyword

**URL:** https://discuss.elastic.co/t/ignore-malformed-part-of-strings-instead-of-keyword/54611
**Category:** Elasticsearch
**Created:** [July 4, 2016, 6:31am UTC](https://discuss.elastic.co/t/ignore-malformed-part-of-strings-instead-of-keyword/54611 "2016-07-04T06:31:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![shantanuo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shantanuo/32/10141_2.png) [@shantanuo](https://discuss.elastic.co/u/shantanuo)
#### Post date: [July 4, 2016, 6:31am UTC](https://discuss.elastic.co/t/ignore-malformed-part-of-strings-instead-of-keyword/54611/1 "2016-07-04T06:31:26Z")

</div>

When I use fields with different type, it works if the entire keyword is an interger. If there is any text, instead of ignoring it, elastic will ingore the entire field. For e.g.

```
DELETE /test_index

PUT /test_index
{
    "mappings": {
        "doc":{
            "properties": {
                "text_field": {
                    "type": "string",
                    "index": "not_analyzed",
                    "fields": {
                        "raw1": {
                            "type": "integer", 
                            "ignore_malformed": true
                        }
                    }
                }
            }
        }
    }
}

POST /test_index/doc/_bulk
{"index":{"_id":1}}
{"text_field": "Apple TV"}
{"index":{"_id":2}}
{"text_field": "Apple iPhone"}
{"index":{"_id":3}}
{"text_field": "300"}

POST /test_index/_search
{
   "query": {
      "range": {
         "text_field.raw1": {
            "from": 200,
            "to": 400
         }
      }
   }
}

```

The above example is working as per my expectation. But if I change the third ID to include text like this...

{"index":{"\_id":3}}  
{"text\_field": "300 abcd"}

Then the range query will fail to return this record. Is there any way to load "300" in raw1 field and ignore the text part?

---

<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: [July 4, 2016, 6:44am UTC](https://discuss.elastic.co/t/ignore-malformed-part-of-strings-instead-of-keyword/54611/2 "2016-07-04T06:44:43Z")

</div>

I don't believe so.  
May be you could write your own analyzer in Java for this and plug it in?

---

<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 5, 2017, 10:38pm UTC](https://discuss.elastic.co/t/ignore-malformed-part-of-strings-instead-of-keyword/54611/3 "2017-07-05T22:38:37Z")

</div>


