You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by AlisonCallahan <al...@gmail.com> on 2010/02/17 16:39:02 UTC

PrefixQuery returning 0 results

I have indexed RDF in N-triple format (with three fields -- "subject",
"predicate", "object") and now am trying to query the index with a
PrefixQuery on the "subject" field. My test case is to get back all
documents whose subject field starts with the prefix "<http", and I would
expect to get back all documents. Instead, the PrefixQuery returns 0
documents. I have read and can't see why the PrefixQuery is returning 0
results. 

Here is the relevant code:

	IndexReader n3reader = IndexReader.open(FSDirectory.open(new File(index)),
true);	
	Searcher searcher = new IndexSearcher(n3reader);
	Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);

	String test = "<http";

	Query nsQuery = new PrefixQuery(new Term("subject", test));
	
	TopDocs hits = searcher.search(nsQuery, 10);

	System.out.println("Hits: "+hits.totalHits);

This code prints out '0' hits ... Any suggestions for why this isn't
working?? Thanks,

Alison Callahan
-- 
View this message in context: http://old.nabble.com/PrefixQuery-returning-0-results-tp27625646p27625646.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


RE: PrefixQuery returning 0 results

Posted by AlisonCallahan <al...@gmail.com>.
Nevermind ... I wrote too soon ... It works!! Thank you Uwe Schindler!

Alison Callahan

AlisonCallahan wrote:
> 
> Originally "subject" was indexed with ANALYZED ... I changed it to
> NOT_ANALYZED (there was no "keyword" option for indexing in Lucene 3.0.0),
> and I am still having the same problem.
> 
> Thanks,
> 
> Alison Callahan
> 
> 
> Uwe Schindler wrote:
>> 
>> How is "subject indexed"?
>> 
>> I fit is indexed with ANALYZED not as keyword only, StandardAnalyzer will
>> remove <, lowercase and so on.
>> 
>> -----
>> Uwe Schindler
>> H.-H.-Meier-Allee 63, D-28213 Bremen
>> http://www.thetaphi.de
>> eMail: uwe@thetaphi.de
>> 
>> 
>>> -----Original Message-----
>>> From: AlisonCallahan [mailto:alison.callahan@gmail.com]
>>> Sent: Wednesday, February 17, 2010 4:39 PM
>>> To: java-user@lucene.apache.org
>>> Subject: PrefixQuery returning 0 results
>>> 
>>> 
>>> I have indexed RDF in N-triple format (with three fields -- "subject",
>>> "predicate", "object") and now am trying to query the index with a
>>> PrefixQuery on the "subject" field. My test case is to get back all
>>> documents whose subject field starts with the prefix "<http", and I
>>> would
>>> expect to get back all documents. Instead, the PrefixQuery returns 0
>>> documents. I have read and can't see why the PrefixQuery is returning 0
>>> results.
>>> 
>>> Here is the relevant code:
>>> 
>>> 	IndexReader n3reader = IndexReader.open(FSDirectory.open(new
>>> File(index)),
>>> true);
>>> 	Searcher searcher = new IndexSearcher(n3reader);
>>> 	Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
>>> 
>>> 	String test = "<http";
>>> 
>>> 	Query nsQuery = new PrefixQuery(new Term("subject", test));
>>> 
>>> 	TopDocs hits = searcher.search(nsQuery, 10);
>>> 
>>> 	System.out.println("Hits: "+hits.totalHits);
>>> 
>>> This code prints out '0' hits ... Any suggestions for why this isn't
>>> working?? Thanks,
>>> 
>>> Alison Callahan
>>> --
>>> View this message in context: http://old.nabble.com/PrefixQuery-
>>> returning-0-results-tp27625646p27625646.html
>>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/PrefixQuery-returning-0-results-tp27625646p27626321.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


RE: PrefixQuery returning 0 results

Posted by AlisonCallahan <al...@gmail.com>.
Originally "subject" was indexed with ANALYZED ... I changed it to
NOT_ANALYZED (there was no "keyword" option for indexing in Lucene 3.0.0),
and I am still having the same problem.

Thanks,

Alison Callahan


Uwe Schindler wrote:
> 
> How is "subject indexed"?
> 
> I fit is indexed with ANALYZED not as keyword only, StandardAnalyzer will
> remove <, lowercase and so on.
> 
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
> 
> 
>> -----Original Message-----
>> From: AlisonCallahan [mailto:alison.callahan@gmail.com]
>> Sent: Wednesday, February 17, 2010 4:39 PM
>> To: java-user@lucene.apache.org
>> Subject: PrefixQuery returning 0 results
>> 
>> 
>> I have indexed RDF in N-triple format (with three fields -- "subject",
>> "predicate", "object") and now am trying to query the index with a
>> PrefixQuery on the "subject" field. My test case is to get back all
>> documents whose subject field starts with the prefix "<http", and I
>> would
>> expect to get back all documents. Instead, the PrefixQuery returns 0
>> documents. I have read and can't see why the PrefixQuery is returning 0
>> results.
>> 
>> Here is the relevant code:
>> 
>> 	IndexReader n3reader = IndexReader.open(FSDirectory.open(new
>> File(index)),
>> true);
>> 	Searcher searcher = new IndexSearcher(n3reader);
>> 	Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
>> 
>> 	String test = "<http";
>> 
>> 	Query nsQuery = new PrefixQuery(new Term("subject", test));
>> 
>> 	TopDocs hits = searcher.search(nsQuery, 10);
>> 
>> 	System.out.println("Hits: "+hits.totalHits);
>> 
>> This code prints out '0' hits ... Any suggestions for why this isn't
>> working?? Thanks,
>> 
>> Alison Callahan
>> --
>> View this message in context: http://old.nabble.com/PrefixQuery-
>> returning-0-results-tp27625646p27625646.html
>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/PrefixQuery-returning-0-results-tp27625646p27626268.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


RE: PrefixQuery returning 0 results

Posted by Uwe Schindler <uw...@thetaphi.de>.
How is "subject indexed"?

I fit is indexed with ANALYZED not as keyword only, StandardAnalyzer will remove <, lowercase and so on.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: AlisonCallahan [mailto:alison.callahan@gmail.com]
> Sent: Wednesday, February 17, 2010 4:39 PM
> To: java-user@lucene.apache.org
> Subject: PrefixQuery returning 0 results
> 
> 
> I have indexed RDF in N-triple format (with three fields -- "subject",
> "predicate", "object") and now am trying to query the index with a
> PrefixQuery on the "subject" field. My test case is to get back all
> documents whose subject field starts with the prefix "<http", and I
> would
> expect to get back all documents. Instead, the PrefixQuery returns 0
> documents. I have read and can't see why the PrefixQuery is returning 0
> results.
> 
> Here is the relevant code:
> 
> 	IndexReader n3reader = IndexReader.open(FSDirectory.open(new
> File(index)),
> true);
> 	Searcher searcher = new IndexSearcher(n3reader);
> 	Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
> 
> 	String test = "<http";
> 
> 	Query nsQuery = new PrefixQuery(new Term("subject", test));
> 
> 	TopDocs hits = searcher.search(nsQuery, 10);
> 
> 	System.out.println("Hits: "+hits.totalHits);
> 
> This code prints out '0' hits ... Any suggestions for why this isn't
> working?? Thanks,
> 
> Alison Callahan
> --
> View this message in context: http://old.nabble.com/PrefixQuery-
> returning-0-results-tp27625646p27625646.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org



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