Skip to content

Instantly share code, notes, and snippets.

@stevepm
Created May 31, 2014 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevepm/8f6915b73fd2042fbbbe to your computer and use it in GitHub Desktop.
Save stevepm/8f6915b73fd2042fbbbe to your computer and use it in GitHub Desktop.
search query
{
from: 0,
size: 150,
query: {
filtered: {
query: {
bool: {
should: [
function_score: {
query: {
multi_match: {
query: query,
fields: ['name^3', 'description']
}
},
functions: [
script_score: {
script: "_score * doc['total_downloads'].value / 2**3.1"
}
],
score_mode: "sum"
}
]
}
},
filter: {
range: {
total_downloads: {
from: 1000
}
}
}
}
}
}
@ferhatsb
Copy link

Hmm you can also try like;

{

"from": 0,
"size": 100,
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"function_score": {
"query": {
"multi_match": {
"query": "rails",
"fields": [
"name^3",
"description"
]
}
},
"functions": [
{
"script_score": {
"script": "_score * doc['total_downloads'].value / 2**3.1"
}
}
],
"score_mode": "sum"
}
}
]
}
}
}
},
"filter": {
"range": {
"total_downloads": {
"gt": 1000
}
}
}
}

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