Skip to content

Instantly share code, notes, and snippets.

@brsanthu
Forked from mattweber/failed query (has filter)
Created February 20, 2012 23:51
Show Gist options
  • Save brsanthu/1872375 to your computer and use it in GitHub Desktop.
Save brsanthu/1872375 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