How to add custom fields uppon indexing


hey there,
I'm new to elasticsearch (Awesome product by the way :slight_smile: )

I am using the FS river plugin to index files on a filesystem.

I want to add customs fields inferred from other fields of the indexed file.

Let me illustrate this by an example :
Suppose we index a file named test.pdf.
FS river will create a document with a _source field containing a field named filename.
I'd like to add a new field named type (to _source or whatever) that will use the filename to determine the filetype (using the extension)

So at the end, the returned document would have a filename field (test.pdf) and a type field (pdf) infered from the filename.

I can already do this on query with the scripts_fields but this mean an overhead on every request. Is there a way to transfert that logic on indexing ?

Thanks in advance,


P.S: I know rivers are now deprecated, I just want to index a filesystem. What are the alternatives in the new version of elasticsearch. The documentation isn't really explicit about indexing a filesystem.

(Magnus Bรคck) #2

You should into using Logstash. It's not deprecated and it's easy to add fields based on the values of existing fields.

(system) #3