yakaz/elasticsearch-analysis-combo — pull request #8 by antonha (2013-04-12 17:43:25+00:00)
Title: Fix for the UnsupportedOperationException if running analyser 2 or more times in elasticsearch

Fix for issues #6 and #7.

The problem is that the analyser is not able to run more than once inside elasticsearch.

The issue stems from that analysers specified in elasticsearch are always wrapped in a NamedAnalyser, which inherit from a CustomAnalyzerWrapper, which in turn specifies a PerFieldReuseStrategy.

This is problematic since the ComboAnalyzer assumes that the ReuseStrategy always returns null, thusly modifying the control flow in the Analyzer base class (the tokenStream method).

This fix is forces the plugin to perform the same operation if the ReuseStrategy returns an actual value; instead of throwing on UnsupportedOperationException, it calls the createComponents method.

I am fully aware that the fix is a bit hacky, and it is only tested for a small amount of sequential calls.