Thanks Yonik,

I was using example schema.xml, in that alphaOnlySort FieldType contains
following analyzer.

<fieldType name="alphaOnlySort" class="solr.TextField"
sortMissingLast="true" omitNorms="true">
      <analyzer>
        <!-- KeywordTokenizer does no actual tokenizing, so the entire
             input string is preserved as a single token
          -->
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <!-- The LowerCase TokenFilter does what you expect, which can be
             when you want your sorting to be case insensitive
          -->
        <filter class="solr.LowerCaseFilterFactory" />
        <!-- The TrimFilter removes any leading or trailing whitespace -->
        <filter class="solr.TrimFilterFactory" />
        <!-- The PatternReplaceFilter gives you the flexibility to use
             Java Regular expression to replace any sequence of characters
             matching a pattern with an arbitrary replacement string,
             which may include back refrences to portions of the orriginal
             string matched by the pattern.

             See the Java Regular Expression documentation for more
             infomation on pattern and replacement string syntax.


http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
          -->
        <filter class="solr.PatternReplaceFilterFactory"
                pattern="([^a-z])" replacement="" replace="all"
        />
      </analyzer>
    </fieldType>

Due to last filter class, I could not sort any field other than alphabets.
I removed that, it is perfectly working as we expect.

Thank you very much for your support.
-kmu


On Feb 15, 2008 11:49 PM, Yonik Seeley <[EMAIL PROTECTED]> wrote:

> On Fri, Feb 15, 2008 at 3:36 AM, Mahesh Udupa <[EMAIL PROTECTED]>
> wrote:
> > Thanks Yonik,
> >
> >  It works fine. But sort is *case sensitive. *
> >  And also,
> >  If my String contains some white space(or - or any other special char)
> then
> >  failed to sort, with following error.
> >
> >  INFO: /select/ version=2.2&rows=20&fl=rcid
> ,status,categoryid,cmprice_value,cmprice_model,cmprice_noofdays,cmprice_nooftimes,cmprice_freqocc,cmprice_startdate,cmprice_enddate,title,devname,category,cmprice,shortdesc,ctype,score&start=0&q=%2Bstatus:published+%2Bplanid:1;title+asc
> >  0 4
> >  Feb 15, 2008 1:40:47 PM org.apache.solr.core.SolrException log
> >  SEVERE: java.lang.RuntimeException: there are more terms than documents
> in
> >  field "title", but it's impossible to sort on tokenized fields
> >
> >  I have used title as follows
> >  <copyField source="title" dest="title_exact"/>
> >  <field name="title_exact" type="string" indexed="true" stored="true"/>
> >
> >  So how can I make sure that sort is case in-sensitive, works for
> special
> >  chars and numeric fields?
>
> Make a custom fieldType, starting with the TextField type and
> specifying the analyzer to use a keyword tokenizer followed by a
> lowercase filter.  The do the copyField (as you have done above).
> Then actually sort by the title_exact field (your example query shows
> you still sorting by "title").
>
> You probably want to use a separate sort parameter:  sort=text_exact desc
>
> -Yonik
>

Reply via email to