Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

How to monkey patch to avoid 'Couldn't find all users with IDs', found 9 results was looking for 10 #852

Closed
inspire22 opened this issue Aug 29, 2013 · 5 comments

Comments

@inspire22
Copy link

Sometimes my servers lose a connection, or there's a database issue, and a rogue row gets left in ES, that is not in my database. It's not terribly important for me.

Ideally I'd rescue it to delete the missing row and return the result.

Initially it sounds simpler to just monkey-patch around raising this error, to silently return whatever results could be found.

Any tips where in the source to start looking? Load: true is difficult to search for...

Thanks for a great project :)

@inspire22
Copy link
Author

In case anyone else has this problem, this seems to work as an obvious workaround:

 ids = request.results.to_a.collect {|a| a['id']}
 myclass.where(:id => ids)

@Awea
Copy link

Awea commented Sep 17, 2013

To force deletion on ES with Tire you can use something like this :

MyModel.index.remove('my_model', object_id)
MyModel.index.refresh #without I can't get it work

This help you ?

@inspire22
Copy link
Author

That unfortunately requires the more-complicated step of finding which row was missing.

I'm still lobbying for this "Couldn't find al" "feature" to be removed.

@karmi
Copy link
Owner

karmi commented Oct 2, 2013

Hi, the hook point for the monkeypatch is the Tire::Results::Collection#__find_records_by_ids. Just override it by using where(ids:...) instead of find(ids) for ActiveRecord. Please ping me if you'd have trouble with it.

@karmi karmi closed this as completed Oct 2, 2013
@karmi
Copy link
Owner

karmi commented Oct 2, 2013

Related: #810

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants