-->
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: Faceted Search
PostPosted: Sat Feb 14, 2009 3:44 pm 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi

I am looking at implementing faceted search using Hibernate Search and have a question and was hoping to get some guidance.

I came across the following code from http://forum.hibernate.org/viewtopic.php?t=993752

Code:
public Map<String,Integer> getAllHits(String field) {
Map<String,Integer> hits = new HashMap<String,Integer>();
IndexReader reader = IndexReader.open( getDirectory() );
TermEnum terms = reader.terms( new Term( field, "" ) );

while( field.equals( terms.term().field() ) ){
hits.put( terms.term().text(), terms.docFreq() );

if( !terms.next() )
break;

}
}


This works really well but I was wondering what approach to take for filtering the results for example only hits for a particular user or a another search term?

Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 10:21 am 
Hibernate Team
Hibernate Team

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

I think I would try to work with filters. Have a look at this post - http://sujitpal.blogspot.com/2007/04/lu ... -with.html
The code examples are based on 'pure' Lucene, but can be applied to Hibernate Search as well.

The code examples are still working with BitSets whereas DocIdSet should be used now, but the same principles apply.

--Hardy


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.