Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: General

Don't get results wheras Luke does...

 

 

Lucene general RSS feed   Index | Next | Previous | View Threaded


ejblom at gmail

Nov 30, 2011, 9:36 AM

Post #1 of 2 (202 views)
Permalink
Don't get results wheras Luke does...

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






--
View this message in context: http://lucene.472066.n3.nabble.com/Don-t-get-results-wheras-Luke-does-tp3549073p3549073.html
Sent from the Lucene - General mailing list archive at Nabble.com.


hossman_lucene at fucit

Dec 5, 2011, 3:16 PM

Post #2 of 2 (166 views)
Permalink
Re: Don't get results wheras Luke does... [In reply to]

1) allthough i'm not certain, the details of your specific situation most
likelye have to do with the default options set on the QueryParser

2) in general questions like this should be sent to the
java-user [at] lucen mailing list (not general [at] lucen) ... i suspect if you
ask your question again on that list you will get a greater number of
helpful responses.


: 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
:
:
:
:
:
:
: --
: View this message in context: http://lucene.472066.n3.nabble.com/Don-t-get-results-wheras-Luke-does-tp3549073p3549073.html
: Sent from the Lucene - General mailing list archive at Nabble.com.
:

-Hoss

Lucene general RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.