Using Index for Filtering with Regex

Task

Use rethinkdb backend for populating autocomplete/typeahead textbox (web ui).  It would be nice to be able to use index to speed up the query such as:

r.table(“users”).filter(function(user) {
return user(“lastName”).match(“^Ma”)

Solution

As suggest in this reply, a similar functionality could be accomplished by using the ‘between’ operator:

r.table('users').between('Ma', 'Mb', {index: 'lastName'})

 

keywords:

autocomplete rethinkdb auto complete autotype regular expression regex substring search index query

About Neil Rubens

see http://ActiveIntelligence.org

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*