Limit hit count for a indice?

I have two separate indices A and B. Both indices have same document structure.

Let's say A contains 50 documents and B contains 5 documents. When i search over these indices with limit 20, resultSet should contains 17 documents from A and 3 documents from B which meet searchCriteria. I want to limit document count from B indice . Everytime I search over these indices, it should return 3 documents or not from B indices.

And sorting over these indices should work well.

Is there any possible solution ?

Thank you very much.

How should this work on the second page of the result list (documents 20 - 40)?

For second page it should returns 18 documents from A indice and 2 from B indice. I want to retrieve max 3 documents from B always.

I am not sure how this is going to work with

I think you might need to come up with a more detailed description of how the sorting should work then just "well". There are several corner cases that you would need to figure out here. In any case I think you will have to use msearch to search both indices separately and combine results in your application based on your business logic of selecting records and your definition of correct sorting. Each record has an array of sort keys that were used to sort the records according to your rules.

I search with alias X on indices A and B . I just want to give max_doc_count= 5 for index B .
Search result should contains max 5 documents from index B . If documents from index B do not meet criteria then all result should contains documents from A. I should able to set size for query. Every time i want to retrieve 20 documents.

This functionality is not supported by Elasticsearch, you would need to implement it in your application as I described in my previous comment.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.