Thursday, 25 September 2008
JBCS 1.0.0 CR1 powered up
Hello hello all, I come out of the darkness for the first time in a couple of weeks: -
As the title suggests, the first release candidate for JBoss Cache Searchable is up and running - download here. Some of you who are more inquisitive might be wondering what's actually changed from Beta 1.
Here's what's new. The 2 iterator methods on CacheQuery - iterator() and lazyIterator() - both can be called with integer parameters. Your fetchSize - your object buffer. This doesn't mean that the method calls with no parameters won't work, that just delegates to the method with parameters and gives a default parameter of 1. If you're more interested and want to dig deeper, have a look on fisheye.
As usual, have a play around and if there are any problems, you can find me on the forums.
On the horizon, I'm looking at releasing a version of the searchable-cache that depends on JBoss Cache 3.0.0. Personally, I'm quite excited to see how searchable-cache performance will change when it's depending on 3.0.0. I will keep you updated :).
Thanks for listening,
Navin.
Posted by Navin Surtani at 18:45 0 comments
Labels: cache, hibernate search, lucene, search, searchable, searchable cache
Thursday, 21 August 2008
JBCS Beta 1 released!
Some of you who may have read this blog a few weeks ago might have been excited to hear about JBoss Cache Searchable. For those of you who don't know about it - it provides a query interface on JBoss Cache. That is to say, you can now search the cache!
Why is this so cool?
You don't need to hang onto your keys to get objects out of the cache. Plus, you can now get multiple results from the cache from searching (e.g. all people named "Steve") whereas traditionally you will only get a specific object out (e.g. "Steve Jones"). Previously, the major difference between a cache and a database was the fact that you could not query it - and we've just changed that :).
Beta 1 for JBoss Cache Searchable is now out, so have a look, play around and let us know what you think about it. For more information, look at the wiki. This is available for download on SourceForge.
Also, I got to make my first proper presentation about this ( wOOt!) and it was to a team of developers at Sri Lanka's biggest mobile phone network - Dialog. Yeah you guys may not have Sri Lanka pop into your minds for cutting-edge technology (even if you know where it is) but these guys do have about 4 million subscribers and may soon use JBCS on a multi-million dollar project to maintain subscriber profiles. I have attached a pdf version if anyone wants to have a look.
'Til later,
Navin.
Posted by Navin Surtani at 06:53 3 comments
Labels: beta, hibernate search, jboss cache, search, searchable
Friday, 4 July 2008
JBoss Cache Searchable
For those who don't know yet, I've been working on a GSoC (Google Summer of Code) project and is the integration package between JBoss Cache and Hibernate Search. Basically, this enables users to search through JBoss Cache using Hibernate Search. According to another Surtani at JBoss, it's a very cool project and as far as I'm concerned it's just a fun piece of code to be working on :). It's been an interesting, topsy-turvy ride over the past couple of months getting all this stuff to work - and is still not optimised, but that will be done over the next couple of weeks. Here is some basic information I copied out from the wiki.
About this package
The goal is to add search capabilities to JBoss Cache. We achieve this by using Hibernate Search to index user objects as they are added to the cache and modified. The cache is queried by passing in a valid Apache Lucene query which is then used to search through the indexes and retrieve matching objects from the cache.
Usage
How will I use jbosscache-searchable?
You can create an instance of a searchable-cache. People who use jbosscache-core frequently will find this quite easy as it is very similar to creating an instance of the cache.
The SearchableCache interface is a sub-interface of Cache. Hence, it has the usual put(), get() and remove() methods on it. However, it also has the createQuery() method. This will return a CacheQuery object with which the list() method can be called. This will return all the results from the search in a list. You can also call an iterator() method on it - which returns a QueryResultIterator which is a sub-interface of the jdk's ListIterator.
How to create a searchable cache, code example: -
Start by creating a core cache.
Cache cache = new DefaultCacheFactory().createCache();
Similar to that create a searchable cache. As parameters, you must pass in the cache instance that you have created and the classes that you wish to be searched.
SearchableCache searchable = new
SearchableCacheFactory().createSearchableCache(cache, Person.class);
Lets say that I have 100 objects in this class and I want to search for the people with name John.As with Hibernate Search, create a Lucene query and a QueryParser.
QueryParser queryParser = new QueryParser("name", new StandardAnalyzer());
"name" is the field within Person that I want to be searching through.
Query luceneQuery = queryParser.parse("John");
"John" is the word within the name field that I want to be searching for.
CacheQuery cacheQuery = searchableCache.createQuery(luceneQuery);
The cacheQuery object will now have all the instances of Person with name John. I can now put all of these into a List: -
List results = cacheQuery.list();
Annotations on your classes.
For the classes that you want to be searched, you will have to annotate them with Hibernate Search annotations.
- @ProvidedId - Firstly, you should not annotate a field with @DocumentId as normally with Hibernate Search. The @ProvidedId is so that Hibernate Search will not expect a @DocumentId and will know that you will provide one later. This is to say that a class with @ProvidedId doesn't need a @DocumentId. Although at this point it has not been tested, a @DocumentId in a field which is in a class that has a @ProvidedId should not break your system. This is a class annotation.
- @Indexed - This is so that Hibernate Search will index the class in Lucene and is annotated on the class.
- @Field - Hibernate Search will put all class-fields with this annotation into the index. With each @Field, you must also specify that the ''store'' property is set to ''yes''. Otherwise the field will not be stored. For example: -@Field (store = STORE.YES)
Also see http://www.hibernate.org/hib_docs/search/api/overview-summary.html for more information on annotations.
For more information, see the wiki page.
Posted by Navin Surtani at 14:23 0 comments
Labels: hibernate, hibernate search, index, jboss cache, lucene, query, search