Hi all,
I intend to convert Query object to a String object for the purpose of passing it to the parse method of the QueryParser class i.e.,
Query query = QueryParser.parse(searchStr.toString(), field name , analyzer); // searchStr is the query string passed
but, it retrieves nothing as output , whatsoever.
I am quite confused as how to usefully convert a Query object to a String.
Even the Hits object, i.e. , hits = indexSrch.search(query), returned by a searcher object of my own class Searcher yields nothing.
Regards,
Jitender
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
My searcher class is stated below :
public class Searcher {
public static void main(String[] args) {
}
public static Hits searchDB(Query searchStr) // it has to be a query type parameter as the
//results.jsp has stmt. : Hits hits = searcher.searchDB(query)
{
ArrayList results = new ArrayList();
Hits hits = null;
try {
//search on index directory
Searcher indexSrch = new IndexSearcher("C:\\Temp\\DBDEX_GT"); // index already delivers by a seperate code
Analyzer analyzer = new StandardAnalyzer();
//create a query to search for the target string in the description field
Query query = QueryParser.parse(searchStr, field name, analyzer);
hits = indexSrch.search(query); // returns nothing and no output is displayed for the next two print stmts.
System.out.println(hits); // displays nothing
System.out.println(hits.length() + " total matching documents"); // displays nothing
}
catch (ParseException ex1) {
ex1.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
return hits;
}
}
}