Skip to content

Instantly share code, notes, and snippets.

@mattweber
Created February 18, 2012 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mattweber/1860568 to your computer and use it in GitHub Desktop.
Save mattweber/1860568 to your computer and use it in GitHub Desktop.
curl -XGET 'http://localhost:9200/test/_search?pretty=true' -d '{
"query":{
"bool":{
"should": [
{
"constant_score":{
"filter" : {
"query":{
"query_string":{
"query":"findme",
"fields":["keywords"],
"use_dis_max":true
}
}
},
"boost": 1000000
}
},
{
"filtered": {
"query": {
"query_string":{
"query":"findme",
"fields":["title","body","keywords"],
"use_dis_max":true
}
},
"filter": {
"not": {
"type": {
"value": "boosted"
}
}
}
}
}
]
}
}
}'
curl -XGET 'http://localhost:9200/test/_search?pretty=true' -d '{
"query":{
"bool":{
"should": [
{
"constant_score":{
"filter" : {
"query":{
"query_string":{
"query":"findme",
"fields":["keywords"],
"use_dis_max":true
}
}
},
"boost": 1000000
}
}
]
}
}
}'
curl -XGET 'http://localhost:9200/test/_search?pretty=true' -d '{
"query":{
"bool":{
"should": [
{
"filtered": {
"query": {
"query_string":{
"query":"findme",
"fields":["title","body","keywords"],
"use_dis_max":true
}
},
"filter": {
"not": {
"type": {
"value": "boosted"
}
}
}
}
}
]
}
}
}'
curl -XPUT 'http://localhost:9200/test/regular/1' -d '{
"title" : "Regular Doc1",
"body" : "findme"
}'
curl -XPUT 'http://localhost:9200/test/regular/2' -d '{
"title" : "Regular Doc2",
"body" : "findme"
}'
curl -XPUT 'http://localhost:9200/test/boosted/3' -d '{
"title" : "Boosted Doc1",
"body" : "dont find me",
"keywords" : ["findme","findme2"]
}'
curl -XGET 'http://localhost:9200/test/_search?pretty=true' -d '{
"query":{
"bool":{
"should": [
{
"constant_score":{
"query":{
"query_string":{
"query":"findme",
"fields":["keywords"],
"use_dis_max":true
}
},
"boost": 1000000
}
},
{
"filtered": {
"query": {
"query_string":{
"query":"findme",
"fields":["title","body","keywords"],
"use_dis_max":true
}
},
"filter": {
"not": {
"type": {
"value": "boosted"
}
}
}
}
}
]
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment