Search code examples
amazon-cloudsearch

Cloudsearch suggester


I recently started working with cloudsearch. When I came across term "Suggester", it confused me. I am not getting difference between a Suggester and prefix search. Aren't those two same? If not can someone explain me what is the difference?

Thank you in advance.


Solution

  • The /suggest API and prefix search are similar, in the sense that they both perform prefix queries. But there are some key differences with suggestions to be aware of:

    • Limited to matches in a single field
    • Prefix matches only
    • Dedicated API
    • Compact response body (only returns the matched field, score, and document ID)

    I'm guessing that the suggest API was thrown together with a limited feature set just to make it easy to provide search-as-you-type suggestions. In my experience, the big downside to this API is that you are relying on users beginning their query with the exact word that your field begins with.

    Here's an example from my company to help illustrate the issue. Let's say you have 5 documents with the word "soap" in the title, but at different positions. Only the document that begins with "soap" would be returned as a match.

    luxury bath soap
    foaming hand soap
    soap dispenser <--- (only prefix match)
    liquid hand soap
    dish soap
    

    Obviously all of those titles are relevant, because they all contain the exact search term. But only "soap dispenser" is a prefix match, which would result in a pretty lousy user experience. I think there's definitely a place for prefix queries like this, but most users aren't going to be familiar enough with the search index to know what word to begin searching for.


    I ended up just using the /search API so I could provide suggestions based on matches anywhere in the field. I limited the number of fields being returned, to limit the size of the response body, and it's worked out very nicely for me.