lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Ingersoll <grant.ingers...@gmail.com>
Subject Re: In which position of a document a word was found?
Date Thu, 14 Jun 2007 13:23:07 GMT
Have a look at the SpanQuery (starting at page 161 in LIA or in the  
javadocs).  I also have some info in my ApacheCon talk at http:// 
www.cnlp.org/presentations/slides/AdvancedLuceneEU.pdf and http:// 
www.cnlp.org/apachecon2005

Incidentally, the SpanQuery functionality does not require  
TermVectors, so if you don't need them otherwise, you would get a  
smaller index size.

Cheers,
Grant

On Jun 13, 2007, at 1:36 PM, Felipe Sánchez Martínez wrote:

> Hi all,
>
> I am new to Lucene and I have been reading the book "Lucene In  
> Action",
> here is my question:
>
> When searching for a word through an index is there any way to know in
> which positions (may be more than one) of each document that word was
> found?
>
> The index is constructed in the following way:
> ---------------------
> IndexWriter writer = new IndexWriter("/path/to/the/index/dir",
> new StandardAnalyzer(), true);
>
> writer.setUseCompoundFile(false);
>
> Document doc = new Document();
>
> doc.add(new Field("contents",
> new FileReader(f),Field.TermVector.WITH_POSITIONS_OFFSETS));
>
> doc.add(new Field("filename", f.getCanonicalPath(), Field.Store.YES,
> Field.Index.NO_NORMS));
>
> writer.addDocument(doc);
> .....
> --------------------
>
>
> Thanks in advance
> --
> Felipe.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

------------------------------------------------------
Grant Ingersoll
http://www.grantingersoll.com/
http://lucene.grantingersoll.com
http://www.paperoftheweek.com/



---------------------------------------------------------------------
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