1

I have a MultiSearch query over multiple types with multiple fields per type. I see that I can add a .SuggestPhrase() to an individual SearchDescriptor on an individual field, but not to an entire search query. How can I apply a Phrase suggestion to a multisearch query? Ideally it would be applied to all fields that are being searched on.

My use case is this: A user performs a MultiSearch query. They didn't find what they wanted. At this point I'd like to suggest a different query that might be what they're looking for. This would be similar to Google's "Did you mean..." recommendation.

Brandon
  • 1,058
  • 1
  • 18
  • 42

1 Answers1

1

Here's a suggest example.

{
  "suggest": {
    "did-you-mean": {
      "text": "pizaz",
      "phrase": {
        "field": "your-field-that-has-the-phrases-to-suggest-to",
        "direct_generator": [
          {
            "field": "your-field-that-has-the-phrases-to-suggest-to",
            "suggest_mode": "always",
            "post_filter": "standard"
          }
        ]
      }
    },
    "did-you-mean-field2": {
      "text": "piza",
      "phrase": {
        "field": "your-field-that-has-the-phrases-to-suggest-to-field2",
        "direct_generator": [
          {
            "field": "your-field-that-has-the-phrases-to-suggest-to-field2",
            "suggest_mode": "always",
            "post_filter": "standard"
          }
        ]
      }
    }
  }
}
leavesof3
  • 421
  • 4
  • 5
  • Does this answer the question? It appears to be unrelated to a multisearch, and it also appears that I have to specify each field individually. In my case I'll have about 40 different fields. I'm looking for a method that scales better. – Brandon Sep 09 '14 at 04:37
  • You can just use the "_all" instead of a specific field. As far as I know you can't specify a list of fields such as "field": ["field1", "field2"] so this is the only way to segment on specific fields – leavesof3 Sep 09 '14 at 06:21
  • @leavesof3 Just wondering if this is still the case that we can't specify the fields we want instead of doing "_all"? – susieloo_ May 30 '18 at 04:06