# Number\_format\_exception when querying field with long type using string

**URL:** <https://discuss.elastic.co/t/number-format-exception-when-querying-field-with-long-type-using-string/101972>\
**Category:** Elasticsearch\
**Created:** [September 27, 2017, 11:27am UTC](https://discuss.elastic.co/t/number-format-exception-when-querying-field-with-long-type-using-string/101972 "2017-09-27T11:27:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanfilmu](https://avatars.discourse-cdn.com/v4/letter/f/8491ac/32.png) [@fanfilmu](https://discuss.elastic.co/u/fanfilmu)\
**Post date:** [September 27, 2017, 11:27am UTC](https://discuss.elastic.co/t/number-format-exception-when-querying-field-with-long-type-using-string/101972/1 "2017-09-27T11:27:35Z")

</div>

Hi!

I have a problem with querying one of the fields in my index.  
It seems to be quite similar to this: [Problems with Query\_String and different field types](https://discuss.elastic.co/t/problems-with-query-string-and-different-field-types/4504) , but it's an old issue so I wanted to create new one.

Elasticsearch version is 5.3.2.

One of the fields in the index:

```auto
curl -XGET http://elastic:changeme@localhost:10200/_mapping/campaign | jq "." | grep -A 2 campaign_id
"campaign_id": {
  "type": "long"
},

```

Now I want to use this field and some other to search for text given by user; it might be a number (which is applicable to `campaign_id` field), but it can be part of the name or something else, which would not be a number. Unfortunately, if I try to query with something which is not a number, I get an error:

```auto
$ curl -XPOST http://elastic:changeme@localhost:10200/campaign/campaign/_search \
     -d '
     {
       "query": { 
         "bool": { 
           "must": [
             {
               "match": {
                 "campaign_id": {
                   "query": "test",
                   "operator": "and",
                   "analyzer": "keyword"
                 }
               }
             }
           ]
         }
       }
     }'
[...]
"caused_by": {
  "type": "number_format_exception", "reason": "For input string: \"test\""
}

```

Is there any way to ignore this? It's ok for me if this query just doesn't match.

---

<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:** [October 25, 2017, 11:28am UTC](https://discuss.elastic.co/t/number-format-exception-when-querying-field-with-long-type-using-string/101972/2 "2017-10-25T11:28:18Z")

</div>

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