Replies: 3 comments 6 replies
-
Why not 6.0.4? The 3, is super old and is missing a lot of fixes, refactoring and features, besides there is no time to support it anymore. The More importantly, you should formulate your questions in a way that does not require to go through a lot of your logic, or I doubt that anybody would have the time to get through it. |
Beta Was this translation helpful? Give feedback.
-
Hi @ddnexus, thank you for taking the time to go through my question. You are right, I apologize for overloading it with so much detail - I just wanted to include every important piece to make following my logic easier. Seems I did quite the opposite 😬 I tried updating to the latest (6.0.4) version but it doesn't seem to resolve the issue. Let me rephrase my question to make it more concise and simple: In my ElasticSearch query, I use the Here's how I pass the query to the
In my code, I do override Do you know how can I keep the total limit I set by the |
Beta Was this translation helpful? Give feedback.
-
By the way, a question on your first part:
Could switching to the "passive" mode help me control the total number of results?
How would I make sure I get the same output format as when I use the active mode? |
Beta Was this translation helpful? Give feedback.
-
I have a problem with limiting the total number of search results in my web application.
The web app is written in Ruby, the search functionality is powered by ElasticSearch, and the pagination is handled by the Pagy ruby gem (documentation is here).
First, to give you a big picture, the main issue I figured out so far is in the
pagy_elasticsearch_rails
method that I use to run and paginate the ElasticSearch query. It overrides thesize
parameter of the query (which, in turn, is used to limit the total number of results returned) when I pass theitems
parameter to it. The reason I need to also useitems
is to limit the number of results per page (this is the right parameter to use with Pagy, according to the documentation).pagy_elasticsearch_rails
drops thesize
parameter that comes from the ElasticSearch query, and placesitems
assize
inside of the query. It limits the results per page number indeed but it also falls back to the default total number of results (which is 10,000).Now, to be more specific, I have the controller file containing the
search
method - it's the starting point for running a search.The first thing that happens here is the
pagy_search
method being called:I am calling
pagy_search
twice because I have two types of results (and two different ElasticSearch queries and indices correspondingly: cars and bikes).pagy_search
method is located in the same file:search_query
variable contains the results of the Elasticsearch call - specifically the elasticsearch.rb file that holds the logic for building the search query itself. That's where I also set up the limit for the total number of results. Here are some of its contents:etc. - I don't think it's worth copy-pasting all the methods as my point here is to show you the structure in general terms. Otherwise, please let me know :)
If we print the result of
pagy_elasticsearch_rails(query_by_type, items: 24)
, we'll get this structure:Inside the
@definition
variable I can see that the size was overwritten::size=>24
, so the value I set in elasticsearch.rb was replaced byitems
value. And it's then being used to limit the number of results per page which I also need.Have you experienced a similar problem before? Do you have any thoughts on how can I navigate around it?
P.S. I am using a pagy version 3.7.0
P.P.S I can confirm that the
size
parameter limits the ElasticSearch results correctly as I verified it in KibanaBeta Was this translation helpful? Give feedback.
All reactions