lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jitender ahuja" <ajiten...@aalayance.com>
Subject Re: Hit Id < 10 in new stop words' table Standard Analyzer causes error
Date Sat, 08 May 2004 22:07:57 GMT
Sir,
     I have corrected the error , however it depends on repassing the
clicked hits' OBJECT_ID value to queryparser object. The code is
presented below for the jsp page responsible for hits' iteration.
What I did was taking the retrieved hits and passing the clicked one to the
same page using the request.getparameter() in the jsp page.
Now, by error the retrieved OBJECT_ID was again passed to the queryparser.
This caused the error, that too if the modified StandardAnalyzer class
extended upon the Analyzer class and not the StandardAnalyzer class.( It
lead me to believe that some class depends upon the original
StandardAnalyzer class alone)

Also, regarding your stmt. regarding the passing of a new STOP_WORD list to
the constructor of the StandardAnalyzer class, it is not
reflected in the output web page. It is passed however, if the new class
extends upon the Analyzer class, i.e. the modified StandardAnalyzer class
has the statement :  "public class StandardAnalyzer extends
org.apache.lucene.analysis.Analyzer {  "


Regards,
Jitender


The jsp code for taking the query from a previous page and retrieving hits
and the clicked hits' data::
----------------------------------------------------------------------------
---------------------------- 
// There are 2 index fields: OBJECT_ID is a keyword field, while the
OBJECT_XML is a Text field(Reader)

try {searcher = new IndexSearcher(IndexReader.open(indexName));
} catch (Exception e) {
  e.printStackTrace();
                                error = true;
}
 if (error == false) {
                       queryString = request.getParameter("query");
//passed from the previous page recieving the query
         if (queryString == null)
     throw new ServletException("no query "+     "specified");
                org.apache.lucene.analysis.Analyzer analyzer = new
org.apache.lucene.modanalysis.StandardAnalyzer();
           try {
          query = QueryParser.parse(queryString, "OBJECT_XML", analyzer);
         } catch (ParseException e) {
  error = true;
 }
}
if (error == false && searcher != null) {
 thispage = maxpage;
 hits = searcher.search(query);
 if (hits.length() == 0) {
                           error = true;
 }
}
if (error == false && searcher != null) {
       for (                    int  i = startindex;
                                i < (thispage + startindex);  i++) {
                                Document doc = hits.doc(i);
                  String url = doc.get("OBJECT_ID");

<!--- %%%%%%%%%% OBJECT_ID of the clicked hit passed to the same page to
display data in the same page %%%%%%%% -->

        String srchString1 = request.getParameter("url");
         if(srchString1 != null)
            String srchString = srchString1;
         else if(srchString1 == null)  // i.e. if no hits' retrieved links
is clicked upon then display data
                                       // of the first link of the retrieved
results
            srchString = hits.doc(0).get("OBJECT_ID");

////earlier code presented below : and also the reason for error, the
removed lines are indicated by a "-" in the new code and the new/////
//// added lines are indicated by a "+"  //////

   -     try {
   -                                   searcher = new
IndexSearcher(IndexReader.open(indexName));
   -      }catch (Exception e) {
   -                                    e.printStackTrace();
   -                                    error = true;
   -     }
   -      if (error == false) {
   - org.apache.lucene.analysis.Analyzer analyzer = new
org.apache.lucene.modanalysis.StandardAnalyzer();
   - try{
   -  query = QueryParser.parse(srchString, "OBJECT_ID", analyzer);
   - }catch(ParseException e){
   -                             error = true;
   - }
   -   }
   -     if (error == false && searcher != null){
   -            hits = searcher.search(query);
   -            Document doc = hits.doc(0);
   -  String datas = doc.get("OBJECT_ID")

  DataRoche abc = new DataRoche();//this class retrieves the actual data for
a particular OBJECT_ID
                                                //by accessing the Oracle
database over a thin client

  -  String data = abc.getdata( datas );

  +             String data = abc.getdata( srchString );

                                // next the "data" is displayed
 }



----- Original Message ----- 
From: "Erik Hatcher" <erik@ehatchersolutions.com>
To: "Lucene Developers List" <lucene-dev@jakarta.apache.org>
Sent: Friday, May 07, 2004 6:03 PM
Subject: Re: Hit Id < 10 in new stop words' table Standard Analyzer causes
error


> Could you provide your code on how you are iterating the hits?
>
> Also, you don't need to modify the StandardAnalyzer for a new stop
> words list - it allows you to pass a list in its constructor.
>
> Erik
>
>
> On May 7, 2004, at 7:28 AM, jitender ahuja wrote:
>
> > Hi ,
> >       I am modifying the Standard Analyzer to include a new Stop-Words
> > list, and am working on an Index with 2 fields: 1) OBJECT_ID serving
> > to identify a document: a keyword field , and 2) OBJECT_XML: a text
> > field with Reader i.e., tokenised and indexed but not stored.
> > Now, in response to the query string the results are retrieved
> > correctly.Then, one need to click on the retrieved hits to get the
> > data from the database through a seperate java class in the underlying
> >  jsp  file , for a particular OBJECT_ID.
> >
> > But it gives the following error for Hit Ids (OBJECT_ID) < 10 on
> > clicking it to retrieve the data field from the database.
> >
> > org.apache.jasper.JasperException: Not a valid hit number: 0
> >
> > Also, pl. do note that::    If the old analyzer is just used from the
> > different folder it causes no error.
> >
> > Can , anyone tell why this weird behavior is exhibited?
> >
> >
> > Regards,
> > Jitender
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message