You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you create a new category that doesn't have any products assigned to it, it won't be included in the index because the :if proc isn't satisfied. If you then later add a product to it and force/trigger the update_index method (changing no other indexed field), it won't be added to the index. This is because ActsAsIndexed::SearchIndex::record_unchanged? will always return true in this case, because when the proc is evaluated on old_record it sees that c.products.count > 0 and the same happens with the proc is evaluated on the old_record - i.e. it is basing the old and new state on the same virtual attribute which isn't ever going to be dirty.
The text was updated successfully, but these errors were encountered:
chrisbloom7
changed the title
If a record doesn't qualify to be included in the index on create, it will never be added even if a later save makes it qualify
If a record doesn't qualify to be included in the index on create, it may not be added even if a later update makes it qualify
Oct 7, 2014
I did some digging in the source and found that records that aren't originally in the index can be added if they later qualify, but just not in certain circumstances. I updated the issue title and description with a more accurate example.
Consider the following model:
If you create a new category that doesn't have any products assigned to it, it won't be included in the index because the
:if
proc isn't satisfied. If you then later add a product to it and force/trigger the update_index method (changing no other indexed field), it won't be added to the index. This is becauseActsAsIndexed::SearchIndex::record_unchanged?
will always return true in this case, because when the proc is evaluated onold_record
it sees thatc.products.count > 0
and the same happens with the proc is evaluated on theold_record
- i.e. it is basing theold
andnew
state on the same virtual attribute which isn't ever going to be dirty.The text was updated successfully, but these errors were encountered: