-->
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: Hibernate Search - query help needed
PostPosted: Sun Mar 18, 2012 1:20 pm 
Beginner
Beginner

Joined: Thu Apr 14, 2005 4:29 am
Posts: 28
Hi,

I use Hibernate Search and have now the following problem. I don't want a query for a particular content but rather for all existing lucene data in a field (for field proposals in the ui).

Code:
@Entity
@Indexed
@Boost(2f)
public class Conference {
    @Id
    ..
    @DocumentId
    private String id;

    @Column(nullable = false, length = 200)
    @Field(index = Index.TOKENIZED, store = Store.NO, boost = @Boost(2f))
    private String name;

    @Column(length = 150)
    @Field(index = Index.TOKENIZED, store = Store.YES, boost = @Boost(1.3f))
    private String cities;


Sample content:

id | name | cities
.. | abc | London, Paris, Berlin
.. | bcd | Paris, New York City, London
.. | cde |
.. | def | Berlin, Dallas, London


The query should return a set with the 5 elements: Berlin, Dallas, London, New York City and Paris.

What’s the way to do this, via org.hibernate.search.query.dsl.QueryBuilder or org.apache.lucene.index.IndexReader? I checked both but found no solution.

Every help is very appreciated.

Thanks a lot,
Detlev


Top
 Profile  
 
 Post subject: Re: Hibernate Search - query help needed
PostPosted: Tue Mar 20, 2012 12:40 pm 
Hibernate Team
Hibernate Team

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

detlev wrote:
Hi,
The query should return a set with the 5 elements: Berlin, Dallas, London, New York City and Paris.


No query would return this for you, since w/ Hibernate Search you would get managed Conference instances back. At least in per default.
You could use the IndexReader for Conferences and its IndexReader.terms(Term t) method. Depending on how you are going to use it, it might work. For example I could imagine that you use it once and cache the cities. I definitely would not use it for every request.

One other way could be to model the Cities are their own class/entities. Depending on your use case that might or might not make sense. You can send build a separate city index and query it which is probably better performance. You could use wildcard queries as the user types.

Well, just some ideas.

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate Search - query help needed
PostPosted: Tue Mar 20, 2012 12:42 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Of this would in theory also be a good use case for faceting. However, Search does at the moment only support faceting for single values fields - https://hibernate.onjira.com/browse/HSEARCH-900


Top
 Profile  
 
 Post subject: Re: Hibernate Search - query help needed
PostPosted: Tue Mar 27, 2012 3:08 pm 
Beginner
Beginner

Joined: Thu Apr 14, 2005 4:29 am
Posts: 28
Thanks, that helped me!


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.