lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ejblom <>
Subject Don't get results wheras Luke does...
Date Wed, 30 Nov 2011 17:36:00 GMT
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

This is the query:


(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",
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);, 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);, 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


EJ Blom

View this message in context:
Sent from the Lucene - General mailing list archive at

View raw message