lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From karl wettin <ka...@snigel.net>
Subject Re: Using Lucene for searching tokens, not storing them.
Date Sat, 15 Apr 2006 17:25:36 GMT

14 apr 2006 kl. 18.31 skrev Doug Cutting:

> karl wettin wrote:
>> I would like to store all in my application rather than using the   
>> Lucene persistency mechanism for tokens. I only want the search   
>> mechanism. I do not need the IndexReader and IndexWriter as that  
>> will  be a natural part of my application. I only want to use the  
>> Searchable.
>
> Implement the IndexReader API, overriding all of the abstract  
> methods. That will enable you to search your index using Lucene's  
> search code.

This was not even half as tough I thought it would be. I'm however  
not certain about a couple of methods:

1. TermPositions. It returns the next position of *what* in the  
document? It would make sence to me if it returned a start/end  
offset, but this just confuses me.

implements TermPositions {
         /** Returns next position in the current document.  It is an  
error to call
          this more than {@link #freq()} times
          without calling {@link #next()}<p> This is
          invalid until {@link #next()} is called for
          the first time.
          */
         public int nextPosition() throws IOException {
             return 0; // todo
         }


2. Norms. I've been looking in other code, but I honestly don't  
understand what data they are storing, thus it's really hard for me  
to implement :-) I read it as it contains the boost of each document  
per field? So what does the byte represent then?

          /** Returns the byte-encoded normalization factor for the  
named field of
          * every document.  This is used by the search code to score  
documents.
          * @see org.apache.lucene.document.Field#setBoost(float)
          */
         public byte[] norms(String field) {
            return null; // todo
         }

         /** Reads the byte-encoded normalization factor for the  
named field of every
          *  document.  This is used by the search code to score  
documents.
          * @see org.apache.lucene.document.Field#setBoost(float)
          */
         public void norms(String field, byte[] bytes, int offset)  
throws IOException {
             // todo
         }

         /** Implements setNorm in subclass.*/
         protected void doSetNorm(int doc, String field, byte value)  
throws IOException {
             // todo
         }

3. I presume I can just ignore the following methods:

         /** Implements deletion of the document numbered  
<code>docNum</code>.
          * Applications should call {@link #delete(int)} or {@link  
#delete(org.apache.lucene.index.Term)}.
          */
         protected void doDelete(int docNum) {

         }

         /** Implements actual undeleteAll() in subclass. */
         protected void doUndeleteAll() {

         }

         /** Implements commit. */
         protected void doCommit() {

         }

         /** Implements close. */
         protected void doClose() {

         }

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


Mime
View raw message