Hi, I am new to Elastic search and trying to retrieve documents across the document types stored in the same index. However what i really need to find is there a way to apply the fetch limit on each type instead of the entire resultset.
For example
I have an index with name my_index having two document types doc1 and doc2. Doc1 is a kind of big document having more fields and doc2 is kind of small document having very few fields. Now i would to query all document matching a criteria and among the results fetched, i would like to see maximum 5 documents of type doc1 and 10 documents of type doc2
The below one fetches only 15 rows overall , i may end up having 15 doc1 or 15 doc2 which i dont want to .
GET /my-index/_search
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"_all"
],
"query": "test"
}
}
]
}
},
"from": 0,
"size": 15
}
Looking for something like
GET /my-index/_search
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"_all"
],
"query": "test",
"type": [ {
"type":"doc1"
"from" : 0
"size":5
},
{
type":"doc2"
"from" : 0
"size":10
}
]
}
}
}
]
}
},
}