> I guess is that somehow the code is not taking my range as numerals but is > probably doing string compare.
Right. We should treat fields as strings. Use "00" to "20" instead of 0 to 20. When doing this, the term values which are indexed should be "00", "01", ... Thanks, Koji > -----Original Message----- > From: Shivani Sawhney [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 09, 2006 12:20 AM > To: java-user@lucene.apache.org > Subject: Using Range Queries > > > Hi, > > > > I am trying to search across some documents and have min and max > experience, > min and max ctc and email as some of the search fields. I have > problem using > the Range Query. > > The problem is as follows. If I am trying to search for documents with exp > between 0 to 9, I get 15 hits, assuming that all 15 documents are with exp > between 3 and 8, but if I change my range to 0 to 20, I do not get any > results. Seems odd to me.anything between 0 to 9 is also between 0 to 20. > > Now, if I change my range to 0 to 90, I get all 15 records again. > > > > I guess is that somehow the code is not taking my range as numerals but is > probably doing string compare. > > > > The code snipped is listed below. > > > > > > Any help will be much appreciated. > > > > Thanks in advance. > > > > > > > > BooleanQuery documentSearchQuery = new BooleanQuery(); > > . > > > > if (minExperience >= 0 && maxExperience >= 0) > > { > > queryExperience = new RangeQuery(new > Term(IndexerColumns.experience, String.valueOf(minExperience)), new Term( > > IndexerColumns.experience, > String.valueOf(maxExperience)), true); > > > > documentSearchQuery.add(queryExperience, true, false); > > } > > > > if (minCtc >= 0 && maxCtc >= 0) > > { > > queryCtc = new RangeQuery(new Term(IndexerColumns.ctc, > String.valueOf(minCtc)), new Term(IndexerColumns.ctc, > > String.valueOf(maxCtc)), true); > > > > documentSearchQuery.add(queryCtc, true, false); > > } > > > > if (emailId != null && !emailId.trim().equals("")) > > { > > > > try > > { > > queryEmailId = > QueryParser.parse(getQueryString(criteriaForTermFields, emailId), > > IndexerColumns.emailId, new > StandardAnalyzer()); > > } catch (ParseException e2) > > { > > e2.printStackTrace(); > > } > > > > documentSearchQuery.add(queryEmailId, true, false); > > > > } > > > > > > Hits hits = null; > > try > > { > > hits = indexsearcher.search(documentSearchQuery); > > } catch (IOException e3) > > { > > e3.printStackTrace(); > > throw new Error("Exception in search().." + > e3.getMessage()); > > } > > > > > > > > > > Regards, > > Shivani > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]