# Different Query format for wildcard query and term query

**URL:** <https://discuss.elastic.co/t/different-query-format-for-wildcard-query-and-term-query/321250>\
**Category:** Elasticsearch\
**Tags:** eql-elastic-query-language\
**Created:** [December 15, 2022, 4:31am UTC](https://discuss.elastic.co/t/different-query-format-for-wildcard-query-and-term-query/321250 "2022-12-15T04:31:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adholpuria](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@adholpuria](https://discuss.elastic.co/u/adholpuria)\
**Post date:** [December 15, 2022, 4:31am UTC](https://discuss.elastic.co/t/different-query-format-for-wildcard-query-and-term-query/321250/1 "2022-12-15T04:31:42Z")

</div>

Hey community, I am currently using below mentioned query format for term query

```auto
{
  "query": {
    "term": {
      "core.externalId": "Kimchy"
    }
  }

```

Below is the query format described in Elasticsearch Document [Term query | Elasticsearch Guide [8.5] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.5/query-dsl-term-query.html)

```auto
{
  "query": {
    "term": {
      "user.id": {
        "value": "kimchy"
      }
    }
  }
}

```

I am planning to implement same format for wildcard query as well which have similar differences as Term query in comparison to Elasticsearch Document

What I am implementing  
`<fieldName> : <value>`

Elasticsearch document query format

```auto
<fieldName> : {
"value": <value>
}

```

I have tried these two query formats directly on Elasticsearch and both of these are working fine.

Attaching wildcard Query examples that I have tried directly on Elasticsearch –  
Request

```auto
{
  "query": {
    "wildcard": {
      "core.ext::keyword": "Di*ionary"
    }
  }
}

```

Response

```auto
{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 3,
            "relation": "eq"
        },
        "max_score": 1.0,
        "hits": [
            {
                "_index": "adholpuria",
                "_type": "_doc",
                "_id": "xxxxxxxx",
                "_score": 1.0,
                "_source": {
                    "core.name::text": "Reading",
                    "core.ext::keyword": "dictionary"
                }
            },
            {
                "_index": "adholpuria",
                "_type": "_doc",
                "_id": "xxxxxxxxx",
                "_score": 1.0,
                "_source": {
                    "core.name::text": "Reaping",
                    "core.ext::keyword": "dicpionary"
                }
            },
            {
                "_index": "adholpuria",
                "_type": "_doc",
                "_id": "xxxxxxxx",
                "_score": 1.0,
                "_source": {
                    "core.name::text": "Reamding",
                    "core.ext::keyword": "dicmtionary"
                }
            }
        ]
   }
}

```

I am looking for supportive doc. But couldn't find one. Do e have any supportive document for `<fieldName> : <value>` query format. Is there any possibility that earlier Elasticsearch has  
`<fieldName> : <value>` query format for term query and wild card query but now it is depricated?

Thanks

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [December 15, 2022, 10:33am UTC](https://discuss.elastic.co/t/different-query-format-for-wildcard-query-and-term-query/321250/2 "2022-12-15T10:33:26Z")

</div>

Hi Abhijeet,

To confirm, are you looking for the documentation for the [wildcard terms query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html), but specifically the `"field": "value"` form? I see an example in the [terms query documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.5/query-dsl-term-query.html), but not in the wildcard one. As these are both term type queries they should work in a similar way.

Not sure which version of Elasticsearch you are using, but having a scan through that format for wildcard in prior versions, wildcard with this format has been supported [since at least 1.3](https://www.elastic.co/guide/en/elasticsearch/reference/1.3/query-dsl-wildcard-query.html).

You can use `"field": "value"` as a shorthand where you don't need any other optional parameters as per the query DSL. Hope that helps!

---

<div class="post-metadata">

**Author:** ![adholpuria](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@adholpuria](https://discuss.elastic.co/u/adholpuria)\
**Post date:** [December 15, 2022, 10:50am UTC](https://discuss.elastic.co/t/different-query-format-for-wildcard-query-and-term-query/321250/3 "2022-12-15T10:50:59Z")

</div>

Hey Carly,  
yes that helps. Thanks for replying.

---

<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:** [January 12, 2023, 10:51am UTC](https://discuss.elastic.co/t/different-query-format-for-wildcard-query-and-term-query/321250/4 "2023-01-12T10:51:38Z")

</div>

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