Term in my view is definitely not any more of a char buffer than a plain String. It's a unique permutation of a particular field name and its text value. If you look at its public API, the only way to mutate a Term instance is by obtaining a reference to underlying BytesRef which is in itself mutable. This can be viewed as a leak in the abstraction, but I doubt there are any uses for this backdoor anyway. Other than that, its public API give you immutable objects to work with - Strings.
FWIW, there are obviously less than intuitive places in Lucene in general, but I have found that ease of understanding of the API generally goes along with one's degree of proficiency with Lucene's machinery, i.e. the complexity of a particular API is proportional to the complexity of a particular concept it represents. On Mon, Nov 5, 2012 at 11:47 AM, Igal @ getRailo.org <i...@getrailo.org>wrote: > it's CharTermAttribute in particular but since there are many such > particular examples -- at some point it becomes Lucene in general. > > perhaps the problem is on my end that I'm not familiar enough with > DSL-style, but learning DSL concepts is not a prerequisite for Lucene. > > as for the Term being immutable -- it's a char buffer, which in my view is > Very much mutable -- so if that was the idea it totally escaped me. > > again, I'm not trying to criticize here, but I think that perhaps the > Lucene-experts are already used to this API and new users have a steeper > learning curve because of it. > > > Igal > > > > On 11/5/2012 11:38 AM, Vitaly Funstein wrote: > >> Are you critiquing CharTermAttribute in particular, or Lucene in general? >> It appears CharTermAttribute is DSL-style builder API, just like its >> superinterface Appendable - does that not appear intentional and >> self-explanatory? Further, I believe Term instances are meant to be >> immutable hence no direct linkage between the two. I could be wrong >> though. >> >> On Mon, Nov 5, 2012 at 10:33 AM, Igal @ getRailo.org <i...@getrailo.org >> >wrote: >> >> I don't mean to sound critical, but is there a reason that the API is not >>> simpler? >>> >>> for example, if I want to read/modify a CharTermAttribute's value, I need >>> to use toString() to get the value, which is very unintuitive, and either >>> copyBuffer() or setEmpty() and append(). >>> >>> is there a reason not to add the methods getTerm() and setTerm()? >>> >>> ------------------------------****----------------------------** >>> --**--------- >>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.****apache.org< >>> java-user-**unsubscr...@lucene.apache.org<java-user-unsubscr...@lucene.apache.org> >>> > >>> For additional commands, e-mail: java-user-help@lucene.apache.****org< >>> java-user-help@lucene.**apache.org <java-user-h...@lucene.apache.org>> >>> >>> >>> > > ------------------------------**------------------------------**--------- > To unsubscribe, e-mail: > java-user-unsubscribe@lucene.**apache.org<java-user-unsubscr...@lucene.apache.org> > For additional commands, e-mail: > java-user-help@lucene.apache.**org<java-user-h...@lucene.apache.org> > >