incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esjew...@apache.org
Subject svn commit: r899991 - in /incubator/esme/trunk/server/src: main/resources/props/ main/scala/org/apache/esme/api/ main/scala/org/apache/esme/model/ test/scala/org/apache/esme/api/
Date Sat, 16 Jan 2010 17:05:01 GMT
Author: esjewett
Date: Sat Jan 16 17:04:59 2010
New Revision: 899991

URL: http://svn.apache.org/viewvc?rev=899991&view=rev
Log:
Tag filtering on pools/POOLID/messages?history=10&filter_tags=test,tags query

Modified:
    incubator/esme/trunk/server/src/main/resources/props/compass.cfg.xml
    incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml
    incubator/esme/trunk/server/src/main/resources/props/compass.jdbc.cfg.xml
    incubator/esme/trunk/server/src/main/resources/props/compass.jndi.cfg.xml
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
    incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala

Modified: incubator/esme/trunk/server/src/main/resources/props/compass.cfg.xml
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/resources/props/compass.cfg.xml?rev=899991&r1=899990&r2=899991&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/resources/props/compass.cfg.xml (original)
+++ incubator/esme/trunk/server/src/main/resources/props/compass.cfg.xml Sat Jan 16 17:04:59
2010
@@ -10,8 +10,7 @@
       <file path="compass-index"/>
     </connection>
     <searchEngine >
-      <analyzer name="default" type="Stop" />
-      <analyzer name="tag" type="Standard" />
+      <analyzer name="default" type="Stop" />    
       <analyzer name="pool" type="Standard" />
       <analyzer name="stemming" type="Snowball" snowballType="English">
             <stopWords>

Modified: incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml?rev=899991&r1=899990&r2=899991&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml (original)
+++ incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml Sat Jan
16 17:04:59 2010
@@ -10,8 +10,7 @@
       <file path="compass-index"/>
     </connection>
     <searchEngine >
-      <analyzer name="default" type="Stop" />
-      <analyzer name="tag" type="Standard" />
+      <analyzer name="default" type="Stop" />   
       <analyzer name="pool" type="Standard" />
       <analyzer name="stemming" type="Snowball" snowballType="English">
             <stopWords>

Modified: incubator/esme/trunk/server/src/main/resources/props/compass.jdbc.cfg.xml
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/resources/props/compass.jdbc.cfg.xml?rev=899991&r1=899990&r2=899991&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/resources/props/compass.jdbc.cfg.xml (original)
+++ incubator/esme/trunk/server/src/main/resources/props/compass.jdbc.cfg.xml Sat Jan 16 17:04:59
2010
@@ -17,8 +17,7 @@
 
     </connection>
     <searchEngine >
-      <analyzer name="default" type="Stop" />
-      <analyzer name="tag" type="Standard" />  
+      <analyzer name="default" type="Stop" />   
       <analyzer name="pool" type="Standard" />
       <analyzer name="stemming" type="Snowball" snowballType="English">
             <stopWords>

Modified: incubator/esme/trunk/server/src/main/resources/props/compass.jndi.cfg.xml
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/resources/props/compass.jndi.cfg.xml?rev=899991&r1=899990&r2=899991&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/resources/props/compass.jndi.cfg.xml (original)
+++ incubator/esme/trunk/server/src/main/resources/props/compass.jndi.cfg.xml Sat Jan 16 17:04:59
2010
@@ -15,8 +15,7 @@
 
     </connection>
     <searchEngine >
-      <analyzer name="default" type="Stop" />
-      <analyzer name="tag" type="Standard" /> 
+      <analyzer name="default" type="Stop" />   
       <analyzer name="pool" type="Standard" />
       <analyzer name="stemming" type="Snowball" snowballType="English">
             <stopWords>

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala?rev=899991&r1=899990&r2=899991&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala Sat Jan 16 17:04:59
2010
@@ -609,10 +609,22 @@
             tx = session.beginTransaction()
             val queryBuilder: CompassQueryBuilder = session.queryBuilder()
 
-            val query: CompassQuery = queryBuilder.bool()
+            val tagQuery = queryBuilder.bool()
+
+            for(tags <- S.param("filter_tags");
+                tag <- tags.split(",")) {
+              tagQuery.addMust(queryBuilder.term("tags", tag.split(" ").mkString("_"))) 
 
+            }
+
+            val non_tag_query = queryBuilder.bool()
               .addMust(queryBuilder.term("pool", poolNum))
-              .toQuery()
+
             
