weighted sum of the union results
As #85, #86, union is performed by the array of the conventional queries. The result is also the array of the results corresponding to per query.
Some use case needs combining the results. For example, hybrid recommender system that combines multiple recommendations needs aggregating the score of the union query results.
For this, I'd like to propose the query as follows
{
"queries": [
{
"srcVertices": [
{
"columnName": "user_id_test",
"id": 0,
"serviceName": "s2graph"
}
],
"steps": [
[
{
"direction": "out",
"label": "s2graph_label_test_0",
"offset": 0
}
]
]
},
{
"srcVertices": [
{
"columnName": "user_id_test",
"id": 0,
"serviceName": "s2graph"
}
],
"steps": [
[
{
"direction": "out",
"label": "s2graph_label_test_1",
"offset": 0
}
]
]
}
],
"weights": [
0.6,
0.4
],
"aggregateBy": ["to"]
}
where weight 0.6 and 0.4 are the weights for aggregating by weighted sum respectively.
The results of the above query would have weightedSum which is the weighted sum of the scores whose to(and keys in aggregateBy) is the same.
@emeth-kim: can you give us PR for this? otherwise I will be working on this this weekend. also quick question. do you think only weighted sum need to be supported?? is there any other possible operation you can think of?
@SteamShon
For now, weighted sum seems enough.
It is determined that the union query in the case of the request body is JsArray. This means there no place to put the information of aggregateBy.
I think there are two options,
- adding new terms to query parameters such as
queries,weights, andaggregateBy - using the route that
/graphs/getEdges/grouped- if union query is received by the above route, returns the aggregated result.
I'm going to try to implement it, please give me an advice.