0

Following the example provided:

# add data to hash set
HSET movies:11002 title "Star Wars: Episode V - The Empire Strikes Back" plot "Luke Skywalker begins Jedi training with Yoda." release_year 1980 genre "Action" rating 8.7 votes 1127635
HSET movies:11003 title "The Godfather" plot "The aging patriarch of an organized crime dynasty transfers control of his empire to his son." release_year 1972 genre "Drama" rating 9.2 votes 1563839

# create index
FT.CREATE idx:movies ON hash PREFIX 1 "movies:" SCHEMA title TEXT SORTABLE release_year NUMERIC SORTABLE rating NUMERIC SORTABLE genre TAG SORTABLE

# search movies
FT.SEARCH idx:movies * SORTBY release_year ASC RETURN 2 title release_year

# search action movies
FT.SEARCH idx:movies "star @genre:{action}" RETURN 2 title release_year

# search movie that title starts with god
FT.SEARCH idx:movies @title:god* SORTBY release_year ASC RETURN 2 title release_year

# search movie that ends with father (DOESNT WORK)?
FT.SEARCH idx:movies @title:*father SORTBY release_year ASC RETURN 2 title release_year

# search movie that contains fath (DOESNT WORK)?
FT.SEARCH idx:movies @title:*fath* SORTBY release_year ASC RETURN 2 title release_year

How do I make the contains string work?

Someone mentioned AGGREGATION, but I don't know how to make this return results:

FT.AGGREGATE idx:movies "*" FILTER "contains('title', 'father')"

redis version: 6.2.7

# Modules
module:name=timeseries,ver=10611,api=1,filters=0,usedby=[],using=[],options=[handle-io-errors]
module:name=graph,ver=20813,api=1,filters=0,usedby=[],using=[ReJSON],options=[]
module:name=search,ver=20408,api=1,filters=0,usedby=[],using=[ReJSON],options=[handle-io-errors]
module:name=ReJSON,ver=20009,api=1,filters=0,usedby=[search|graph],using=[],options=[handle-io-errors]
module:name=bf,ver=20215,api=1,filters=0,usedby=[],using=[],options=[]
Teebu
  • 677
  • 7
  • 18

1 Answers1

2

There's really two questions here but I'm happy to answer both:

  1. How do I make the contains string work?
    RediSearch doesn't support prefix wildcards, only postfix wildcards. So, using FT.SEARCH, this is not possible.

  2. Someone mentioned AGGREGATION, but I don't know how to make this return results.
    Your call to the contains function is not providing the field name properly. Field names are almost always prefixed with an @. Easy mistake to make and I've made it many times myself. Try this:

FT.AGGREGATE idx:movies "*" FILTER "contains(@title, 'father')"

Hope that helps!

Guy Royse
  • 2,739
  • 12
  • 9
  • 1
    Thanks Guy. Loved your video on bloom filters. I see there is an open issue regarding #1 for like 2 years, I think redis search should support this. – Teebu Jun 27 '22 at 22:45
  • 1
    @Teebu we have prefix search today on our master branch (you can try it out with the edge docker container) and wildcard search will be available ion the master branch within a couple of weeks. We will release a milestone release (pre release) of both features soon – Pieter Cailliau Jun 28 '22 at 08:45
  • @PieterCailliau hello, thanks for answer. Do you have any link to issue or PR where I can track progress please? Thanks – quatermain Aug 04 '22 at 09:25
  • https://github.com/RediSearch/RediSearch/pull/2932 https://github.com/RediSearch/RediSearch/pull/2774 – Pieter Cailliau Aug 06 '22 at 09:29