lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shivani Sawhney" <shiv...@netedgecomputing.com>
Subject Using Range Queries
Date Wed, 08 Feb 2006 15:20:18 GMT
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

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message