1

I have firstname and lastname indexed in apache solr. My requirement is to get the fullname i.e. in the form 'firstname lastname' in autocomplete when a user enters firstname. For this I have indexed another field called fullname which combines firstname and lastname with space in between. I managed to achieve the autocomplete working using search_api_autocomplete module. But heres the problem. Suppose i want 'Christian Bale' in autocomplete suggestion. As i type 'Christian' i get the suggestion properly but when I type space to enter 'Bale' the suggestion goes away. The type of my fullname field is fulltext and for firstname and lastname is String.

I have already tried multiple variations of tokenizers and filters but could not figure it out.

Here is my configuration from schema.xml file,

<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords.txt"
                />
        <filter class="solr.WordDelimiterFilterFactory"
                protected="protwords.txt"
                generateWordParts="0"
                generateNumberParts="0"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                splitOnCaseChange="0"
                preserveOriginal="1"/>
        <filter class="solr.LengthFilterFactory" min="1" max="100" />
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords.txt"
                />
        <filter class="solr.WordDelimiterFilterFactory"
                protected="protwords.txt"
                generateWordParts="0"
                generateNumberParts="0"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                splitOnCaseChange="0"
                preserveOriginal="1"/>
        <filter class="solr.LengthFilterFactory" min="2" max="100" />
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
      <analyzer type="multiterm">
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords.txt"
                />
        <filter class="solr.WordDelimiterFilterFactory"
                protected="protwords.txt"
                generateWordParts="1"
                generateNumberParts="1"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                splitOnCaseChange="1"
                preserveOriginal="1"/>
        <filter class="solr.LengthFilterFactory" min="2" max="100" />
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
    </fieldType>
  • Where's the tokenizer for your `index` analyzer? Are you using this field directly for your auto complete suggestions? How are you querying it in that case? – MatsLindh Oct 18 '19 at 11:16
  • I missed the tokenizer while pasting. I have edited it. I am using fulltext search filter in views for querying. Yes, i am using the fullname field directly for suggestions. – yedhukrishnan pillai Oct 18 '19 at 11:34
  • Also can you tell me why suggestion stops working when i remove LowerCaseFilterFactory? I do not want to index my field in lowercases. – yedhukrishnan pillai Oct 18 '19 at 12:19
  • 2
    Why do you not want to index your field in lowercase? The explanation is that .. that's why it doesn't work. If you don't lowercase your field, `Foo` and `foo` will not be considered equal, so case will have to match. Any reason why you have an explicit multiterm analyzer as well? Simplify your chains as much as possible, then start building out from that. – MatsLindh Oct 18 '19 at 13:58

0 Answers0