# Count values in terms based on the starting character

**URL:** <https://discuss.elastic.co/t/count-values-in-terms-based-on-the-starting-character/211658>\
**Category:** Elasticsearch\
**Created:** [December 12, 2019, 1:50pm UTC](https://discuss.elastic.co/t/count-values-in-terms-based-on-the-starting-character/211658 "2019-12-12T13:50:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinothkumar\_Ganeshan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinothkumar_ganeshan/32/46534_2.png) [@Vinothkumar\_Ganeshan](https://discuss.elastic.co/u/Vinothkumar_Ganeshan)\
**Post date:** [December 12, 2019, 1:50pm UTC](https://discuss.elastic.co/t/count-values-in-terms-based-on-the-starting-character/211658/1 "2019-12-12T13:50:04Z")

</div>

Hello,  
I have an index seach-2019-08\* and it has term site. I want to count the terms based on the starting character of the site.

> GET search-2019-08\*/\_count  
> { "query": { "bool": {  
> "must": [  
> {  
> "term": {  
> "site": "a\*"  
> } } ] } }}

I'm looking for the count of documents with site starts with a. but, it always return 0. But, I know, there is some data like that

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [December 14, 2019, 12:32pm UTC](https://discuss.elastic.co/t/count-values-in-terms-based-on-the-starting-character/211658/2 "2019-12-14T12:32:03Z")

</div>

You can't use wildcards in a `term` query. What you're doing here is search for documents that contain the exact two characters `a` and `*`.

If you want to use wildcards, you have to use the `wildcard` query:

```auto
GET search-2019-08*/_count
{
  "query": {
    "wildcard": {
      "site": {
        "value": "a*"
      }
    }
  }
}

```

---

<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 11, 2020, 12:32pm UTC](https://discuss.elastic.co/t/count-values-in-terms-based-on-the-starting-character/211658/3 "2020-01-11T12:32:08Z")

</div>

Closed on January 11, 2020, 12:32pm UTC

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