Skip to content

Instantly share code, notes, and snippets.

@panmari
Created August 28, 2013 09:14
Show Gist options
  • Save panmari/6363953 to your computer and use it in GitHub Desktop.
Save panmari/6363953 to your computer and use it in GitHub Desktop.
Starting two queries to the elasticsearch server through the Tire gem. Even though the long, complicated query starts before the short one, the short one is returned first.
# try this in a rails environment, that has the Indexing module loaded. (medcode, orangeproton)
search_queries = ["Ein sehr komplizierter query, der sehr lange zum ausfuhren braucht", "kurz"] # !sic
threads = []
search_queries.each do |string|
threads << Thread.new(string) do |query|
puts "started #{query}"
Indexing.elastic_find_all(string, 'icd', '2012', 'ch', 'de')
puts "finished #{query}"
end
end
threads.each { |t| t.join }
@panmari
Copy link
Author

panmari commented Aug 28, 2013

Output (with corrected newlines):

started Ein sehr komplizierter query, der sehr lange zum ausfuhren braucht 
started kurz 
finished kurz 
finished Ein sehr komplizierter query, der sehr lange zum ausfuhren braucht 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment