Mapping an attachment field
Elasticsearch allows extending its core types to cover new requirements with native plugins that provide new mapping types. A most used custom field type is the attachment one.
It allows indexing and searching the contents of common documental files, that is, Microsoft office formats, open document formats, PDF, ePub, and many others.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup with the ingest attachment plugin installed.
It can be installed from the command line with the following command:
bin/elasticsearch-plugin install ingest-attachment
How to do it...
To map a field as attachment, it's required to set the type
to attachment
.
Internally, the attachment field defines the fields
property as a multi-field that takes some binary data (encoded base64) and extracts several useful information such as author
, content
, title
, date
, and so on...