How do we OR filters using rethinkdb and nobrainer in ruby on rails? -



How do we OR filters using rethinkdb and nobrainer in ruby on rails? -

following nobrainer docs here: http://nobrainer.io/docs/querying/

i trying or query, articles keyword matches title or text fields...

the next query returns no results...

s = 'something' @articles = article.where(:or=>[:title=>/(?i)#{s}/, :text=>/(?i)#{s}/])

i checked regex next query , works...

@articles = article.where(:title=>/(?i)#{s}/)

could help understand how or queries? thanks.

update:

the query returns results if search term found in both fields... appears working , instead of or!

the nobrainer documentation warns of behaviour:

:or => [p1,...,pn] evaluates true when @ to the lowest degree 1 of predicates true.

be aware [:a => 1, :b => 2] same [{:a => 1, :b => 2}], not same [{:a => 1}, {:b => 2}].

your query may work if add together curly brackets:

@articles = article.where(:or=>[{:title=>/(?i)#{s}/}, {:text=>/(?i)#{s}/}])

rethinkdb-ruby

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -