Skip to content

Instantly share code, notes, and snippets.

@shairontoledo
Created May 10, 2012 17:14
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 shairontoledo/2654525 to your computer and use it in GitHub Desktop.
Save shairontoledo/2654525 to your computer and use it in GitHub Desktop.
export SERVER=localhost
curl -XPUT --silent "http://$SERVER:9200/documents" -d '
{
"settings" : {
"index" : {
"analysis": {
"analyzer": {
"default": {
"tokenizer": "pattern",
"filter": [
"stop","asciifolding", "standard", "word_delimiter", "lowercase"
]
}
}
}
}
},
"mapping": {
"document":{
"properties" : {
"name" : {
"type" : "string",
"store" : "yes",
"index" : "analyzed",
"term_vector" : "with_positions_offsets"
},
"content" : {
"type" : "string",
"store" : "yes",
"index" : "analyzed",
"term_vector" : "with_positions_offsets"
}
}
}
}
}
'
curl -XPUT --silent "http://$SERVER:9200/documents/document/1?pretty=true" -d '
{
"name": "The Scala Collections API.pdf",
"content": "foo bar baz quux"
}
'
curl -XPUT --silent "http://$SERVER:9200/documents/document/2?pretty=true" -d '
{
"name": "Abstract Members.pdf",
"content": "foo bar baz quux"
}
'
#Success
curl -XGET --silent "http://$SERVER:9200/documents/document/_search?pretty=true&q=name:scala"
##Success
curl -XGET --silent "http://$SERVER:9200/documents/document/_search?pretty=true&q=name:pdf"
#Success
curl -XGET --silent "http://$SERVER:9200/documents/document/_search?pretty=true" -d '
{
"query":{
"query_string":{
"fields": ["name^7","content"],
"query": "scala"
}
}
}
'
#Success
curl -XGET --silent "http://$SERVER:9200/documents/document/_search?pretty=true" -d '
{
"query":{
"query_string":{
"fields": ["name^7","content"],
"query": "pdf"
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment