Results 1 to 1 of 1
- 12-02-2011, 09:03 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 1
- Rep Power
- 0
Lucene finds nothing, Luke on the other hand finds everything!
Dear Lucene-users,
I am a bit puzzled over this. I have a query which should return some documents, if I use Luke, I obtain hits using the org.apache.lucene.analysis.KeywordAnalyzer.
This is the query:
domain:NB-AR*
(I have data indexed using:
doc.add(new Field("domain", NB-ARC, Field.Store.YES, Field.Index.NOT_ANALYZED)); )
Explain structure reveals that Luke is employing a PrefixQuery. Ok, now I want to obtain these results using my Java application:
//Using the QueryParser, let him decide what to do with it:
Query q = new QueryParser(Version.LUCENE_35, "contents", analyzer).parse("domain:NB-AR*");
System.out.println("Type of query: " + q.getClass().getSimpleName());
// Type of query: PrefixQuery so that's ok
int hitsPerPage = 1000;
TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage, true);
searcher.search(q, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;
System.out.println("Found " + hits.length + " hits.");
// Unfortunately 0 hits.
// move on and make specify a Term and PrefixQuery:
Term term = new Term("domain", "NB-AR");
q = new PrefixQuery(term);
collector = TopScoreDocCollector.create(hitsPerPage, true);
searcher.search(q, collector);
hits = collector.topDocs().scoreDocs;
// Found with prefix 441 hits.
I tried to lowercase the search query, re-index and made the field: Field.Index.ANALYZED but nothing worked...
I have a feeling it is something very trivial, but I just can't figure it out...
Anyone?
EJ Blom
Similar Threads
-
not looking for a hand out just a hand up
By cloutier172 in forum New To JavaReplies: 3Last Post: 10-04-2011, 03:38 AM -
Finds resource in netbeans but the jar does not
By dko in forum Advanced JavaReplies: 13Last Post: 05-28-2011, 02:58 AM -
I need some one to give me a hand
By HosHos in forum Advanced JavaReplies: 9Last Post: 09-05-2009, 03:18 PM -
Really Would use a hand
By mollentze in forum New To JavaReplies: 7Last Post: 07-03-2008, 02:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks