Skip to content

Instantly share code, notes, and snippets.

@martijnvg
Created December 12, 2012 10:55
Show Gist options
  • Save martijnvg/4266907 to your computer and use it in GitHub Desktop.
Save martijnvg/4266907 to your computer and use it in GitHub Desktop.
Match query with multiple tokens as query with and without boost.
#!/bin/bash
curl -XDELETE 'http://localhost:9200/status_index'
echo ""
curl -XPUT 'http://localhost:9200/status_index/?pretty=1' -d '{
"mappings" : {
"status" : {
"properties" : {
"id" : {
"type" : "integer"
},
"summary": {
"type": "string",
"analyzer" : "snowball"
},
"msg" : {
"type" : "string",
"analyzer" : "snowball"
}
}
}
}
}'
echo ""
curl -XPOST 'http://localhost:9200/status_index/status?pretty=1' -d '{
"id" : 1,
"summary": "first post",
"msg" : "first status message posted."
}'
echo ""
curl -XPOST 'http://localhost:9200/status_index/status?pretty=1' -d '{
"id" : 2,
"summary": "second post",
"msg" : "second status message posted."
}'
echo ""
curl -XPOST 'http://localhost:9200/status_index/_refresh?pretty=1'
echo ""
curl -XGET 'http://localhost:9200/status_index/_search?pretty' -d '
{
"fields" : [],
"query" : {
"bool" : {
"should" : [
{"text": {
"summary": {
"query": "message posted"
}
}},
{"text": {
"msg": {
"query": "message posted"
}
}}
]
}
},
"explain": true
}
'
echo ""
curl -XGET 'http://localhost:9200/status_index/_search?pretty' -d '
{
"fields" : [],
"query" : {
"bool" : {
"should" : [
{"text": {
"summary": {
"query": "message posted",
"boost": 4.0
}
}},
{"text": {
"msg": {
"query": "message posted",
"boost": 2.0
}
}}
]
}
},
"explain": true
}
'
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment