Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 7499 invoked from network); 4 Oct 2010 20:21:24 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Oct 2010 20:21:24 -0000 Received: (qmail 17864 invoked by uid 500); 4 Oct 2010 20:21:22 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 17708 invoked by uid 500); 4 Oct 2010 20:21:21 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 17700 invoked by uid 99); 4 Oct 2010 20:21:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 20:21:21 +0000 X-ASF-Spam-Status: No, hits=2.9 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.160.48] (HELO mail-pw0-f48.google.com) (209.85.160.48) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 20:21:15 +0000 Received: by pwj8 with SMTP id 8so2013062pwj.35 for ; Mon, 04 Oct 2010 13:20:54 -0700 (PDT) Received: by 10.114.89.11 with SMTP id m11mr12279843wab.69.1286223653991; Mon, 04 Oct 2010 13:20:53 -0700 (PDT) Received: from [10.0.1.90] (203-114-161-15.wir.sta.inspire.net.nz [203.114.161.15]) by mx.google.com with ESMTPS id 33sm9978058wad.6.2010.10.04.13.20.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 04 Oct 2010 13:20:52 -0700 (PDT) Subject: RE: Numeric range query not returning results From: Todd Nine Reply-To: todd@spidertracks.co.nz To: Uwe Schindler Cc: java-user@lucene.apache.org In-Reply-To: <003b01cb6388$c8979330$59c6b990$@thetaphi.de> References: <1286165587.15807.7.camel@greenlantern.local> <003b01cb6388$c8979330$59c6b990$@thetaphi.de> Content-Type: multipart/alternative; boundary="=-wFuuBvYKRQs9j6osHihU" Organization: Spidertracks Date: Tue, 05 Oct 2010 09:20:17 +1300 Message-ID: <1286223617.15807.41.camel@greenlantern.local> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 --=-wFuuBvYKRQs9j6osHihU Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Hi Uwe, My example wasn't very clear, as I have a load of other code in my actual implementation and I was trying to cut it down for clarity. This is actually my indexing service for my Datanucleus Cassandra plugin, so I have a 1 to 1 relationship where a single document corresponds to a Persistent object. I actually create 5 separate documents, and I would expect 3 of those to be returned. I've ported your entire set of tests for 32 and 64 bit numeric range tests over, and it unfortunately appears that Lucandra is still very broken in terms of numeric ranges even after the Cassandra encoding fix for the 7bit shift into UTF 8 characters. I'll hopefully be able to solve the bugs in the next few days. Thanks again for your help, it's always appreciated. Todd On Mon, 2010-10-04 at 07:55 +0200, Uwe Schindler wrote: > This test works perfectly and returns 1 doucment: > > > > public void testToddNine() throws Exception { > > RAMDirectory directory = new RAMDirectory(); > > IndexWriter writer = new IndexWriter(directory, new > WhitespaceAnalyzer(), true, MaxFieldLength.UNLIMITED); > > try { > > Document doc = new Document(); > > doc.add(new > NumericField("LastLogin").setLongValue(1282197146L)); > > writer.addDocument(doc); > > doc = new Document(); > > doc.add(new > NumericField("LastLogin").setLongValue(1282197946L)); > > writer.addDocument(doc); > > } finally { > > writer.close(); > > } > > > > NumericRangeQuery rangeQuery = > > NumericRangeQuery.newLongRange("LastLogin", 1282197146L, > 1282197146L, true, true); > > > > IndexReader reader = IndexReader.open(directory, true); > > try { > > IndexSearcher searcher = new IndexSearcher(reader); > > TopDocs docs = searcher.search(rangeQuery, 1000); > > assertEquals(1,docs.totalHits); > > } finally { > > reader.close(); > > } > > } > > > > Maybe you have the following problems: > > - Are you executing the same query than created. In your > example code the searcher executed “query” but the range query was > “rangeQuery” variable name > > - Are you sure that your document is not returned, but you > miss some stored fields? E.g. the default NumericField ctor does not > create the field as “stored” to the document? > > > > public NumericField(String name) > > Creates a field for numeric values using the default precisionStep > NumericUtils.PRECISION_STEP_DEFAULT (4). The instance is not yet > initialized with a numeric value, before indexing a document > containing this field, set a value using the various set???Value() > methods. This constructor creates an indexed, but not stored field. > > > > Uwe > > > > ----- > > Uwe Schindler > > H.-H.-Meier-Allee 63, D-28213 Bremen > > http://www.thetaphi.de > > eMail: uwe@thetaphi.de > > > > > > > -----Original Message----- > > > From: Todd Nine [mailto:todd@spidertracks.co.nz] > > > Sent: Monday, October 04, 2010 6:13 AM > > > To: java-user@lucene.apache.org > > > Subject: Numeric range query not returning results > > > > > > Hi all, > > > I'm having some issues with Numeric Range queries not working as > expected. > > > My underlying storage medium is the Lucandra index reader and > writer, so I'm > > > not sure if this is an issue within Lucandra or with my usage of > numeric field. > > > My numeric range tests that are copies of Uwe's pass in the > Lucandra, source, > > > so I have a feeling it's my usage. I have a simple test case, with > 5 people. I > > > have a Date field, the LastLogin field. This date is converted to > epoch > > > milliseconds, and stored in the index in the following way. > > > > > > NumericField numeric = new NumericField("LastLogin"); > > > numeric.setLongValue(fieldValue); doc.add(numeric); > > > > > > Where I have the following 2 field values on 2 documents. > > > > > > 1282197146L and 1282197946L > > > > > > I then perform the following query. > > > > > > NumericRangeQuery rangeQuery = > > > NumericRangeQuery.newLongRange("LastLogin", 1282197146L, > 1282197146L, > > > true, true); > > > > > > IndexReader reader = new IndexReader(columnFamily, > > > > getContext(conn)); > > > > IndexSearcher searcher = new > > > IndexSearcher(reader); > > > > > > TopDocs > docs = searcher.search(query, > > > maxResults); > > > > > > > List documents = new > > > ArrayList( > > > > docs.totalHits); > > > > > > > Set fields = new HashSet(); > > > > fields.add(IndexDocument.ROWKEY); > > > > fields.add(IndexDocument.IDSERIALIZED); > > > > > > > SetBasedFieldSelector selector = new > > > SetBasedFieldSelector( > > > > fields, null); > > > > > > for > (ScoreDoc score : docs.scoreDocs) { > > > > > > documents.add(reader.document(score.doc, selector)); > > > } > > > > > > return > documents; > > > > > > I'm always getting 0 documents. I know this is incorrect, I can see > the values > > > getting written to Cassandra when I run it in debug mode. Is this > an issue with > > > precision step, or an issue with the Lucandra index reader > implementation? > > > > > > Thanks, > > > Todd > > --=-wFuuBvYKRQs9j6osHihU--