[katello-devel] elasticsearch delay in being able to search

Justin Sherrill jsherril at redhat.com
Tue Jun 11 15:50:51 UTC 2013


On 06/11/2013 10:15 AM, Tom McKay wrote:
> Need some elasticsearch assistance...
>
> Since changes to subscriptions can happen in candlepin without katello being made aware of them (eg. a system registers, triggering the generation of a virtual bonus subscription), I have code in place that will reindex all the subscription pools whenever the page is visited. This imposes a slight hit but helps insure that searches will return the proper results.
>
> In switching to use nutupane, which pulls its data from the api controller, I am running into an issue. I'd like to continue indexing the pools as before, but then immediately perform an elasticsearch query on the results. When I do this, instead of getting the 40 results, I get a variable number back. My guess is this is due to elasticsearch not immediately refreshing all its shards (or something similar?).
>
> The re-index code:
> https://github.com/Katello/katello/blob/master/app/models/glue/elastic_search/pool.rb#L79
>
> Some elasticsearch docs:
> http://www.elasticsearch.org/guide/reference/api/bulk/
> http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh/
>
> Any suggestions?
We hit this previously due to when we create a new entity we immediately 
search that entity to see if it matches the current search and display a 
message to the user if it doesn't.  You do need to manually refresh the 
index. We call Model.index.refresh, but in your case its not an active 
record model, so i believe something like:  
Tire.index(index_name).refresh   should work.  If it doesn't i can look 
into it more tomorrow.

-Justin




More information about the katello-devel mailing list