Query with calculated limit


(Eziz Eliyar) #1

I have video model and album model, Like,

| video | title     | album_id |
| ----- | --------- | -------- |
| 1     | apple A 1 | 1        |
| 2     | apple A 2 | 1        |
| 3     | apple A 3 | 1        |
| 4     | apple A 4 | 1        |
| 5     | apple A 5 | 1        |
| 6     | apple B 6 | 2        |
| 7     | apple B 7 | 2        |
| 8     | apple B 8 | 2        |
| 9     | apple B 9 | 2        |

Now I have to query videos with a limit that I should return at most 2 videos for each album. Like when I search apple, I need to get [apple A 1, Apple A 2, Apple B 6, Apple B 7]. Is there any way to do this?


(Xavier Facq) #2

Hi, I don't it is possible, but instead you can use the multi-search:

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html

bye
Xavier


(system) #3

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