Skip to content

Instantly share code, notes, and snippets.

@MaxPleaner
Created February 17, 2017 23:25
Show Gist options
  • Save MaxPleaner/aa1bf7d722f58ca5bf958578a5019526 to your computer and use it in GitHub Desktop.
Save MaxPleaner/aa1bf7d722f58ca5bf958578a5019526 to your computer and use it in GitHub Desktop.
codementor gist
def search(term)
@client.search({
index: "trends",
type: "trend",
body: {
suggest: {
name_suggest: {
prefix: term,
completion: {
field: "name_suggest"
}
}
}
}
})
end
@lekansogunle
Copy link

Can you try implementing boost as follows.

/_search
{
"query": {
"function_score": {
"query": { "match_all": {} },
"boost": "5",
"random_score": {},
"boost_mode":"multiply"
}
}
}

Like in your use case;

def search(term)
@client.search({
index: "trends",
type: "trend",
body: {
suggest: {
name_suggest: {
prefix: term,
completion: {
field: "name_suggest",
"function_score": {
"query": { "match_all": {} },
"boost": "5",
"random_score": {},
"boost_mode":"multiply"
}
}
}
}
}
})
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment