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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to