Skip to content

Instantly share code, notes, and snippets.

@andreiz
Created October 28, 2010 17:17
Show Gist options
  • Save andreiz/651839 to your computer and use it in GitHub Desktop.
Save andreiz/651839 to your computer and use it in GitHub Desktop.
curl -XDELETE 'http://localhost:9200/foo/'
curl -XPUT 'http://localhost:9200/foo/' -d'{ index : { number_of_shards : 1, number_of_replicas : 1 } }'
curl -XPUT 'http://localhost:9200/foo/place/_mapping' -d'
{
"place" : {
"_all" : {"enabled" : false},
"properties" : {
"user_id" : {"type" : "integer", "index" : "not_analyzed"},
"title" : {"type" : "string", "boost" : 1.5},
"notes" : {"type" : "string"},
"tags" : {"type" : "string", "index_name" : "tag", "boost" : 1.5}
}
}
}'
curl -XPUT http://localhost:9200/foo/place/1 -d'{"user_id": 23, "notes": "Coffee in notes", "tags": ["tag1"], "title": "Place 1"}'
curl -XPUT http://localhost:9200/foo/place/2 -d'{"user_id": 23, "notes": "Notes for place 2", "tags": ["coffee"], "title": "Place 2"}'
curl -XPUT http://localhost:9200/foo/place/3 -d'{"user_id": 23, "notes": "Notes for third place", "tags": ["tag2"], "title": "Coffee place"}'
curl 'http://localhost:9200/foo/_search?pretty=true' -d'
{
"query": {
"query_string": {
"query": "coffee",
"default_field": ["notes", "title"],
"use_dis_max": true
}
}
}'
curl 'http://localhost:9200/foo/_search?pretty=true' -d'
{
"query": {
"query_string": {
"query": "coffee",
"default_field": ["title", "notes"],
"use_dis_max": true
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment