Created
May 21, 2014 04:52
-
-
Save anonymous/0e75d85d3a8e97c95f63 to your computer and use it in GitHub Desktop.
Mapper Attachment Elasticsearch
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
#!/bin/sh | |
host=http://localhost:9200 | |
curl -X DELETE "${host}/test" | |
curl -X PUT "${host}/test" -d '{ | |
"settings" : { "index" : { "number_of_shards" : 1, "number_of_replicas" : 0 }} | |
}' | |
curl -X PUT "${host}/test/stories/_mapping" -d '{ | |
"stories" : { | |
"properties" : { | |
"story_name" : {"type" : "string"}, | |
"files":{ | |
"type":"nested", | |
"path":"full", | |
"include_in_root":"true", | |
"properties" : { | |
"file" : { | |
"type" : "attachment", | |
"fields" : { | |
"title" : { "store" : "yes" }, | |
"file" : { "term_vector":"with_positions_offsets", "store":"yes" } | |
} | |
} | |
} | |
} | |
} | |
} | |
}' | |
curl -X POST "${host}/test/stories/" -d '{"story_name":"Story 2", "files" :[{"file" : "d29ybGQgaXMgYmVhdXRpZnVs"},{"file":"d29ybGQ="}]}' | |
echo | |
curl -XPOST "${host}/_refresh" | |
curl "${host}/test/stories/_search?pretty=true" -d '{ | |
"fields" : ["story_name", "files.file"], | |
"query" : { | |
"query_string" : { | |
"query" : "world" | |
} | |
}, | |
"highlight" : { | |
"fields" : { | |
"files.file" : {} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment