-->
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.  [ 4 posts ] 
Author Message
 Post subject: errors querying on stringbridge/fieldbridge
PostPosted: Thu Feb 24, 2011 11:17 am 
Newbie

Joined: Thu Jul 19, 2007 11:21 am
Posts: 12
Seeing that this seems to work for so many people, it should be really simple to solve, perhaps someone spots an issue here cause i am really at a loss of what causes it.

So, i am trying to translate an object to string by implementing the FieldBridge interface.

relevant excerpt from bridge
Code:
    public void set(String name, Object value, org.apache.lucene.document.Document document, LuceneOptions luceneOptions) {
        luceneOptions.addFieldToDocument("document", convert((Document) value), document);
    }


annotation
Code:
    @Field(index = Index.TOKENIZED, store = Store.NO)
    @FieldBridge(impl = DocumentBridge.class)
    public Document getDocument() {
        return this.document;
    }


full-text search
Code:
BooleanQuery query = new BooleanQuery();
...
query.add(qbDocuments.keyword().onField("document").matching(search.getSimpleQuery()).createQuery(), SHOULD);


the indexation goes fine (in order for indexation to happen i have to add the @Field annotation though), i can query the docuemtn in luke.

the query part however yields this error

Code:
org.hibernate.search.SearchException: FieldBridge class ...document.DocumentBridgedoes not have a objectToString method


prior to the FieldBridge implementation I have tried the StringBridge alternative which also ended up with this error:

Code:
FieldBridge class org.hibernate.search.bridge.String2FieldBridgeAdaptordoes not have a objectToString method


I am building this with hibernate-core v.3.6.0.Final and hibernate-search v.3.3.0.Final and hibernate-commons-annotations v.3.2.0.Final and lucene-core v.3.0.3

thanks for any idea on what my problem would be.

--val


Top
 Profile  
 
 Post subject: Re: errors querying on stringbridge/fieldbridge
PostPosted: Thu Feb 24, 2011 2:53 pm 
Newbie

Joined: Thu Jul 19, 2007 11:21 am
Posts: 12
Tried another approach using lucene query -- pretty much the example from hibernate search in action:

the lucene query end result is something like: org.apache.lucene.index.Term (field/text) "document:house"

this doesn't bring back any results just like the previous approach while ignoring the bridge. at the same time luke retrieves 2 documents..


Top
 Profile  
 
 Post subject: SOLVED
PostPosted: Thu Feb 24, 2011 5:03 pm 
Newbie

Joined: Thu Jul 19, 2007 11:21 am
Posts: 12
Solved it by carefully debugging my queries..it turns out that the QueryBuilder logic (for reuse sake some inheritance mechanisms depending on entities that are being used) -- not shown in my code -- wasn't using the right entity builder. copy/paste bug, that is. however, one must admit the error messages i received were quite strange..

finally many thanks to developers for this great tool!


Top
 Profile  
 
 Post subject: Re: errors querying on stringbridge/fieldbridge
PostPosted: Fri Feb 25, 2011 6:45 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
ah, I'm glad you solved it.
I wonder if we could make that safer, or be able to detect it in some way to throw a proper error message - not easy as we build org.apache.lucene stuff and that is then fed back to our API so we can't attach "type safe" metadata to it.
If you have ideas or want to help out: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-697

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.