I need something like filter's in servlet containers so that catch arrived request before launching indexing process. When I debugged elastic source code, I found TransportReplicationAction is called and i'd like to have something like that in my plugin. Of course, if there is a way that I can have a custom DefaultIndexingChain in my plugin, it will be very useful.
You can implement your own "index" command in a plugin, with your preferred custom primary shard/replication action management.
Extending the existing indexing action is not possible so you would have to copy/paste much code.
ِDear @jprante many thanks for your reply. Can you refer to a document or snip of code which help me?
@jprante In fact, I am looking for a way so that let me to pass a parameter to my custom Analyzer at indexing time. What is the best solution? This is why I came to the idea that I implement a custom Action. Right now, I implemented my custom Action, But there is tow problems: the first is that I don't know How I can register this Action so that it automatically called for every request for indexing. Secondly, Is this solution is the best way for my problem?
@mahdi_malaki You don't need a custom index operation just for applying a custom analyzer. Custom analyzers can be registered and integrated into ES without hassles.
@jprante I have known that it is easy to integrate a typical analyzer into elastic as a plugin. But my analyzer expect to restive a special parameter from the client as well as indexing data. My problem is that how I can pass this parameter?
When I debug my analyzer, I see that the analyzer just access to field name along with its data. While I need to access a parameter that is attached to request.
@mahdi_malaki can you show an example what you want you achieve? Note that an analyzer can not have access to the indexing., because the phase of analyzing (token stream generation) is happening before, independent of the index machinery (shards, replica, etc.)
@jprante OK, I have a custom analyzer that try to automatically detect the language used in the data field. But sometimes I need to send the client language to the analyzer for indexing along with the document. I can set the language as a separated field in my document which is supposed to be indexed, but the analyzer can't access to the lang field while attempting to index another field.
It looks like you want to implement a custom field type. The phase where you can access the field plus the whole document source is the field mapper, not the analyzer.
Thank @jprante, I handled the problem through registering a TypeParser as you defined in your plugin. It lets me to access to the special filed value before analyzing phase. Then I set the lang field in a thread local variable and try to read in my analyzer. This approach is not ideal but works.