Acts_as_indexed . with_query() does not return the expected results in the query

Asked

Viewed 10 times

0

Good afternoon, I have a method to search for products in the bank that uses the with_query method of Gem acts_as_indexed:

Product.with_query(query_text)

This generates an SQL query like this:

SELECT produtos.* FROM produtos WHERE (products.id IN (NULL)) LIMIT 11

I have tested by replacing . with_query(query_text) with . all and the results are returned. I have already checked in my model products.Rb I have configured the fields for Gem to work (acts_as_indexed :Fields => [ :status, :name ]).

Does anyone have any idea why Gem is returning WHERE (products.id IN (NULL)) in the query? Thank you.

The same is true for the console

Product.with_query('Pump')

Load product (0.6ms) SELECT produtos.* FROM produtos WHERE (products.id IN (NULL)) LIMIT 11

1 answer

0

The problem has been fixed by updating all products. Apparently this Gem creates some kind of index when the item is updated.

I did it on the Rails console:

Produto.all.each do |produto|
    nome = produto.nome
    Produto.update(produto.id, :nome => 'teste')
    Produto.update(produto.id, :nome => nome )
end

Browser other questions tagged

You are not signed in. Login or sign up in order to post.