FT.SEARCH from a list key

What I need to do is.

I have only 1 big text, and a list of words to search for. The desired output is another list from this input list. What I’ve done so far is something like this.

FT.CREATE my-doc-index SCHEMA texto TEXT

FT.ADD my-doc-index document 1 FIELDS texto “this is supposed to be a very big text with words.”

RPUSH list-of-terms “this is” “the big” “list of” “words” “to search” “for”

FT.SEARCH my-doc-index “supposed words” HIGHLIGHT

This works “ok”. The current output is the input text with a bunch of ‘< b>’ which is not the best case, but I know that I can parse it using python which is fine.

What I would like to do is run using the list “list-of-terms” instead of passing a string with a list of words.
Like this:

FT.SEARCH my-doc-index list-of-terms # Is this possible?

And would be great if I can get the list of words found directly as a list instead of the input text with a bunch of ‘< b>’ in the text.

you can use OR operator to pass a list of terms that you wanna to search for. For example:

Given a INDEX:


you can load data using HSET or JSON.SET (FT.ADD is deprecated):

HSET k1 texto "I can play the guitar"
HSET k2 texto "I like to listen to bel canto music"
HSET k3 texto "I like to play the piano"

and retrieving the multiple terms using the operator “|”, highlighting them using HIGHLIGHT and defining the TAGS [open close] that better suits you, in such as:

FT.SEARCH idx '(guitar|piano)' HIGHLIGHT TAGS _ _


1) "2"
2) "k1"
3) 1) "a"
   2) "I can play the _guitar_"
4) "k3"
5) 1) "b"
   2) "I like to play the _piano_"

you can find more details here: Highlighting

I have 2 problems here.

  1. I want to be able to search compound words, like “of course”, “in case of”, etc…

I read query syntax documentation and it says that I can search compound words, however, I wasn’t able to get the desired output.

  • Exact phrases are wrapped in quotes, for example, "hello world".

When I try it.

FT.SEARCH idx "listen to" highlight tags _ _
1) (integer) 1
2) "k1"
3) 1) "texto"
   2) "I like to _listen_ to bel canto music"
  1. I wanted that the output was something like this, (even though this is not so important)
1) "2"
2) "k1"
3) 1) "a"
   1) "guitar"
   2) "piano"

here there is 2 different approaches,

  1. is disabling STOPWORDS for the index take in consideration words like “of”, “the” when creating your index, here you can find more about redis_io/docs/stack/search/reference/stopwords

  2. the index on search split the phrase in different terms using the whitespace as separator (others applied too), you can use backlash to ignore it as described here: redis_io/docs/stack/search/reference/escaping/

about the item 2. currently not supported