The simplest answer seems to be just run a fuzzy query with the appropriate query syntax, like:
FULL_NAME_ND_RO:india~ AND CC1:in
However, if you need to analyze each field differently, you can do that with a PerFieldAnalyzerWrapper
Based on the comments below:
the default stopword set in StandardAnalyzer includes the word "in", so that search term is eliminated entirely from the query. The stopword set can be overridden via the appropriate StandardAnalyzer
constructor:
StandardAnalyzer(Version.LUCENE_45, new CharArraySet(Version.LUCENE_45, 0, true));
Since the CC1 field is a StringField (and is, thus, not analyzed at index time), it may make sense to be sure it is not analyzed at query time either. While the above fixes the stopword issue, you may yet run into case-related or tokenization issues, for instance. KeywordAnalyzer
is generally appropriate for un-analyzed fields. A PerFieldAnalyzerWrapper
can be passed in to the query parser to apply different analysis rules to different fields.
Something like:
Map<String,Analyzer> analyzerPerField = new HashMap<String,Analyzer>();
analyzerPerField.put("CC1", new KeywordAnalyzer());
PerFieldAnalyzerWrapper aWrapper =
new PerFieldAnalyzerWrapper(geonamesAnalyzer, analyzerPerField);
QueryParser parser = new QueryParser(Version.LUCENE_45, defaultField, aWrapper);