After Integrating our existing Hibernate Search application with ElasticSearch,
we are getting the following exception upon querying from created indexes :
Cannot cast org.hibernate.search.elasticsearch.analyzer.impl.ScopedElasticsearchAnalyzerReference to org.hibernate.search.analyzer.impl.LuceneAnalyzerReference
The indexes were created successfully on ElasticSearch server.
But when we try to query the indexes using the analyzer we get the above exception.
The query is:
Thank you for your feedback. The error message is confusing; I will change it and document the limitation.
An explanation of what is happening: you are trying to get an instance of org.apache.lucene.analysis.Analyzer, which is a Lucene-specific type, while using the Elasticsearch integration, which basically just manipulates JSON and delegates most of the operations (including analyzers) to a remote server across the network.
This cannot be done; there is no Analyzer instance in your application when you use the Elasticsearch application, and there never will be.
Now about a solution... I see you only need the analyzer to use MultiFieldQueryParser in order to parse a query string. If that string is provided by your users, you may want to use "simple query string" queries. They provide more or less the same feature as MultiFieldQueryParser, but on the contrary to MultiFieldQueryParser they can be used in the Elasticsearch backend.
In your case you will have to do something like this:
If you need to run multiple queries, you should do this multiple times and combine the query objects using a boolean junction: see "Combining queries" in the documentation.
The code in my previous message was wrong (there were remnants of the code I based my example on). I edited my message.
Fixed by improving the error message and documenting the limitation in the javadoc.