0

I have the Solr XML response below using this query: http://localhost:8983/solr/trl/select/?indent=off&facet=false&wt=xml&fl=title,overallscore,service,reviewdate&q=:&fq=id:315&start=0&rows=4&sort=reviewdate%20desc

I want to add paging on the multivalued fields, but the above query throws the error can not sort on multivalued field: reviewdate

How can I add paging (or put differenly select only a subset of the response based on a filter on a multivalued field)? In my case with a pagesize of 4 and total results of 18 that would result in 5 pages.

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">0</int>
      <lst name="params">
         <str name="facet">true</str>
         <str name="fl">reviewtitle,overallscore,service,reviewdate,rating</str>
         <str name="facet.mincount">1</str>
         <str name="indent">on</str>
         <str name="q">*:*</str>
         <str name="fq">id:315</str>
      </lst>
   </lst>
   <result name="response" numFound="1" start="0">
      <doc>
         <float name="rating">8.78</float>
         <arr name="service">
            <int>8</int>
            <int>10</int>
            <int>10</int>
            <int>10</int>
            <int>5</int>
            <int>8</int>
            <int>9</int>
            <int>10</int>
            <int>10</int>
            <int>10</int>
            <int>10</int>
            <int>9</int>
            <int>9</int>
            <int>9</int>
            <int>9</int>
            <int>6</int>
            <int>1</int>
            <int>10</int>
         </arr>
         <arr name="overallscore">
            <int>8</int>
            <int>10</int>
            <int>10</int>
            <int>10</int>
            <int>8</int>
            <int>8</int>
            <int>9</int>
            <int>10</int>
            <int>9</int>
            <int>10</int>
            <int>10</int>
            <int>9</int>
            <int>10</int>
            <int>9</int>
            <int>9</int>
            <int>8</int>
            <int>1</int>
            <int>10</int>
         </arr>
         <arr name="reviewdate">
            <date>2014-11-26T17:18:50.367Z</date>
            <date>2014-10-10T16:54:07.397Z</date>
            <date>2014-08-18T14:21:17.807Z</date>
            <date>2014-08-17T00:20:41.877Z</date>
            <date>2014-08-14T15:30:44.963Z</date>
            <date>2014-08-14T15:23:36.29Z</date>
            <date>2014-08-13T16:25:38.327Z</date>
            <date>2014-08-13T13:54:47.847Z</date>
            <date>2014-08-13T13:20:20.753Z</date>
            <date>2014-06-16T23:29:37.093Z</date>
            <date>2012-11-23T21:54:07.897Z</date>
            <date>2012-11-21T17:40:01.11Z</date>
            <date>2012-11-17T01:58:53.15Z</date>
            <date>2012-11-14T02:17:30.677Z</date>
            <date>2012-11-13T23:22:14.613Z</date>
            <date>2012-11-13T19:09:25.563Z</date>
            <date>2012-08-01T18:09:33.243Z</date>
            <date>2012-07-09T20:37:39.837Z</date>
         </arr>

      </doc>
   </result>
   <lst name="facet_counts">
      <lst name="facet_queries" />
      <lst name="facet_fields" />
      <lst name="facet_dates" />
      <lst name="facet_ranges" />
   </lst>
</response>
Adam
  • 6,041
  • 36
  • 120
  • 208
  • It doesn't make sense to sort on a multi-valued field. What is the expected sort order? It may make sense to use either the MAX or MIN value (or any other aggregate like number of values) of a multi-valued field and then sort on that. You need to index a new field for this and then sort on it. – arun Jan 20 '15 at 19:14
  • My response shows the values for the reviews for a single company (or document in Solr). However, it now always returns ALL reviews whereas I want to be able to return a subset of those reviews (sorted on reviewdate desc) to be able to page through the results. Is that requirement clear? – Adam Jan 20 '15 at 19:35
  • I don't think you can do what you want with multi-valued fields. An easier approach would be to store each review as a separate document, along with the company ID. Then you can sort on `reviewdate` DESC and paginate for a given company ID. (Average rating for the company has to come from elsewhere.) – arun Jan 20 '15 at 20:05

0 Answers0