-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can I check if given Entity matches given query?
PostPosted: Thu Nov 18, 2010 11:54 am 
Newbie

Joined: Thu Nov 18, 2010 11:04 am
Posts: 2
Dear Hibernate Community,

Is there any runtime fast method to check if one given JPA entity matches given Hibernate Search query?

Use case: we have a query "refactor" and entity Book{title, description, author...}. We have 500 000 books in database but we allready narrowed search set to 10 books (e.g. "Refactoring to patterns", "Happy refactoring", "Clean code" etc.).
We would like to check which of these 10 books matches the query. We want to take into account all Analyzers, Bridges etc. that are definied on entity Book.

Kind regards,
Krzysztof Kowalczyk


Top
 Profile  
 
 Post subject: Re: Can I check if given Entity matches given query?
PostPosted: Fri Nov 19, 2010 4:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I am not sure I understand your question correctly, but I will try to to provide some ideas depending on how I understood it.
You have a database with 500 000 books and out of these you selected 10. I am assuming this selection/search is not done via a Lucene query, otherwise you would already know that they match, right? Now you want to know if any of these 10 books matches a given Lucene query.
What you can do is build your Lucene query and then combine this query using a BooleanQuery with a set of TermQueries matching the entity ids. Each indexed document contains the entity id (use FullTextQuery.ID as field name). Run the BooleanQuery and see if you get a result.

Quote:
We want to take into account all Analyzers, Bridges etc. that are definied on entity Book.

Hibernate Search will do this automatically for you.

--Hardy


Top
 Profile  
 
 Post subject: Re: Can I check if given Entity matches given query?
PostPosted: Fri Nov 19, 2010 6:55 am 
Newbie

Joined: Thu Nov 18, 2010 11:04 am
Posts: 2
Hi,

Thanks for the answer. The problem is that we use tree structure. We need to group and paginate on some top level element (e.g. Shelve) but our query is more concerned about children (e.g. books). For example we have shelves and books on them. We have already found some shelves with a Lucene Query (e.g. a shelve for books starting with letter "A"), but we have problem that shelve contains also some books "B", so we need reuse the query to find only books A from the already found shelve "A". Of course the problem is more complex and it would take long to explain the real domain.

Kind regards,
Krzysztof Kowalczyk


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