Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 90562 invoked from network); 20 Dec 2004 17:20:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 20 Dec 2004 17:20:44 -0000 Received: (qmail 72806 invoked by uid 500); 20 Dec 2004 17:07:07 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 72790 invoked by uid 500); 20 Dec 2004 17:07:07 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 72768 invoked by uid 99); 20 Dec 2004 17:07:07 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO,HTML_30_40,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from host-64-65-202-3.pro.choiceone.net (HELO contextmedia.com) (64.65.202.3) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 20 Dec 2004 09:07:03 -0800 Received: from ppeddi ([192.168.1.33]) by contextmedia.com ; Mon, 20 Dec 2004 12:06:56 -0500 Message-ID: <012f01c4e6b6$2eff82f0$aa87a8c0@ppeddi> From: "Praveen Peddi" To: "lucenelist" Subject: sorting on a field that can have null values Date: Mon, 20 Dec 2004 12:06:01 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_012C_01C4E68C.461D9410" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Rcpt-To: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ------=_NextPart_000_012C_01C4E68C.461D9410 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I am getting null pointer exception when I am sorting on a field that = has null value for some documents. "Order by" in sql does work on such = fields and I think it puts all results with null values at the end of = the list. Shouldn't lucene also do the same thing instead of throwing = null pointer exception. Is this an expected behaviour? Is lucene always = expecting some value on the sortable fields? I thought of putting empty strings instead of null values but I think = empty strings are put first in the list while sorting which is the = reverse of what anyone would want.=20 Following is the exception I saw in the error log: java.lang.NullPointerException at = org.apache.lucene.search.SortComparator$1.compare(Lorg.apache.lucene.sear= ch.ScoreDoc;Lorg.apache.lucene.search.ScoreDoc;)I(SortComparator.java:36)= at = org.apache.lucene.search.FieldSortedHitQueue.lessThan(Ljava.lang.Object;L= java.lang.Object;)Z(FieldSortedHitQueue.java:95) at = org.apache.lucene.util.PriorityQueue.upHeap()V(PriorityQueue.java:120) at = org.apache.lucene.util.PriorityQueue.put(Ljava.lang.Object;)V(PriorityQue= ue.java:47) at = org.apache.lucene.util.PriorityQueue.insert(Ljava.lang.Object;)Z(Priority= Queue.java:58) at = org.apache.lucene.search.IndexSearcher$2.collect(IF)V(IndexSearcher.java:= 130) at = org.apache.lucene.search.Scorer.score(Lorg.apache.lucene.search.HitCollec= tor;)V(Scorer.java:38) at = org.apache.lucene.search.IndexSearcher.search(Lorg.apache.lucene.search.Q= uery;Lorg.apache.lucene.search.Filter;ILorg.apache.lucene.search.Sort;)Lo= rg.apache.lucene.search.TopFieldDocs;(IndexSearcher.java:125) at org.apache.lucene.search.Hits.getMoreDocs(I)V(Hits.java:64) at = org.apache.lucene.search.Hits.(Lorg.apache.lucene.search.Searcher;L= org.apache.lucene.search.Query;Lorg.apache.lucene.search.Filter;Lorg.apac= he.lucene.search.Sort;)V(Hits.java:51) at = org.apache.lucene.search.Searcher.search(Lorg.apache.lucene.search.Query;= Lorg.apache.lucene.search.Sort;)Lorg.apache.lucene.search.Hits;(Searcher.= java:41) If its a bug in lucene, Will it be fixed in next release? Any = suggestions would be appreciated. Praveen **************************************************************=20 Praveen Peddi Sr Software Engg, Context Media, Inc.=20 email:ppeddi@contextmedia.com=20 Tel: 401.854.3475=20 Fax: 401.861.3596=20 web: http://www.contextmedia.com=20 **************************************************************=20 Context Media- "The Leader in Enterprise Content Integration"=20 ------=_NextPart_000_012C_01C4E68C.461D9410--