lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jitender ahuja" <>
Subject Conversion of Query object to a String object in 1.2 ver.
Date Sat, 17 Apr 2004 08:18:13 GMT
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 =,  returned by a searcher object
of my own class Searcher yields nothing. 


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 =;   // 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) {

    catch (IOException ex) {

    }catch(Exception e){
     return hits;

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message