Search similar to SQL LIKE '%foo%'

88 views
Skip to first unread message

Alejandro Wainzinger

unread,
May 31, 2018, 11:27:06 PM5/31/18
to redisearch
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.

Kyle Davis

unread,
Jun 1, 2018, 9:15:21 AM6/1/18
to redisearch
Hi Alejandro,

I think you're looking for "fuzzy matching" which is new in 1.2.0


Hope this helps!

-Kyle

Alejandro Wainzinger

unread,
Jun 1, 2018, 2:08:44 PM6/1/18
to redisearch
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?

Dvir Volk

unread,
Jun 1, 2018, 3:05:26 PM6/1/18
to Alejandro Wainzinger, redisearch
Notice that in SQL engines, this is done by a full scan and not by indexing. 

--
You received this message because you are subscribed to the Google Groups "redisearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redisearch+...@googlegroups.com.
To post to this group, send email to redis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redisearch/6039dcd8-762c-49d3-84b5-8d84623167bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Itamar Haber

unread,
Jun 1, 2018, 3:13:24 PM6/1/18
to Dvir Volk, Alejandro Wainzinger, redisearch
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 :)

Cheers,

On Fri, Jun 1, 2018 at 10:05 PM, Dvir Volk <dvi...@gmail.com> wrote:
Notice that in SQL engines, this is done by a full scan and not by indexing. 
On Fri, Jun 1, 2018, 9:08 PM Alejandro Wainzinger <aikawa...@gmail.com> wrote:
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?

--
You received this message because you are subscribed to the Google Groups "redisearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redisearch+unsubscribe@googlegroups.com.

To post to this group, send email to redis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redisearch/6039dcd8-762c-49d3-84b5-8d84623167bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "redisearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redisearch+unsubscribe@googlegroups.com.

To post to this group, send email to redis...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber
Technicalist Evangenly

Phone: +972.54.567.9692

Redis Labs


pel...@assemblypayments.com

unread,
Aug 7, 2018, 9:05:48 PM8/7/18
to redisearch
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


On Saturday, June 2, 2018 at 5:13:24 AM UTC+10, Itamar Haber wrote:
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 :)

Cheers,
On Fri, Jun 1, 2018 at 10:05 PM, Dvir Volk <dvi...@gmail.com> wrote:
Notice that in SQL engines, this is done by a full scan and not by indexing. 
On Fri, Jun 1, 2018, 9:08 PM Alejandro Wainzinger <aikawa...@gmail.com> wrote:
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?

--
You received this message because you are subscribed to the Google Groups "redisearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redisearch+...@googlegroups.com.

To post to this group, send email to redis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redisearch/6039dcd8-762c-49d3-84b5-8d84623167bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "redisearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redisearch+...@googlegroups.com.

To post to this group, send email to redis...@googlegroups.com.

pel...@assemblypayments.com

unread,
Aug 7, 2018, 9:06:44 PM8/7/18
to redisearch
Reply all
Reply to author
Forward
0 new messages