Created
May 10, 2012 17:14
-
-
Save shairontoledo/2654525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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