You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by bbarani <bb...@gmail.com> on 2013/05/10 19:15:03 UTC

Best way to construct term?

Hi,

I am currently constructing a term using the below steps,

Final Static (class level): Term t=new Term(fieldName);

Inside some function(s):

t.createTerm(termText);


It seems like createTerm method has been removed from Lucene 4.3.0 API, I
just thought of checking the best / efficient way to create a Term. Can
someone please guide me on that?

Thanks,
BB



--
View this message in context: http://lucene.472066.n3.nabble.com/Best-way-to-construct-term-tp4062388.html
Sent from the Lucene - General mailing list archive at Nabble.com.

RE: Best way to construct term?

Posted by bbarani <bb...@gmail.com>.
Thanks a lot for your awesome explanation!!!!!



--
View this message in context: http://lucene.472066.n3.nabble.com/Best-way-to-construct-term-using-Lucene-4-3-0-API-tp4062388p4062396.html
Sent from the Lucene - General mailing list archive at Nabble.com.

RE: Best way to construct term?

Posted by Uwe Schindler <uw...@thetaphi.de>.
Very simple:
new Term(fieldName, termText)

The reason for the extra constructor and createTerm() in Lucene 3.x and before was the extra cost of interning (String.intern()) the field name. In Lucene 4.0 field names are no longer interned, because the index structure changed and field<->field comparisons in term enumerations is no longer needed. So just create a term by using the constructor.

In general Term is just a light wrapper and no longer a fundamental component of Lucene, it is just used for "backwards compatibility" with earlier versions and mainly only used for constructing Query like new TermQuery(Term),.... From the implementation point of view, in Lucene 4.x every field is like a separate index, the terms of each field are represented by the new class BytesRef, which is a slice out of a larger byte[] array containing the data of many terms of a field in the index.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: bbarani [mailto:bbarani@gmail.com]
> Sent: Friday, May 10, 2013 7:15 PM
> To: general@lucene.apache.org
> Subject: Best way to construct term?
> 
> Hi,
> 
> I am currently constructing a term using the below steps,
> 
> Final Static (class level): Term t=new Term(fieldName);
> 
> Inside some function(s):
> 
> t.createTerm(termText);
> 
> 
> It seems like createTerm method has been removed from Lucene 4.3.0 API, I
> just thought of checking the best / efficient way to create a Term. Can
> someone please guide me on that?
> 
> Thanks,
> BB
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Best-
> way-to-construct-term-tp4062388.html
> Sent from the Lucene - General mailing list archive at Nabble.com.