File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Lucene Query.toString returns blank/empty value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Lucene Query.toString returns blank/empty value" Watch "Lucene Query.toString returns blank/empty value" New topic

Lucene Query.toString returns blank/empty value

Ajay Singh
Ranch Hand

Joined: Jan 04, 2008
Posts: 105
i am trying to use Lucene for indexing and searching long terms.My terms are of the form A.B.C.D in my documents(Example "" is a term which is indexed).I am able to index terms of such patterns.But retrieving does not work for some of these patterns.I am using StandardAnalyzer while indexing the documents and using the same Analyzer for retrieving.While debugging i found that query.toString is blank(empty) for the patterns which are not being searched.Otherwise some values comes in the Sysout in line number 3 below of my term search logic.

QueryParser queryParser = new QueryParser(Version.LUCENE_30,"TM", standardAnalyzer);
Query query= queryParser.parse("\"" + termToBeSearched + "\"");
System.out.println("===================================================Query :: "+query.toString());
System.out.println("=======================Query Class---->"+query.getClass());

Pattern Number 1:-

Pattern Number 2:-

The query.toString has some values for Pattern no 1( and is able to search it) but is empty/blank for Pattern number 2 while searching although indexing happens for both. What am i doing wrong? is there any limit in lucene regarding term length.Even some of the bigger length terms compared to the second pattern is being searched successfully,so i dont think that is the case.Please guide me.

Thanks in advance.
I agree. Here's the link:
subject: Lucene Query.toString returns blank/empty value
It's not a secret anymore!