lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Best way to construct term?
Date Fri, 10 May 2013 17:24:52 GMT
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.


Mime
View raw message