MultiFieldQueryParser error encountered when searching for the 2nd time
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Joan_So
Posted On:   Tuesday, January 15, 2008 03:10 AM

It's my first time to use Lucene and I'm using MultiFieldQueryParser for doing an advance search on our site. When I run the site (using Netbeans 5.5's built-in Tomcat server) and do a sample search, it produces results. However, the next searches I make (including doing the same search I did the first time) doesn't work. Netbeans only says that the error is "null". The error occurs when it runs Query query = mparser.parse(queries, fields, occurs, getAnalyzer()); Please help. Here's my code: public Vector advSearch(String[] fields, String[] queries, BooleanClause.Occur[] occurs) {   int i;   Vector results = null;   try   {     Searche   More>>

It's my first time to use Lucene and I'm using MultiFieldQueryParser for doing an advance search on our site. When I run the site (using Netbeans 5.5's built-in Tomcat server) and do a sample search, it produces results. However, the next searches I make (including doing the same search I did the first time) doesn't work. Netbeans only says that the error is "null". The error occurs when it runs Query query = mparser.parse(queries, fields, occurs, getAnalyzer()); Please help. Here's my code:

			
public Vector advSearch(String[] fields, String[] queries, BooleanClause.Occur[] occurs)

{

  int i;

  Vector results = null;



  try

  {

    Searcher searcher = new IndexSearcher(Constants.INDEXDIR);

    MultiFieldQueryParser mparser = new MultiFieldQueryParser(fields, getAnalyzer());

    Query query = mparser.parse(queries, fields, occurs, getAnalyzer());



    Hits hits = searcher.search(query);



    for(i = 0; i < hits.length(); i++)

    {

      if(results == null)

        results = new Vector();



      Document doc = hits.doc(i);

      Text t = this.getDocumentDetails(doc.get("url"), hits.score(i));



      results.add(t);

    }



    searcher.close();

  }



  catch(Exception e)

  {

    System.out.println("generalError: " + e.getMessage());

  }



  return results;

}
   <<Less
About | Sitemap | Contact