Search Query Syntax - complex query in one - exact phrase, prefix and fuzzy

@bogumil Ah, so there is a trick.

If you manually do some tokenizing, the way you approach mid-query typeahead is to index partial queries and use payloads.

Consider this:

127.0.0.1:6379> FT.SUGADD typeahead "star wars trilogy" 1 PAYLOAD "star wars trilogy"
(integer) 1
127.0.0.1:6379> FT.SUGADD typeahead "wars trilogy" 1 PAYLOAD "star wars trilogy"
(integer) 2
127.0.0.1:6379> FT.SUGADD typeahead "trilogy" 1 PAYLOAD "star wars trilogy"
(integer) 3

Then as a user types:

127.0.0.1:6379> FT.SUGGET typeahead "tri" WITHPAYLOADS
1) "trilogy"
2) "star wars trilogy"
127.0.0.1:6379> FT.SUGGET typeahead "wa" WITHPAYLOADS
1) "wars trilogy"
2) "star wars trilogy"

It’s also possible to produce a trivial Lua script to do this tokenization for you, if you don’t want to push that complexity to your application.

One thing to note is that mid-search typeahead is only sometimes desirable. This is a personal opinion, but it pushes up the signal to noise ratio in many search domains. Seems like a good idea, but with actual data it tends to be a bit of a mess. Note: the solution won’t work for multiple query tokens, so star tri won’t work, although I would question the UX of this pattern as well.