I am creating a plugin that analyzes document being indexed and based on
the analysis it adds new fields to it. It is done from a root mapper and it
works similarly as the attachment mapper.
I need to use the root mapper because I need the whole document for
analysis, not individual fields. I also don't have a fixed predefined set
of fields that can be generated.
I'd like to ask what is the correct way of updating the mapping in this
If I don't update the mapping then I'm getting a NPE:
Caused by: java.lang.NullPointerException
That's because there is no FieldMapper for the newly added field.
I can add the field mapper this
way: context.docMapper().addFieldMappers(ImmutableSet.of(field.mapper)) and
then it seems to work. No NPE, no warnings in the log.
However, to create the field mapper, I need a Mapper.BuilderContext, so
that I can do e.g. field.mapper
This seems to be a problem because the BuilderContext is available only
from my root mapper's Builder. I pass the BuilderContext to my root mapper
which then uses it to create the field mappers. But this seems hacky/wrong.
What would be the correct approach? Will the mapping be otherwise updated
somehow by Elasticsearch in this case? Or how exactly should I go about
implementing my root mapper's toXContent() method?
You can see the mapper
(work in progress/playground).
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c3722146-2929-4a3d-b82e-07a54ddef6d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.