You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Shamik Bandopadhyay <sh...@gmail.com> on 2015/01/22 01:44:28 UTC
Issue with Solr multiple sort
Hi,
I'm facing a problem with multiple field sort in Solr. I'm using the
following fields in sort :
PublishDate asc,DocumentType asc
The sort is only happening on PublishDate, DocumentType seemsto completely
ignored. Here's my field type definition.
<field name="PublishDate" type="tdate" indexed="true" stored="true"
default="NOW"/>
<field name="DocumentType" type="string" indexed="true" stored="true"
multiValued="false" required="false" omitNorms="true"/>
Here's the sample query:
http://localhost:8983/solr/select?sort=PublishDate+desc%2CDocumentType+desc&q=cat:search&fl=PublishDate,DocumentType&debugQuery=true
Here's the output :
<result name="response" numFound="8" start="0">
<doc>
<date name="PublishDate">2015-01-17T00:00:00Z</date>
<str name="DocumentType">Hotfixes</str>
</doc>
<doc>
<date name="PublishDate">2014-11-17T00:00:00Z</date>
<str name="DocumentType">Hotfixes</str>
</doc>
<doc>
<date name="PublishDate">2013-01-17T00:00:00Z</date>
<str name="DocumentType">Tutorials</str>
</doc>
<doc>
<date name="PublishDate">2012-10-17T00:00:00Z</date>
<str name="DocumentType">Service Packs</str>
</doc>
<doc>
<date name="PublishDate">2012-01-17T00:00:00Z</date>
<str name="DocumentType">Tutorials</str>
</doc>
<doc>
<date name="PublishDate">2011-01-17T00:00:00Z</date>
<str name="DocumentType">Tutorials </str>
</doc>
<doc>
<date name="PublishDate">2006-01-17T00:00:00Z</date>
<str name="DocumentType">Object Enablers</str>
</doc>
<doc>
<date name="PublishDate">2006-01-17T00:00:00Z</date>
<str name="DocumentType">Hotfixes</str>
</doc>
</result>
As you can see, the sorting happened only on PublishDate. I'm using Solr
4.7.
Not sure what I'm missing here, any pointers will be appreciated.
Thanks,
Shamik
Re: Issue with Solr multiple sort
Posted by Erick Erickson <er...@gmail.com>.
Shamik:
Nice job of including the relevant information and just the relevant info!
One addition to what Chris said that _may_ be relevant in future. The
"string" type
is totally unanalyzed, so sorting done on that field may be
case-sensitive, leading
to some confusion. If the schema has a "lowercase" type that may be better, it's
just KeywordTokenizerFactory and LowercaseFilterFactory as the analysis chain.
FWIW,
Erick
On Wed, Jan 21, 2015 at 5:25 PM, shamik <sh...@gmail.com> wrote:
> Thanks Hoss for clearing up my doubt. I was confused with the ordering. So I
> guess, the first field is always the primary sort field followed by
> secondary.
>
> Thanks again.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Issue-with-Solr-multiple-sort-tp4181056p4181062.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: Issue with Solr multiple sort
Posted by shamik <sh...@gmail.com>.
Thanks Hoss for clearing up my doubt. I was confused with the ordering. So I
guess, the first field is always the primary sort field followed by
secondary.
Thanks again.
--
View this message in context: http://lucene.472066.n3.nabble.com/Issue-with-Solr-multiple-sort-tp4181056p4181062.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Issue with Solr multiple sort
Posted by Chris Hostetter <ho...@fucit.org>.
: I'm facing a problem with multiple field sort in Solr. I'm using the
: following fields in sort :
:
: PublishDate asc,DocumentType asc
correction: you are using: PublishDate desc,DocumentType desc
: The sort is only happening on PublishDate, DocumentType seemsto completely
: ignored. Here's my field type definition.
the results you posted are perfectly sorted according to the criteria in
your URL...
2015-01-17, 2014-11-17, 2013-01-17, 2012-10-17, 2012-01-17, 2011-01-17,
then 2 docs from 2006-01-17 correctly ordered by secondary sort: "O"
before "H".
...did you not post the query/results you ment to post? what exactly is
it about the result ordering that you are getting do you think is
incorrect?
: <result name="response" numFound="8" start="0">
: <doc>
: <date name="PublishDate">2015-01-17T00:00:00Z</date>
: <str name="DocumentType">Hotfixes</str>
: </doc>
: <doc>
: <date name="PublishDate">2014-11-17T00:00:00Z</date>
: <str name="DocumentType">Hotfixes</str>
: </doc>
: <doc>
: <date name="PublishDate">2013-01-17T00:00:00Z</date>
: <str name="DocumentType">Tutorials</str>
: </doc>
: <doc>
: <date name="PublishDate">2012-10-17T00:00:00Z</date>
: <str name="DocumentType">Service Packs</str>
: </doc>
: <doc>
: <date name="PublishDate">2012-01-17T00:00:00Z</date>
: <str name="DocumentType">Tutorials</str>
: </doc>
: <doc>
: <date name="PublishDate">2011-01-17T00:00:00Z</date>
: <str name="DocumentType">Tutorials </str>
: </doc>
: <doc>
: <date name="PublishDate">2006-01-17T00:00:00Z</date>
: <str name="DocumentType">Object Enablers</str>
: </doc>
: <doc>
: <date name="PublishDate">2006-01-17T00:00:00Z</date>
: <str name="DocumentType">Hotfixes</str>
: </doc>
: </result>
:
: As you can see, the sorting happened only on PublishDate. I'm using Solr
: 4.7.
:
: Not sure what I'm missing here, any pointers will be appreciated.
:
: Thanks,
: Shamik
:
-Hoss
http://www.lucidworks.com/