0

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?

rdm
  • 330
  • 1
  • 4
  • 18

1 Answers1

0

The question is about a context for suggester. My answer is about filtering the result as if the suggester would have been build only for a subset of the documents. The lucene-folk calls this filter a context: https://issues.apache.org/jira/browse/LUCENE-6464

Version 5.4 is the first solr version with supported filter on suggesters, but only for BlendedInfixSuggester and AnalyzingInfixSuggester: Make Lucene's AnalyzingInfixSuggester.lookup() method that takes a BooleanQuery filter parameter available in Solr

So at time for all other suggesters you have to build one suggester for each possible filter e.g. by creating a extra field for each filter "field_filtername".

Without extra information I can not see how to solve this problem better.

Possible your context could be used as route for Shard Splitting (and the separation of suggesters per context is already done by SolrCloud).

Possible you don't need a suggester at all and highlighting or facets could solve your original problem.

Karsten R.
  • 1,628
  • 12
  • 14
  • Thanks, that you mean: "So at time for all other suggesters you have to build one suggester for each possible filter e.g. by creating a extra field for each filter "field_filtername". ? – rdm Dec 29 '15 at 11:21
  • Now I made CustomInputIterator, CustomLuceneDictionary, CustomMultiFields for my case. Custom InputIterator contains only filtered terms. My approach requires that the field names contain the type name, eg field "title_typeA", "title_typeB"... – rdm Dec 29 '15 at 13:46