1

I have five field in solr document .

 startDate---> Date type
 endDate----> Date type
 name -----> string type
 location ----> string type
 publishDate ----> Date type

Now I want to sort this doc in this order

  1. first i want to on the base of startDate
  2. if startdate is same then endate
  3. if start and end date is same then name
  4. if start,end,name are same then location and so on....

I am using solrj api and for this i am using

          solrQuery.setSort("startdate", SolrQuery.ORDER.asc)
            solrQuery.addSort("enddate", SolrQuery.ORDER.asc)
            solrQuery.addSort("name", SolrQuery.ORDER.asc)
            solrQuery.addSort("location", SolrQuery.ORDER.asc)
            solrQuery.addSort("publish_date", SolrQuery.ORDER.asc) 

But it is not working pls help

       schema.xml:
        <field name="startdate" type="tdate" 
        indexed="true" stored="true"/>
        <field name="enddate" type="tdate" indexed="true" stored="true"/>
        <field name="publish_date" type="tdate" indexed="true" 
        stored="true"/>
        <field name="location" type="text_general_edge_nGram" 
        indexed="true" stored="true"/>

        <fieldType name="tdate" class="solr.TrieDateField" 
        precisionStep="6" positionIncrementGap="0"/>
         <fieldType name="text_general_edge_nGram" class="solr.TextField" 
         positionIncrementGap="100">
                <analyzer type="index">
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" 
            words="stopwords.txt" />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" 
             maxGramSize="30" side="front"    luceneMatchVersion="4.3"/>

              </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>
            </fieldType>
YoungHobbit
  • 13,254
  • 9
  • 50
  • 73
rahul
  • 11
  • 5

1 Answers1

2

I think it comes from your tokenizer, that produce a multiple valued field. Unless you use an analyzer that produces a single term you wont be able to sort on that field.

https://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters

http://atpatil.blogspot.fr/2014/07/Solr-sort-strings.html

difference between StandardTokenizerFactory and KeywordTokenizerFactory in SoLR

Community
  • 1
  • 1
Erwan C.
  • 709
  • 5
  • 18
  • sorry but i did not get you. What do you want to say. – rahul Oct 12 '15 at 08:24
  • If in "text_general_edge_nGram" field you have for exemple "John Doe". It ll be tokenized as "John" and "Doe". How can Solr know if he has to sort on "John" or on "Doe" ? For more explainations, just read the links i posted in my answer... – Erwan C. Oct 12 '15 at 08:29