Ignore malformed part of strings instead of keyword

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?

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

1 Like