Java ES对多个索引进行联合查询时,如何实现针对不同索引用不同字段进行排序

业务场景:需要对index1和index2两个索引进行联合查询,其中排序字段field1仅在index1中存在,field2仅在index2中存在,如何对这两个字段进行排序使用。
{
“from”: 0,
“size”: 20,
“query”: {
“bool”: {
“should”: [
{
“bool”: {
“must”: [
{
“terms”: {
“operatetype”: [
“1”,
“2”
],
“boost”: 1.0
}
}
],
“filter”: [
{
“term”: {
“_index”: {
“value”: “asset”,
“boost”: 1.0
}
}
}
],
“adjust_pure_negative”: true,
“boost”: 1.0
}
},
{
“bool”: {
“must”: [
{
“terms”: {
“typeId”: [
4,
5
],
“boost”: 1.0
}
}
],
“filter”: [
{
“term”: {
“_index”: {
“value”: “object”,
“boost”: 1.0
}
}
}
],
“must_not”: [
{
“term”: {
“status”: {
“value”: 1,
“boost”: 1.0
}
}
}
]
}
}
]
}
},
“sort”: [
{
“asset.favoriteCount”: {
“order”: “desc”
}
},
{
“object.visitCount”: {
“order”: “desc”
}
}
]
}

讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!