# How to run wildcard queries for long types?

**URL:** <https://discuss.elastic.co/t/how-to-run-wildcard-queries-for-long-types/319706>\
**Category:** Elasticsearch\
**Created:** [November 24, 2022, 7:35am UTC](https://discuss.elastic.co/t/how-to-run-wildcard-queries-for-long-types/319706 "2022-11-24T07:35:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![golofetuk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/golofetuk/32/114272_2.png) [@golofetuk](https://discuss.elastic.co/u/golofetuk)\
**Post date:** [November 24, 2022, 7:35am UTC](https://discuss.elastic.co/t/how-to-run-wildcard-queries-for-long-types/319706/1 "2022-11-24T07:35:51Z")

</div>

I just run a simple wildcard query on my elasticsearch server.

My query is;

```auto
GET calls-*/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "should": [
              {
                "query_string": {
                  "default_field": "foo.number",
                  "query": "*16922*"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

The error response looks like this;

```auto
Can only use wildcard queries on keyword, text, and wildcard fields - not on [foo.number] which is of type [long]

```

when I check the index info I saw number type is `long`. If I switch to `text` from `long` everything worked as expected. This [answer](https://stackoverflow.com/a/67949362/14373656) says exact same thing.

```auto
"number": {
  "type": "long",
  "ignore_malformed": false,
  "coerce": true
},

```

But I can't change the number type because the code will ship to the prod server and I can't modify any prod elastic index.

So how can I run my wildcard queries without any errors? If the only way is the modifying the index (switch `text` from the `long`), can I replace wildcard queries with another method?

---

<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:** [December 22, 2022, 7:36am UTC](https://discuss.elastic.co/t/how-to-run-wildcard-queries-for-long-types/319706/2 "2022-12-22T07:36:37Z")

</div>

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