Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard queries in field name

I can use simple wildcard query like this:

"wildcard" : { "user" : "ki*y" }

but if i want to use wildcard in field, then what? How shoud look valid query for this:

"wildcard" : { "base/*" : "value" }
like image 902
FoKycHuK Avatar asked Jul 15 '15 14:07

FoKycHuK


People also ask

What is a wildcard query?

Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with similar, but not identical data. Wildcards can also help with getting data based on a specified pattern match.

What is the keyword that is necessary to use with wildcard queries?

To use wildcard characters in a query, the enableQuerySyntax option of the Querybox component must be enabled.

What is wildcard in elastic search?

A wildcard operator is a placeholder that matches one or more characters. For example, the * wildcard operator matches zero or more characters. You can combine wildcard operators with other characters to create a wildcard pattern.


1 Answers

You can use query_string which allows both field names wildcards and query text wildcards.

Something around these lines:

{
  "query": {
    "query_string": {
      "fields": [
        "base*"
      ],
      "query": "ki*y"
    }
  }
}
like image 125
Andrei Stefan Avatar answered Oct 05 '22 23:10

Andrei Stefan