lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Biswas, Goutam_Kumar" <>
Subject Lucene throws an ArrayIndexOutOfBoundsException() if the first te rm in my query string is a stopWord
Date Thu, 07 Mar 2002 16:42:18 GMT
Dear Lucene Users

     Lucene throws an ArrayIndexOutOfBoundsException() if the first term in
my query string is a stopWord. Why is it so ?

     I'm making AND as the default mode of search. So I'm adding an AND
operator between each term of my query. That is if my query 
     is 'cats dogs' I'm rephrasing it as 'cats AND dogs'. But if the first
term is a stopWord (example: 'of cats ...') I get the 

     I'm tried something like the following to get away with this:

	// <<<<<<<<<<<<<<<<<
     String queryStr = "of AND by AND for AND cats AND dogs"; // 'of', 'by',
'for'  are stopwords	
     Query query = null;
     Analyzer myAnalyzer = new MyAnalyzer(stopWords); 
     try {
         query = QueryParser.parse(queryStr, "content", myAnalyzer); //
content is the default field to search.   
     } catch (ArrayIndexOutOfBoundsException e) {
         queryStr = queryStr.substring(queryStr.indexOf("AND") + 3); 
     // so my final queryStr becomes 'cats AND dogs' which works fine!
     // >>>>>>>>>>>>>>>>>>		

     Is there a better way to handle this situation ? or can someone throw a
pointer on why this error is occuring in the first place ?   

Thanks in advance

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message