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
Post a Comment