In my clusters, I have documents containing, among others, a field created_at which is the date at which they were inserted and a field category which is a string describing the category of the document: its values are in list ["a", "b", "c", ...].
I got two problems:
- I want to rank items by recency (se newer first)
- I also want to prevent documents with the same
categoryto appear near to each other
For problem 1. alone, I would simply use a decay (either among the linear/gauss/exp available) on created_at, setting its parameters, say as in
functions: [
{
gauss: {
created_at : {
"origin": 'now',
"scale": '12h',
"offset": '0s',
"decay": 0.5
}
}
}
]
Problem 2. is particularly severe as for reasons related to the data, many documents with same category get inserted at the same time. For this problem alone, I would use the random_score field in ES to resort results randomly, say as in
functions: [
random_score:
{
seed: 2 // seed: ID of user
}
}
]
What I want though is a query where results are both sorted by recency but also the same category values do not appear clustered. I tried combining them as
functions: [
{
gauss: {
created_at : {
"origin": 'now',
"scale": '12h',
"offset": '0s',
"decay": 0.5
}
}
},
{ random_score:
{ seed: 2 }
},
]
but the results are not really satisfactory on the side of the category.
Is the best I can do playing with the weights of these two functions, or is there a better way to achieve my goal?
Aucun commentaire:
Enregistrer un commentaire