Wildcard not working

{
	"query":{
		"wildcard":{
			"id": "C0*"
		}
	}
}

I'm trying to run a get request through postman using this as a json body. there is around 44k entries with this id. But when I run it I cannot see any data in my response body. I'm set allow expensive query to true as well.

Hi @yash_gehi, Welcome to the Elastic community.

I assume your id has a type text. And it is not holding terms which starting with "C0*".

For example:

Add some documents

POST test-wildcard/_doc
{
  "id":"C0111a"
}

POST test-wildcard/_doc
{
  "id":"C0111b"
}

POST test-wildcard/_doc
{
  "id":"C0111c"
}

I am getting proper result for below query:

GET test-wildcard/_search?pretty
{
  "query": {
    "wildcard": {
      "id": {
        "value": "c0*"
      }
    }
  }
}

GET test-wildcard/_search?pretty
{
  "query": {
    "wildcard": {
      "id.keyword": {
        "value": "C0*"
      }
    }
  }
}

Here my id type is text and id.keyword having keyword type.

Similarly you can check with your mapping with below query:

GET index-name/_mappings
1 Like

Thank you Ashish!

1 Like

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