You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Murali Krishna <mu...@gmail.com> on 2018/12/05 12:03:01 UTC

Adding attributes to IndexFieldType

Today, we can write a custom Field using custom IndexFieldType, but when
the DefaultIndexingChain converts IndexFieldType to FieldInfo
<https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java#L662>,
only few key informations such as indexing options and doc value type are
retained. The Codec gets the FieldInfo
<https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java#L90>,
but not the type details.

FieldInfo has support for 'attributes'
<https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java#L47>
and
it would be great if we can add 'attributes' to IndexFieldType also and
copy it to FieldInfo's 'attribute'. If we can at-least add the 'field type'
to the FieldInfo attribute, that should suffice, but I felt adding
attributes to IndexFieldType would be more appropriate.

This would allow someone to write a custom codec (extending docvalueformat
for example) for only the 'special field' that he wants and delegate the
rest of the fields to the default codec. Let me know if there are other
alternatives or if I should create an issue for this.

Thanks,
Murali

Re: Adding attributes to IndexFieldType

Posted by Michael McCandless <lu...@mikemccandless.com>.
Hi Murali,

I agree it'd be nice if there were a way to carry over attributes from an
IndexFieldType into the FieldInfo.  It'd need to have a way to resolve
differences/conflicts, since many IndexFieldType instances are indexed for
a single FieldInfo.

Lacking this, it seems like you'd have to hard code your Codec based on
field name or based on other attributes (e.g. all numeric fields are
handled one way).

Can you open an issue to discuss/iterate further?

Thanks,

Mike McCandless

http://blog.mikemccandless.com


On Wed, Dec 5, 2018 at 8:11 AM Murali Krishna <mu...@gmail.com>
wrote:

> Today, we can write a custom Field using custom IndexFieldType, but when
> the DefaultIndexingChain converts IndexFieldType to FieldInfo
> <https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java#L662>,
> only few key informations such as indexing options and doc value type are
> retained. The Codec gets the FieldInfo
> <https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java#L90>,
> but not the type details.
>
> FieldInfo has support for 'attributes'
> <https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java#L47> and
> it would be great if we can add 'attributes' to IndexFieldType also and
> copy it to FieldInfo's 'attribute'. If we can at-least add the 'field type'
> to the FieldInfo attribute, that should suffice, but I felt adding
> attributes to IndexFieldType would be more appropriate.
>
> This would allow someone to write a custom codec (extending docvalueformat
> for example) for only the 'special field' that he wants and delegate the
> rest of the fields to the default codec. Let me know if there are other
> alternatives or if I should create an issue for this.
>
> Thanks,
> Murali
>
>