You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by shadab khan <ca...@yahoo.co.in> on 2005/10/05 10:17:03 UTC

finding the position of a term in a field.....

hi all,
while indexing for a document, one field i am using is "contents". 
 
doc.add(Field.Text("contents", reader));
 
the "contents" field is not being stored in index(only being tokenize and indexing. Now my problem is to find the position for a word from this field(i.e. contents). if you have a solution for this plzz send it to me asap. 
 
with regards, 
Shadab

		
---------------------------------
 Yahoo! India Matrimony: Find your partner now.

Re: finding the position of a term in a field.....

Posted by shadab khan <ca...@yahoo.co.in>.
thnks erik
thnks for your reply...
 
with regards,
 

Erik Hatcher <er...@ehatchersolutions.com> wrote:

On Oct 5, 2005, at 4:17 AM, shadab khan wrote:

> hi all,
> while indexing for a document, one field i am using is "contents".
>
> doc.add(Field.Text("contents", reader));
>
> the "contents" field is not being stored in index(only being 
> tokenize and indexing. Now my problem is to find the position for a 
> word from this field(i.e. contents). if you have a solution for 
> this plzz send it to me asap.

One solution is to store it. :) Field.Text(String,Reader) does not 
store though, only Field.Text(String,String). So you will need to 
load it as a String first to do that. An alternative is to grab the 
contents from its original location when you need the positions and 
re-run the Analyzer on the text to get the Tokens with position 
information. There is also some enhancements in the trunk 
(unreleased) version of Lucene you may try to store offset and 
position information in the index.

Erik


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


		
---------------------------------
 Yahoo! India Matrimony: Find your partner now.

Re: finding the position of a term in a field.....

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Oct 5, 2005, at 4:17 AM, shadab khan wrote:

> hi all,
> while indexing for a document, one field i am using is "contents".
>
> doc.add(Field.Text("contents", reader));
>
> the "contents" field is not being stored in index(only being  
> tokenize and indexing. Now my problem is to find the position for a  
> word from this field(i.e. contents). if you have a solution for  
> this plzz send it to me asap.

One solution is to store it.  :)   Field.Text(String,Reader) does not  
store though, only Field.Text(String,String).  So you will need to  
load it as a String first to do that.  An alternative is to grab the  
contents from its original location when you need the positions and  
re-run the Analyzer on the text to get the Tokens with position  
information.  There is also some enhancements in the trunk  
(unreleased) version of Lucene you may try to store offset and  
position information in the index.

     Erik


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