Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2014 16:13
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 anonymous/9414437 to your computer and use it in GitHub Desktop.
Save anonymous/9414437 to your computer and use it in GitHub Desktop.
Elasticsearch and attachment
host="http://localhost:9200"
# Create index
curl -XPUT "$host/docs"
# Define mapping
curl -XPUT "$host/docs/_mapping/doc" -d'
{
"doc": {
"properties": {
"att" : {
"type": "attachment",
"fields": {
"att": {
"index": "analyzed",
"store": "no"
}
}
}
}
}
}'
# Store doc with attachment "hello world"
curl -XPUT "$host/docs/doc/1" -d'
{
"att": "aGVsbG8gd29ybGQ="
}'
# Get doc
curl -XGET "$host/docs/doc/1"
# Received
# ...
# _source: {
# att: "aGVsbG8gd29ybGQ="
# }
# ...
# Expected empty _source
# The same is for e.g. text PDF document - no document metadata is extracted into att field, it always holds the base64-encoded string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment