Hi,
I have a strange problem - tried to implement a custom FieldBridge in order to add a couple of fields with the data fromother entities into the index.
The problem, that all new fields, that my FieldBridge implementation creates, are not stored into the lucene index. Yes, I do call document.add(...) to add newly created fields into the document. When walking inside my bridge set(...) method with the debugger, I do see that fields are fine, even more, at the end of set(...) method, the document instance is also populated with the fields.
But when I try to search or go and open index with Luke - there are no fields, added by my FieldBridge. I do see added/changed fields from entity annotation, so the indexing is not broken. Simply all fields, created inside my FieldBridge are ignored and not stored.
Am I doing somehting worng ?
Inside the bridge, I do run an HQL query in order to fetch a small amount of other entities I want to extract informaion from. This is a read-only query - I do not modify anything. But this seems not to be a reason, because I simplified my bridge to insert a fixed dummy field but this did not help.
Thanks in advance.
P.S. I'm using JDK 1.6, latest GA's of Hibernate and Hibernate-search, also tried current beta of Hibernate-search, but with the same result.
Here is the entity I index:
Code:
@Indexed
@Analyzer(impl = ArchiveFulltextAnalyzer.class)
@ClassBridge(
name = "fx",
index = Index.UN_TOKENIZED,
store = Store.YES,
impl = AttributeValueToCardMapperBridge.class
)
public class ArchiveObject implements Serializable, Cloneable {
private transient boolean localModificationFlag = false;
@DocumentId
private String objectId = "";
@Fields({@Field(index = Index.TOKENIZED, store = Store.NO), @Field(name = "abstract",
index = Index.TOKENIZED, store = Store.NO)})
private String keywords = "";
@Fields({@Field(index = Index.TOKENIZED, store = Store.NO), @Field(name = "abstract",
index = Index.TOKENIZED, store = Store.YES)})
private String name = "";
. . .
Here is the current bridge implementation:
Code:
public class AttributeValueToCardMapperBridge implements FieldBridge
{
public void set ( String s, Object o, Document document, Field.Store store, Field.Index index,
Float aFloat )
{
if ( !( o instanceof Card ) )
{
return;
}
indexAttributes ( s, ( Card ) o, document, store, index, aFloat );
}
public void indexAttributes ( String name, Card card, Document document, Field.Store store,
Field.Index index, Float aFloat )
{
Field funny = new Field ( "funny", "xyz", store, index );
funny.setBoost ( aFloat );
document.add ( funny );
}
}