-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: FieldBridge - fields, created in the impl. are not stored
PostPosted: Wed Nov 05, 2008 10:13 am 
Newbie

Joined: Wed Nov 05, 2008 9:50 am
Posts: 2
Location: St.Petersburg
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 );
    }

}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 12:30 pm 
Newbie

Joined: Wed Nov 05, 2008 9:50 am
Posts: 2
Location: St.Petersburg
Never mind, I finally figured out the problem. It was the hibernate session issue. When loading enities from the database inside a FieldBridge's set method, a new session must beexplicitly opened via SF.openSession(). This solved the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.