Author: navssurtani
Date: 2008-06-30 15:22:09 -0400 (Mon, 30 Jun 2008)
New Revision: 6131
Modified:
searchable/trunk/pom.xml
searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java
Log:
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2008-06-30 19:10:15 UTC (rev 6130)
+++ searchable/trunk/pom.xml 2008-06-30 19:22:09 UTC (rev 6131)
@@ -39,7 +39,7 @@
<dependency>
<groupId>org.hibernate.sandbox</groupId>
<artifactId>hibernate-search-gsoc</artifactId>
- <version>3.1.0-SNAPSHOT</version>
+ <version>3.1.1-SNAPSHOT</version>
</dependency>
<dependency>
@@ -54,6 +54,13 @@
<version>1.4.2</version>
</dependency>
+ <dependency>
+ <groupId>org.hibernate.apache.lucene.solr</groupId>
+ <artifactId>apache-solr-analyzer</artifactId>
+ <version>1.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<plugins>
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java 2008-06-30
19:10:15 UTC (rev 6130)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java 2008-06-30
19:22:09 UTC (rev 6131)
@@ -69,9 +69,8 @@
public String getDocumentId()
{
- if (key != null || fqn != null)
+ if (key == null || fqn == null)
{
-
throw new IllegalArgumentException("Either your key or fqn is null. Please
check again.");
}
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
---
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-06-30
19:10:15 UTC (rev 6130)
+++
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-06-30
19:22:09 UTC (rev 6131)
@@ -51,16 +51,18 @@
if (log.isWarnEnabled()) log.warn("You haven't passed in any classes to
index. Is this an error?");
}
- // Step 1: Add cache listener to listen for events happening in the cache.
- SearchableListener listener = new SearchableListener();
- c.addCacheListener(listener);
-
- // step 2: create hibernate search searchImpl
+ // step 1: create hibernate search searchImpl
Cfg cfg = new SearchableCacheCfgImpl(classes, properties);
// set classes in the cfg
SearchFactoryImpl searchImpl = new SearchFactoryImpl(cfg);
+
+ // Step 2: Add cache listener to listen for events happening in the cache.
+ SearchableListener listener = new SearchableListener(searchImpl);
+ c.addCacheListener(listener);
+
+
// step 3: create the searchable cache delegate.
SearchableCache sc = new SearchableCacheImpl(c, searchImpl);
return sc;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
===================================================================
---
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java 2008-06-30
19:10:15 UTC (rev 6130)
+++
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java 2008-06-30
19:22:09 UTC (rev 6131)
@@ -12,8 +12,8 @@
/**
* @author Navin Surtani - navin(a)surtani.org
- *
- * Class that listens for changes made to the cache so that the Lucene indexes can be
updated.
+ * <p/>
+ * Class that listens for changes made to the cache so that the Lucene indexes
can be updated.
*/
@CacheListener
@@ -21,10 +21,14 @@
{
private SearchFactoryImpl searchFactory;
+ public SearchableListener(SearchFactoryImpl searchFactory)
+ {
+ this.searchFactory = searchFactory;
+ }
+
/**
* Takes in a NodeModifiedEvent and updates the Lucene indexes using methods on the
NodeModifiedEvent class.
*
- *
* @param event that has occured - or a node that has been changed. {@link
org.jboss.cache.notifications.event.NodeModifiedEvent}
*/
@@ -72,7 +76,7 @@
/**
* If the modification type is DELETE_DATA then this method will be called.
* Takes in the event as a parameter
- *
+ *
* @param event that has occured - or a node that has been changed. {@link
org.jboss.cache.notifications.event.NodeModifiedEvent}
*/
void handleDeleteData(NodeModifiedEvent event)
Modified:
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
===================================================================
---
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-06-30
19:10:15 UTC (rev 6130)
+++
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-06-30
19:22:09 UTC (rev 6131)
@@ -68,7 +68,7 @@
public void testSimple() throws ParseException
{
- queryParser = new QueryParser("field", new StandardAnalyzer());
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
luceneQuery = queryParser.parse("playing");
cacheQuery = searchableCache.createQuery(luceneQuery);
@@ -80,6 +80,8 @@
public void testMultipleResults() throws ParseException
{
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
luceneQuery = queryParser.parse("Goat");
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
@@ -92,7 +94,7 @@
public void testModified() throws ParseException
{
- queryParser = new QueryParser("field", new StandardAnalyzer());
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
luceneQuery = queryParser.parse("playing");
cacheQuery = searchableCache.createQuery(luceneQuery);
@@ -116,6 +118,8 @@
public void testAdded() throws ParseException
{
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
luceneQuery = queryParser.parse("Goat");
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
@@ -142,6 +146,8 @@
public void testRemoved() throws ParseException
{
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
luceneQuery = queryParser.parse("Goat");
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java 2008-06-30
19:10:15 UTC (rev 6130)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java 2008-06-30
19:22:09 UTC (rev 6131)
@@ -2,10 +2,12 @@
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.ProvidedId;
/**
* @author Navin Surtani - navin(a)surtani.org
*/
+@ProvidedId
@Indexed
public class Person
{
Show replies by date