I have below code in my spring-boot application . We are not getting any exception at startup but while creating attribute I am getting below exception like
Caused by: org.hibernate.search.util.common.SearchException: HSEARCH400609: Unknown field ‘attributes.archetype.archetypeId’.
I am not sure if I miss anything else…
Resource.java(Entity class)
@MapKeyColumn(name = "attribute_name")
@Column(name = "attribute_value", nullable = false, length = 5000)
@PropertyBinding(binder = @PropertyBinderRef(type = ResourceAttributesBinder.class))
@Convert(attributeName = "value", converter = JSONObjectConverter.class)
@EqualsAndHashCode.Exclude
@ToString.Exclude
@OptimisticLock(excluded = true)
private Map<String, JSONObject> attributes;
ResourceAttributesBinder.java
public class ResourceAttributesBinder implements PropertyBinder {
@Override
public void bind(PropertyBindingContext context) {
context.dependencies().useRootOnly();
PojoModelProperty bridgedElement = context.bridgedElement();
IndexSchemaObjectField attributeField = context.indexSchemaElement()
.objectField( bridgedElement.name() );
context.bridge(Map.class,new ResourceAttributesPropertyBridge(attributeField.toReference()));
}
}
ResourceAttributesPropertyBridge.java
@Override
public void write(DocumentElement target, Map bridgedElement, PropertyBridgeWriteContext context) {
final Map<String, Object> indexMap = (Map<String, Object>) bridgedElement;
DocumentElement indexedAttributeMetadata = target.addObject( fieldReference );
....
....
indexedAttributeMetadata.addValue(fieldName,attributeValue.toString());
}