I had the same problem, but never found a good solution. The best
solution is to have a more dynamic way of determining which analyzer to
return, such as having some kind of conditional expression evalution in
the fieldType/analyzer element, where either the document or the query
request could be used as the comparison object.
<fieldtype type="textMultiLingual" class="solr.TextField">
<analyzer type="query" expression="request.lang == 'EN'">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
</fieldtype>
Analyzers could still be cached by adding the expression to the cache key.
Unfortunately I have switched jobs, so I don't have the time or
motivation to do this, but it should be a very useful addition.
- Thom
Wu, Daniel wrote:
Hi,
I know this probably has been asked before, but I was not able to find
it in the mailing list. So forgive me if I repeated the same question.
We are trying to build a search application to support multiple
languages. Users can potentially query with any language. First
thought come to us is to index the text of all languages in the same
field using language specific analyzer. As all the data are indexed in
the same field, it would just find results with the language that
matches the user query.
Looking at the Solr schema, it seems each field can have one and only
analyzer. Is it possible to have multiple analyzers for the same field?
Or is there any other approaches that can achieve the same thing?
Daniel