Intro
Autocomplete is one of the most important features for modern software development. When user presses some text at text field, software will return suitable options to user. And user can select someone to execute specify action.
Principles
- Read times >>>>> write times
References
- http://oldblog.antirez.com/post/autocomplete-with-redis.html
- https://redis.com/ebook/part-2-core-concepts/chapter-6-application-components-in-redis/6-1-autocomplete/6-1-1-autocomplete-for-recent-contacts/
- https://redis.com/ebook/part-2-core-concepts/chapter-6-application-components-in-redis/6-1-autocomplete/6-1-2-address-book-autocomplete/
- https://www.prefixbox.com/blog/autocomplete-search/
- https://zh.wikipedia.org/wiki/%E8%87%AA%E5%8A%A8%E5%AE%8C%E6%88%90
Difference autocomplete with search suggestion
The two words always used alternately. Currently, autocomplete defines prefix match, and search suggestion defines any position match.
Elasticsearch
Redis
Comparison between Elasticsearch and Redis
Comparison | Elasticsearch | Redis |
---|---|---|
Write speed | N/A | N/A |
Read speed | Because all data store at hard disk, the same keyword must read slowly at first time, and stores all results to memory. But read data faster since second time if the same keyword | Because all data store at memory, the speed must faster than Elasticsearch overall |
Storage size | Depends on edge-ngram's min and max ngram | If sort by length, simple version more less than complicated version |
Storage cost | Store at hard disk, low cost | Store at memory, high cost |
Summary
- Elasticsearch’s edge-ngram tokenizer can improve many works, including create inverted index and tokenize.
- Elasticsearch’s storage size maybe more than Redis, because Elasticsearch store data at hard disk, Redis store data at memory.
- Although Elasticsearch access data at hard disk, but query syntax will use filter clause. So old query results would store at memory, and query speed maybe not obvious slowly