+            val query = if(S.param("filter_tags").isDefined)
+              non_tag_query.addMust(tagQuery.toQuery).toQuery()                         
   
+            else
+              non_tag_query.toQuery()
+
             val hitlist = query
               .addSort("when", CompassQuery.SortPropertyType.STRING, CompassQuery.SortDirection.REVERSE)
               .hits().detach(0, num)

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala?rev=899991&r1=899990&r2=899991&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala Sat Jan
16 17:04:59 2010
@@ -476,10 +476,11 @@
   @SearchableProperty{val format="yyyy-MM-dd mm:ss"}
   def getWhen = new java.util.Date(when.is)
 
-  @SearchableProperty{val termVector=TermVector.YES, val analyzer="tag"}
+  @SearchableProperty{val termVector=TermVector.YES, val analyzer="default"}
   def getTags:String = {
-    // Create a string of space-separated tags, with the spaces in each tag converted to
underscores
-    tags.map(x => x.split(" ").mkString("_")) mkString " "
+    // Create a string of space-separated tags, with the spaces in each tag converted to
underscores 
+    val tagString: String = tags.map(x => x.split(" ").mkString("_")) mkString " "
+    tagString
   } 
 
   @SearchableProperty{val termVector=TermVector.YES, val analyzer="pool"}

Modified: incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala?rev=899991&r1=899990&r2=899991&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala (original)
+++ incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala Sat Jan
16 17:04:59 2010
@@ -356,8 +356,7 @@
             "tags" -> "test,tag",
             "pool" -> "test_pool1")
           all_msgs <- session.get("user/messages?timeout=2")
-        } {          
-          println(all_msgs.xml)
+        } {                    
           mess_res.code must be equalTo 200
           (all_msgs.xml \ "messages") must \\(<body>test POST message</body>)
           (all_msgs.xml \ "messages") must \\(<tags><tag>Test</tag><tag>Tag</tag></tags>)
@@ -693,7 +692,7 @@
           session_res.code must be equalTo 204
         }                                                   
       }
-    }
+    }    
 
     "/pools/POOLID/messages?history=10 GET" in {
       "with valid session" in {
@@ -704,19 +703,52 @@
             "message" -> "test message for pool history",
             "pool" -> "test_pool5")
           res <- sess.get("pools/5/messages?history=10")
-        } {                             
-          res.code must be equalTo 200  
+        } {                                
+          res.code must be equalTo 200          
           (res.xml \ "messages") must \\(<id>{theUser.id.toString}</id>)
           (res.xml \ "messages") must \\(<body>test message for pool history</body>)
         }
-      }
+      }     
 
+      "with tag restrictions" in {
+        for{
+          sess <- post_session 
+          pool_res <- sess.post("pools", "poolName" -> "test_pool6") 
+		  mess_res <- sess.post("user/messages",
+            "message" -> "test message for pool #history",
+            "pool" -> "test_pool6")                      
+          mess_res <- sess.post("user/messages",
+	        "message" -> "test message for pool history with tags test, tag",
+	        "pool" -> "test_pool6",
+	        "tags" -> "test, tag") 
+	      mess_res <- sess.post("user/messages",
+	        "message" -> "test message for pool history with tag test",
+	        "pool" -> "test_pool6",
+	        "tags" -> "test,crazycrazy")
+	      mess_res <- sess.post("user/messages",
+	        "message" -> "test message for pool history with tag tag",
+	        "pool" -> "test_pool6",
+	        "tags" -> "tag")     
+	      wait <- sleep(2000)
+          res1 <- sess.get("pools/6/messages?history=10&filter_tags=test")
+          res2 <- sess.get("pools/6/messages?history=10&filter_tags=test,tag")
+        } {                    
+          res1.code must be equalTo 200   
+          res2.code must be equalTo 200
+          (res1.xml \ "messages") must \\(<id>{theUser.id.toString}</id>)
+          (res1.xml \ "messages") must \\(<body>test message for pool history with
tag test</body>)
+          (res1.xml \ "messages") must \\(<body>test message for pool history with
tags test, tag</body>)
+          (res2.xml \ "messages") must \\(<body>test message for pool history with
tags test, tag</body>)
+          (res2.xml \ "messages").length must be equalTo 1
+        }
+      }   
+ 
       "with no session returns 403 (forbidden)" in {
         for (session_res <- get("pools/1/messages?history=10")) {
           session_res.code must be equalTo 403
         }
       }
-    }
+    }       
 
     "/pools/POOLID/messages?timeout=2 GET" in {
       "with valid session" in {



Mime
View raw message