Query_string multi field multi analyzers howto


(Sebastian Gavarini) #1

Hi all,

I am trying to understand how to implement a query with multiple
analyzers against query_string's parsing. I have seen you can pass
many fields, with boosts for each, to query_string, also you can pass
an analyzer. What I don't know how to do is to pass many analyzers, or
a by-field analyzer, I have seen a FieldNameAnalyzer, but it isn't
explained in the Analyzers documentation, and probably isn't meant to
be used by clients.

My use case consists with say two fields, "title" and "description",
each with different analyzers. "title" uses a compile-time known
analyzer, but "description" depends on the locale (for stop words
removal), so it's only run-time known, and even then, it uses a
different set of token filters and tokenizer (description is a longer
field, a little less important, and so I do less data cooking with
it).

So, how can I let query_string know the analyzers I need for each
field? In my mappings I already added the analyzer for "title", but I
ues the "_analyzer" parameter for indexing time in "description". I
need a way to tell the same thing at search time, to tell "title" with
"analyzer1" and "description" with "analyzer2_en_GB" for example.

I could ignore query_string altogether and do all it's work in
client's code, building the query myself, but I would like to know if
there is a better way.

Thanks,
Sebastian.


(system) #2