Now only AnalyzingInfixSuggester support contexts. All other implementations, such as AnalyzingSuggester, FreeTextSuggester, FuzzySuggester not support contexts. In my task I need to implementing suggester, which search only on terms which are exist in documents that have specific field with a specific value. For example, only terms of field description of the documents in which the field type have value TYPE_A.
Now to solve this problem, I created different iterator for each type, like that:
Map<String, List<String>> mapOfTerms...;
int maxDoc = indexReader.maxDoc();
for (int i = 0; i < maxDoc; i++) {
Document doc = indexReader.document(i);
String type = doc.get("type");
List<String> list = mapOfTerms.get(type);
//... add terms from doc to list
}
//create custom InputIterator for each type list
//create AnalyzingSuggester, AnalyzingInfixSuggester, FreeTextSuggester, FuzzySuggester for each InputIterator
For example, for three types "TYPE_A", "TYPE_B", TYPE_C" I make 12 suggesters. How to solve this problem better?