Analyzing queries in the client side of Elasticsearch but not on the server

403 views Asked by At

We are migrating our Lucene based search codebase to Elasticsearch. The major problem we encountered is how we should migrate our QueryParsers.

In our old solution, the QueryParsers take in a human input query string, and transform that to Lucene's Query object, which is then fed into Lucene's IndexSearcher. However, in Elasticsearch we don't directly interact with IndexSearcher, instead we can only build the queries in the client side using Query DSL and send the JSON to Elasticsearch server. Elasticsearch server then (possibly) rewrites/analyses the JSON query to build a Lucene query.

To make use of our existing and sophisticated logic in QueryParsers, we decided that we can stick to our old approach by:

  1. Explicitly tell Elasticsearch to NOT analyze any query in the search time.
  2. Do ALL the query related analysis (tokenizing, synonym, etc) in the Java client.
  3. Believe that Elasticsearch's Query DSL is kind of a one-to-one mapping to Lucene's Query

Don't worry about the scoring process, we are writing our scorer scripts as a Elasticsearch plugin.

The questions are:

  1. Is this approach feasible?
  2. What are the potential problems in doing so?
  3. What is the best practice?

Thanks in advance!

0

There are 0 answers