How to implement autocomplete on a massive dataset

前端 未结 7 923
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 21:54

I\'m trying to implement something like Google suggest on a website I am building and am curious how to go about doing in on a very large dataset. Sure if you\'ve got 1000 items

7条回答
  •  悲哀的现实
    2021-01-29 22:01

    I've built AutoCompleteAPI for this scenario exactly.

    Sign up to get a private index, then, Upload your documents.

    Example upload using curl on document "New York":

    curl -X PUT -H "Content-Type: application/json" -H "Authorization: [YourSecretKey]" -d '{
    "key": "New York",
    "input": "New York"
    }' "http://suggest.autocompleteapi.com/[YourAccountKey]/[FieldName]"
    

    After indexing all document, to get autocomplete suggestions, use:

    http://suggest.autocompleteapi.com/[YourAccountKey]/[FieldName]?prefix=new
    

    You can use any client autocomplete library to show these results to the user.

提交回复
热议问题