Hi Ian,
thanks for your answer.

On Wed, Nov 2, 2011 at 10:36 AM, Ian Lea <ian....@gmail.com> wrote:

> How many of the different query types would you need to mess around
> with?  TermQuery certainly, as you show, and PhraseQuery presumably
> for "operating system" in your example, but prefix and wildcard etc
> are maybe not relevant.
>

Yes, I was thinking about translating only *TermQuery* and
*PhraseQuery,*at the moment.

The problem is that, while it looks easy to override *newTermQuery* method
in *QueryParser*,
it looks more difficult to handle also *PhraseQueries*, without "copying"
some *QueryParser* code.




> An alternative might be to tackle it one level up, along the lines of
>
> String querystr = ...;
> String deflang = ...;
> BooleanQuery bq = new BooleanQuery();
> QueryParser qp = new QueryParser(,,,, "contents_"+deflang, ...);
> bq.add(qp.parse(querystr), ...);
> for (String lang in allLangs) {
>  if (!lang.equals(deflang)) {
>    QueryParser qp2 = new QueryParser(,,,, "contents_"+lang, ...);
>    bq.add(qp2.parse(translate(querystr, deflang, lang)));
>  }
> }
>


The problem I see with this approach is that I would need to do some
"manual parsing"
in *translate *method to handle *lucene query syntax* *--> +, -, (, ), *and
so on.

I would like to extend *QueryParser* in order to avoid to re-do this job
(that is not a *translate* job, but a *parser* job).

Thanks,
Bye

*Raf*

Reply via email to