3

I have following query that queries (simple_query_string) and also does suggest, but before it does any of this, I would like to filter the data using a term.

{
    "query": {
      "simple_query_string": {
        "fields": ["merchant.basic"],
        "query": "(sterbuck|sterbuck*)",
        "default_operator": "and"
      }
    },
    "suggest": {
      "text": "sterbuck",
      "phraseSuggestion": {
        "phrase": {
          "field": "merchant.basic",
          "direct_generator": [{
            "field": "merchant.basic",
            "suggest_mode": "popular",
            "min_word_length": 3,
            "prefix_length": 2
          }]
        }
      }
    },
    "size": 4,
    "_source": ["merchant"]
  }

Thank you in advance.

1 Answer 1

7
{
   "query":{
      "bool":{
         "must":{
             "simple_query_string": {
            "fields": ["merchant.basic"],
            "query": "(star|star*)",
            "default_operator": "and"
          }
         },
         "filter":{
            "term":{
               "name":"michael"
            }
         }
      }
   },
   "suggest": {
       "text": "sterbuck",
          "phraseSuggestion": {
            "phrase": {
              "field": "merchant.basic",
              "direct_generator": [{
                "field": "merchant.basic",
                "suggest_mode": "popular",
                "min_word_length": 3,
                "prefix_length": 2
              }]
            }
          }
    },
    "size": 4,
    "_source": ["merchant"]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.