Before, we were able to successfully find 'roots' in a tree by checking for an empty previous_id:
Phrase.search do
with :previous_id, nil
end.results
Now we successfully changed the model from 1:n (belongs_to) to n:n (has_and_belongs_to_many).
We upgraded the searchable segment from
integer :previous_id #, :references => Phrase
to
integer :previous_ids, :multiple => true, :stored=>true do
previous.reload
previous_ids #OK!
end
Everything works fine except that the following search for nodes with empty associations returns all nodes:
Phrase.search do
with :previous_ids, nil
end.results
How to search sunspot rails for empty associations?