Dynamic Templates - Query

Hello,
Can I have example of query which uses dynamic template in mapping.

This question does not make sense to me.

A dynamic template is something applied when a new field is created.
A query is ran when you search for documents.

Could you clarify your question?

I am having an index contains following mapping.

{
"dynamic": false,
"dynamic_templates": [
{
"ticket_state_filter": {
"match": "*_state",
"mapping": {
"type": "keyword"
}
}
}
]
}

And Having document something like below.
{
"typeId": "60445e4b-03ea-4d7c-a3a3-12b8da1f2f9b",
"typeFieldDetails": {
"tic_state": "AL"
}
}

"tic_state" field is dynamic. it may have fieldname like '*_state'.
Now I want to search on this dynamic field.
How can I achieve this?

Thank you!

This?

GET /_search?q=tic_state:AL

Thanks for showing interest.

But while searching I don't know the field name. I guess I need to write script for generating field name.

This?

GET /_search?q=AL

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