Search similar to SQL LIKE '%foo%'

Sorry if this has been asked before, but is there support for searching by substrings?

I notice in the docs here that there’s something similar that deals only with prefixes: https://oss.redislabs.com/redisearch/Query_Syntax/#mapping

SQL Redisearch

WHERE name LIKE ‘john%’ @name:john*

Given an entry with “Hello” I was hoping to be able to do something like ello, and have it find “Hello”.

I noticed suffix search was a feature request here: https://github.com/RedisLabsModules/RediSearch/issues/331

In this case, I don’t care whether the search term is a prefix or suffix, just that it’s contained in an entry in an index.

Hi Alejandro,

I think you’re looking for “fuzzy matching” which is new in 1.2.0

https://github.com/RedisLabsModules/RediSearch/releases/tag/v1.2.0

Hope this helps!

-Kyle

Thanks for the response Kyle.

This seems to use Levenshtein distance for fuzzy matching, which is useful but in this case I'm strictly looking for substrings.

LD of 1 means that if I have this data:

Some
Now

And I search for %som% it should match only Some, but for some reason it's also matching Now, even though this should be an LD of 2.

In either case, I'd like to search for "ome" and only get Some, not Now. This is strictly substring with no LD taken into account.

In Postgres you would use this in a WHERE clause

WHERE word LIKE '%ome%'

Does this make sense?

Notice that in SQL engines, this is done by a full scan and not by indexing.

Hello Alejandro,

This sounds like a nice feature request, please feel free to submit it.

Also, thanks for reporting the issue about numbers’ fuzzy search - AFAIK digits are not indexed, but I’ll let the devs answer in the repo.

And I search for %som% it should match only Some, but for some reason it’s also matching Now, even though this should be an LD of 2.

Please open an issue for that as well.

P.S. yo @dvirsky :slight_smile:

Cheers,

Hi Itamar,

What is the likelihood of the “substring” function being implemented in RediSearch at some point in time?

Alejandro, had you submitted the feature request for it?

Best regards,

Patrick

I see the feature request here: https://github.com/RedisLabsModules/RediSearch/issues/348

I actually asked this in the GitHub feature request as well, but still trying again here: is there any timetable on when this could be implemented? We are very happy with RediSearch as our database engine but lacking substring search is quite a drawback in many use cases.

@Miika sorry but the feature is not planned for the upcoming versions. You can see the general planing for the next versions here https://github.com/RediSearch/RediSearch/projects

I would imagine that since other subsstring searches are performed by doing full scans (can present locking issues) rather than using an index, it would kind of go contrary to the architecture of Redis and be cumbersome to implement. I could be off base here, but that is my first thought.

1 Like