Created
March 7, 2014 16:13
-
-
Save anonymous/9414437 to your computer and use it in GitHub Desktop.
Elasticsearch and attachment
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
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