Right now I have the following code:
search = Tire.search ['object1_index', 'object2_index'] do |search|
search.query { string params[:q] }
end
@results = search.results
The results right now are all coming from just object1, however, if I remove 'object1_index' with the same query, I do get object2 results. How can I get my search to interact with both indices at once?
edit:
I now have the following (using the search I have defined on my models), but as I will be eventually adding pagination I'm unsure if this is the best work around:
object1_results = Object1.search(params).results
object2_results = Object2.search(params).results
@results = object1_results + object2_results
@results.sort!(&:_score)
Just add size
parameter since elasticsearch default size is 10 which must be only limiting to object1_index
search space in your case
search = Tire.search ['object1_index', 'object2_index'], size: 1000 do |search|
...
Update
For pagination, you can add from
parameter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With