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 "Igal @ getRailo.org" <ig...@getrailo.org> on 2012/11/05 19:33:13 UTC

Lucene API

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
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Lucene API

Posted by Vitaly Funstein <vf...@gmail.com>.
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 <ig...@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 <igal@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-**unsubscribe@lucene.apache.org<ja...@lucene.apache.org>
>>> >
>>> For additional commands, e-mail: java-user-help@lucene.apache.****org<
>>> java-user-help@lucene.**apache.org <ja...@lucene.apache.org>>
>>>
>>>
>>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.**apache.org<ja...@lucene.apache.org>
> For additional commands, e-mail: java-user-help@lucene.apache.**org<ja...@lucene.apache.org>
>
>

Re: Lucene API

Posted by "Igal @ getRailo.org" <ig...@getrailo.org>.
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 <ig...@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<ja...@lucene.apache.org>
>> For additional commands, e-mail: java-user-help@lucene.apache.**org<ja...@lucene.apache.org>
>>
>>


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


Re: Lucene API

Posted by Vitaly Funstein <vf...@gmail.com>.
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 <ig...@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<ja...@lucene.apache.org>
> For additional commands, e-mail: java-user-help@lucene.apache.**org<ja...@lucene.apache.org>
>
>