lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G.Long" <jde...@gmail.com>
Subject Re: how to create a range query with string parameters
Date Tue, 17 May 2011 14:41:09 GMT
Hi Uwe :)

Thank you for your answer ! Now I have another problem. Here is the code 
I use to query the index :

ScoreDoc[] hits = null;
         TopFieldCollector collector = TopFieldCollector.create(new 
Sort(SortField.FIELD_DOC), 200000, true, false, false, false);
         Directory directory = FSDirectory.open(new 
File("/home/user/index"));

         IndexSearcher isearcher = new IndexSearcher(directory);
         Query tQueryCode = new TermQuery(new Term(FIELD_CODE, "CCOM"));
         Query tQueryCodeRef = new TermQuery(new Term(FIELD_CODE_REF, 
"CCOM"));
         Query rQuery = new TermRangeQuery(FIELD_ARTICLE, "l110-1", 
"l146-4", true, true);

         BooleanQuery bQuery = new BooleanQuery();
         bQuery.add(tQueryCode, Occur.MUST);
         bQuery.add(tQueryCodeRef, Occur.MUST);
         bQuery.add(rQuery, Occur.MUST);

         System.out.println(bQuery.toString());

         isearcher.search(bQuery, collector);
         hits = collector.topDocs().scoreDocs;

         System.out.println(hits.length);

The query is : +code:CCOM +codeRef:CCOM +article:[l110-1 TO l146-4]

The hits[] is equal to Zero although there should be hits. I'm using a 
program called lukeall 3.1 which provide
a GUI to query a lucene index. When I copy the query into this program 
and run it, it return a lot of results =o

So I guess I'm missing something. I thought about a missing analyzer but 
I'm not sure...

Regards,
Gary

Le 17/05/2011 14:02, Uwe Schindler a écrit :
> Hi,
>
> Query q = new TermRangeQuery(...)
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message