WebHare community

Wait for Consilio indexing an entry

I have an application where I make use of a pretty big custom Consilio index (40.000 entries atm) to help speeding up WRD queries in a backend application.

It seems that (sometimes) when updating a WRD entity, calling CheckConsilioObjectByTag and updating the list (which triggers a Consilio search), Consilio is not quite ready re-indexing that entity.

Which brings me to the question: afaik, CheckConsilioObjectByTag triggers a task in Consilio to reindex. Is there some way to (a)wait this, so I can be 100% sure that the index for the particular entity is updated and I can safely refresh the list?

CheckConsilioObjectByTag just places the item on the queue, and doesn’t wait for anything else.

To do what you want through the offiical APIs: by waiting for the item to appear. keep searching until it does.

The publisher:whfs consilio index has implemented a promise-based interface for whfs indexing actions and does this by completely avoiding the central consilio queue and managing it by itself. Look for system:whfs.index.response in the source code, but that is all pretty low level - just one or two levels of abstraction away from speaking HTTP to the consilio indexmanager.

If I had to do what you are doing today… I wouldn’t even consider the consilio indexmanager but switch to an elasticsearch backed index, avoid the consilio queuemanager entirely, and use AddObjects with the synchronous flag whenever I wanted to be sure the item was there. But this is all pretty low level and requires a bit of understanding of how elasticsearch itself works.

Thanks. I’ll guess I will need to look into ElasticSearch or the Publisher solution one day.

For now I’ve fixed it by updating the row from the database directly and in unit tests with a simple loop that keeps searching.