I'd like to get a query result with two different part,
- query docs with field X and collapse on it.
- query docs without field X
- pagination based on queries above
For example, I have docs:
| docID | Field X |
|---|---|
| 1 | a |
| 2 | a |
| 3 | null |
| 4 | b |
There are 4 docs, doc 1 and 2 have same X value, doc 3 have no value at X, doc 4 have unique value.
So the target docs should be (1 or 2), 3 and 4, and I need to add pagination condition (from + size)here
Is there any way to do this? now I have a collapse query but can only get doc(1 or 2)
GET job_info/_search
{
"_source": false,
"aggregations": {
"total": {
"cardinality": {
"field": "x.keyword"
}
}
},
"collapse": {
"field": "x.keyword"
},
"from": 0,
"query": {
"bool": {
"must": [
{
"terms": {
"other_condition1": [
1101
]
}
},
{
"match": {
"other_condition1": {
"query": "abc"
}
}
}
]
}
},
"size": 10,
"track_total_hits": true
}