[hibernate-dev] DocumentBuilder refactoring in Hibernate Search: how to deal (internally) with metadata

Hardy Ferentschik hardy at hibernate.org
Fri May 31 05:13:23 EDT 2013


> public interface IndexedEntityDescriptor {
> 
> I find the name "IndexedEntityDescriptor" in conjunction with isIndexed() potentially returning "false" a bit irritating. Maybe just EntityDescriptor? Or SearchableEntityDescriptor?

I thought about EntityDescriptor, but found it to generic. Somehow I wanted to have the connection to Search/Lucene. SearchableEntityDescriptor implies that I can search
something in the descriptor. I am not 100% happy about IndexedEntityDescriptor either, but for now I still think it is the best.

>         boolean isIndexed();
> 
> Maybe return an enum if this can potentially be more than a simple yes/no? I don't know how likely that is, but an enum would allow for evolvement.

Not sure this is needed. I don't foresee that this would change.

>         Set<String> getIndexNames();
> 
> Would something like Set<IndexDescriptor> getIndexes() make sense?

That's an interesting thought. In fact I was wondering whether more index specific information is needed. On the other hand, 
I was thinking thinking that as long as you have the index name you can always get more information via accessing the IndexManager
directly - SearchFactoryImplementor.getAllIndexesManager.getIndexManager(String indexName)

Now that you bring it up, I am wondering, however, if we could expose thinks like directory type via a IndexDescriptor.

> At least for my case I think it would be easier if this contained all field descriptors so I can handle them uniformly. Maybe FieldDescriptor#isId() or if there are more id specific things something like this could be added:

sounds good

>         // TODO should OBJECT_CLASS be considered?
>         Set<FieldDescriptor> getIndexedFields();
> 
> Could you also add FieldDescriptor getIndexedField(String fieldName);

sure

> public interface FieldDescriptor {
>         /**
>          * Returns the Lucene {@code Document} field name for this indexed property.
>          *
>          * @return Returns the field name for this index property
>          */
>         String getFieldName();
> 
> I'd call it just "getName()", not repeating the type's name.

ok

> public interface FieldNameReportingBridge {
>         Iterable<String> getGeneratedFieldNames(String baseFieldName);
> }
> 
> Not better a Set? Returning Iterable makes it harder for users (e.g. no contains()) and also hides set vs. list semantics.

+1

thanks for the great feedback :-)


--Hardy


More information about the hibernate-dev mailing list