You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Gunjan Juyal <hi...@yahoo.com> on 2008/08/29 16:22:44 UTC

reusing Document with multiple fields in lucene 2.3

Hello all!
 I have a document structure such that each document can have multiple and
variable number of fields of a given name. For example:
- Document-1 has two fields with the name "fld1" and three fields with the
name "fld2";
- Document-2 has five fields with the name "fld1" and one field with the
name "fld2".

 If a document has a fixed number of fields then it's easy to reuse the
field instances by setting them to different values before writing the doc,
but I can't think of any way in which I can reuse the document or field
instances in this case (where the number of fields varies from document to
document). One possibility is to maintain a pool of fields, create a new
instance for each document and add the already-existing fields to the new
doc after setting them to an appropriate value. But this would require
significant additions to the code.

 Has anyone else faced such a situation? I'd be glad if someone could give
any pointers for this situation! Thanks in anticipation!

- Gunjan
-- 
View this message in context: http://www.nabble.com/reusing-Document-with-multiple-fields-in-lucene-2.3-tp19220927p19220927.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: reusing Document with multiple fields in lucene 2.3

Posted by Michael McCandless <lu...@mikemccandless.com>.
Maybe the complexity caused by reuse in this case (a pool of Field  
instances) may not be offset by the performance gains of avoiding GC?   
You could code up a quick test and see what performance gains it gives  
you?

Reuse works very well when your documents are extremely regular.

Mike

Juyal wrote:

>
> Hello all!
> I have a document structure such that each document can have  
> multiple and
> variable number of fields of a given name. For example:
> - Document-1 has two fields with the name "fld1" and three fields  
> with the
> name "fld2";
> - Document-2 has five fields with the name "fld1" and one field with  
> the
> name "fld2".
>
> If a document has a fixed number of fields then it's easy to reuse the
> field instances by setting them to different values before writing  
> the doc,
> but I can't think of any way in which I can reuse the document or  
> field
> instances in this case (where the number of fields varies from  
> document to
> document). One possibility is to maintain a pool of fields, create a  
> new
> instance for each document and add the already-existing fields to  
> the new
> doc after setting them to an appropriate value. But this would require
> significant additions to the code.
>
> Has anyone else faced such a situation? I'd be glad if someone could  
> give
> any pointers for this situation! Thanks in anticipation!
>
> - Gunjan
> -- 
> View this message in context: http://www.nabble.com/reusing-Document-with-multiple-fields-in-lucene-2.3-tp19220927p19220927.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>


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