Search code examples
amazon-dynamodbamazon-cloudsearch

Search as you type functionality in amazon CloudSearch


How should I go about implementing search as you type in amazon CloudSearch to search Amazon dynamodb. Like the way algolia does it.


Solution

  • You can search-as-you-type by using a prefix search every time the user enters a character -- it would look something like this:

    (prefix field=name 'dri')
    

    The prefix search is necessary because a regular search for q=dri would not match drive, drivel, etc.

    Here are the prefix search docs: http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-text.html#searching-text-prefixes

    If you don't want to specify the fields for your prefix search you can use a query of the form q=dri* | dri (the non-* term is necessary because q=dri* does not match the word "dri" -- it requires there to be at least one additional character).