0
votes

I have a field-name called "customer" contains the following values,

  1. Brooks Sports
  2. AM-Records
  3. 1elememt
  4. ALTAVISTA
  5. Adidas
  6. 3gdata
  7. Apple
  8. BMW
  9. 7eleven
  10. bic corporation

    customer field in solr schema.xml

    <field docValues="true" indexed="true" multiValued="false" name="customer" stored="true" type="TextField"/>
    

I need to perform case-insensitive sort on above customer values. so i can get the data as follow,

  1. 1elememt
  2. 3gdata
  3. 7eleven
  4. Adidas
  5. ALTAVISTA
  6. AM-Records
  7. Apple
  8. bic corporation
  9. BMW
  10. Brooks Sports

for this i create a new copyField named "customer_sort" field in scheme.xml

        <field docValues="true" indexed="true" multiValued="false" name="customer_sort" stored="false" type="LowerTextField"/>

fieldType in scheme.xml

        <fieldType name="LowerTextField" class="solr.TextField" sortMissingLast="true" positionIncrementGap="1000">
        <analyzer type="index">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>

        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>

copyfield in scheme.xml

<copyField source="customer" dest="customer_sort"/>

currently the sort result is

  1. 1elememt
  2. 3gdata
  3. 7eleven
  4. ALTAVISTA
  5. AM-Records
  6. Adidas
  7. Apple
  8. BMW
  9. Brooks Sports
  10. bic corporation

sort happening based on ascii value. i.e.(A then a, B then b,...).

Same happen when i tried alphaOnlySort.

Can anybody please tell me what i'm missing?

Thanks

2
What does your sort query look like? What does the analysis page for the field show when indexing values? If the tokens aren't being lowercased, the sort won't work - and you'll have to reindex after adding the copyField definition. There is no need to give separate index and query chains if they're identical.MatsLindh
@MatsLindh i checked the scheme_builder for the "customer_sort" copyfield. all the indexing is happened in lowercase.dhanayan manoharan
@MatsLindh Please take a look on the attached images, fo rmy solrquery and scheme_browser for customer_sort.dhanayan manoharan
Did you reindex after changing the definition? What does the analysis page (not analyzer) show for index/query values?MatsLindh

2 Answers

0
votes
0
votes

Can you use this in schema.xml and also you have mentioned type="TextField". I would like to know about that.

<fieldType name="LowerTextField" class="solr.TextField" sortMissingLast="true" positionIncrementGap="1000">
<analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>