Query_string with wildcard

I am having latest ES and set a field in mapping to keyword and index: true.

I need to use wildcard so this example from your web is perfect match:

      "query": {
        "query_string" : {
          "query" : "city.\\*:(this AND that OR thus)"

But it is not working for me. I added


but still no match with wildcard. I need to search for something like

name: "John *" AND (city: "Berlin" OR city: "Prague")

therefore I need to use query_string and not wildcard search directly.
So what mapping should I use? r what I am doing wrong?

you need to use a bool query.
bool is used to combine a few conditions together.
So your query will be something like (just high level pseudo code) -->

    "query": {
        "bool": {
            "must": [
                "bool": {
                    "should": [
					{"term": {"city": "Berlin"}}, 
					{"term": {"city": "Prague"}}
					{"wildcard": {"name": "john*"}}

Here is a good example.
And another one

Can I make just one query_string? This is input from search bar by user so I have no idea what user will search for. If he writes wildcard or name of attribute

Not sure what your requirements are.
You can create predefined filters and let the users enable/disable them whenever they need to.
Also, they can edit these filters if that's a requirement.

If this is in Kibana, you can consider creating a dropdown filter element.

I have around 30 different attributes taht user can use to filter. He can write name of attribute or I set default fields to search in, he can do range query, wildcard query... so I can't create predefined filters, so many cobinations.

I am not using kibana.

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