I want to sort some entities(A),each of them is related to another kind of entity(B). Different A has different relation score with B。I want to query A by B and sort them by relation scores。
some samples for A:
{
"name":"aaa",
"bEntitys":{
"b_1": 1,
"b_2": 3,
"b_4": 5
}
}
{
"name":"ccc",
"bEntitys":{
"b_1": 1,
"b_3": 3,
"b_5": 5
}
}
{
"name":"eee",
"bEntitys":{
"b_2": 1,
"b_3": 3,
"b_4": 5,
"b_5": 8,
"b_6": 0,
"b_7": 3
}
}
{
"name":"fff",
"bEntitys":{
"b_1": 1
}
}
At present, I import the bEntitys
field into ES with Object
type and indexed them. so,I can search them with the logic of:(search b_1,for example)
- Filter: field
bEntitys.b_1
is exist. - Sort: get
bEntitys.b_1
's score for sort.
Question is that, every key of bEntitys
will be the field of the current index(json field will be paved). when there is a lot of B,it is going to exceed the maximum limit of index fields.
In addition, may be script
can do this,but Its performance is not good.
Is there any other ways?
Thanks.