In this post I will combine the popularity of a document with the most searched terms in order to boost the results based on past search issued against a particular index.
PUT blogposts
PUT statistics
PUT /blogposts/post/1
{
"title": "About popularity",
"content": "In this post we will talk about...",
"votes": 6
}
PUT /blogposts/post/2
{
"title": "About elasticsearch",
"content": "In this post we will talk about...",
"votes": 3
}
PUT /blogposts/post/3
{
"title": "About popularity",
"content": "In this post we will talk about...",
"votes": 7
}
PUT /statistics/queries/1
{
"user_query": "popularity"
}
PUT /statistics/queries/2
{
"user_query": "popularity in elasticsearch"
}
PUT /statistics/queries/3
{
"user_query": "boost"
}
PUT /statistics/queries/4
{
"user_query": "boost in elasticsearch"
}
PUT /statistics/queries/5
{
"user_query": "elasticsearch is the best search engine"
}
GET blogposts/post/_mapping
GET statistics/queries/_mapping
POST statistics/queries/_search
{
"query" : {
"match_all" : {}
},
"facets": {
"keywords": {
"terms": {
"field": "user_query"
}
}
}
}
POST blogposts/post/_search
{
"sort" : [
{ "votes" : {"order" : "desc"}},
"_score"
],
"query" : {
"match" : {
"title":{
"query":"elasticsearch popularity"
}
}
}
}
Nenhum comentário:
Postar um comentário