Author: yonik
Date: Tue Apr 29 14:07:25 2008
New Revision: 652124

URL: http://svn.apache.org/viewvc?rev=652124&view=rev
Log:
SOLR-334: change local params syntax from angle brackets to curly braces

Modified:
    
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
    lucene/solr/trunk/src/java/org/apache/solr/search/FunctionQParser.java
    lucene/solr/trunk/src/java/org/apache/solr/search/QueryParsing.java
    lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java
    lucene/solr/trunk/src/test/org/apache/solr/search/TestQueryTypes.java

Modified: 
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java?rev=652124&r1=652123&r2=652124&view=diff
==============================================================================
--- 
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
 (original)
+++ 
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
 Tue Apr 29 14:07:25 2008
@@ -292,7 +292,7 @@
           String facet_q = (String)facet_queries.getName(i);
           long count = ((Number)facet_queries.getVal(i)).longValue();
 
-          // expect <!field f=field>value style params
+          // expect {!field f=field}value style params
           SolrParams qparams = QueryParsing.getLocalParams(facet_q,null);
           String field = qparams.get(QueryParsing.F);
           String val = qparams.get(QueryParsing.V);
@@ -302,7 +302,7 @@
           // Find the right constraint count for this value
           ShardFacetCount sfc = dff.counts.get(val);
 // TODO REMOVE
-System.out.println("Got " + facet_q + " , refining count: " + sfc + " += " + 
count);
+// System.out.println("Got " + facet_q + " , refining count: " + sfc + " += " 
+ count);
 
           sfc.count += count;
 
@@ -490,7 +490,7 @@
     sf = rb.req.getSchema().getField(field);
     missingMax = new long[rb.shards.length];
     counted = new OpenBitSet[rb.shards.length];
-    queryPrefix = "<!field f=" + field + '>';
+    queryPrefix = "{!field f=" + field + '}';
   }
 
   void add(int shardNum, NamedList shardCounts, int numRequested) {

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/FunctionQParser.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/FunctionQParser.java?rev=652124&r1=652123&r2=652124&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/FunctionQParser.java 
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/FunctionQParser.java Tue 
Apr 29 14:07:25 2008
@@ -155,7 +155,7 @@
           throw new ParseException("Nested local params must have value in v 
parameter.  got '" + qs + "'");
         }
       } else {
-        throw new ParseException("Nested function query must use $param or 
<!v=value> forms. got '" + qs + "'");
+        throw new ParseException("Nested function query must use $param or 
{!v=value} forms. got '" + qs + "'");
       }
   
       sp.pos += end-start;  // advance past nested query

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/QueryParsing.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/QueryParsing.java?rev=652124&r1=652123&r2=652124&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/QueryParsing.java 
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/QueryParsing.java Tue Apr 
29 14:07:25 2008
@@ -52,6 +52,8 @@
   public static final String F = "f";      // field that a query or command 
pertains to
   public static final String TYPE = "type";// type of this query or command
   public static final String DEFTYPE = "defType"; // default type for any 
direct subqueries
+  public static final String LOCALPARAM_START = "{!";
+  public static final char LOCALPARAM_END = '}';
 
   /** 
    * Helper utility for parsing a query using the Lucene QueryParser syntax. 
@@ -116,31 +118,31 @@
   // note to self: something needs to detect infinite recursion when parsing 
queries
   static int parseLocalParams(String txt, int start, Map<String,String> 
target, SolrParams params) throws ParseException {
     int off=start;
-    if (!txt.startsWith("<!",off)) return start;
+    if (!txt.startsWith(LOCALPARAM_START,off)) return start;
     StrParser p = new StrParser(txt,start,txt.length());
-    p.pos+=2; // skip over "<!"
+    p.pos+=2; // skip over "{!"
 
     for(;;) {
       /*
       if (p.pos>=txt.length()) {
-        throw new ParseException("Missing '>' parsing local params '" + txt + 
'"');
+        throw new ParseException("Missing '}' parsing local params '" + txt + 
'"');
       }
       */
       char ch = p.peek();
-      if (ch=='>') {
+      if (ch==LOCALPARAM_END) {
         return p.pos+1;
       }
 
       String id = p.getId();
       if (id.length()==0) {
-        throw new ParseException("Expected identifier '>' parsing local params 
'" + txt + '"');
+        throw new ParseException("Expected identifier '}' parsing local params 
'" + txt + '"');
 
       }
       String val=null;
 
       ch = p.peek();
       if (ch!='=') {
-        // single word... treat <!func> as ""=func for easy lookup
+        // single word... treat {!func} as type=func for easy lookup
         val = id;
         id = TYPE;
       } else {
@@ -157,7 +159,7 @@
             val = params.get(pname);
           }
         } else {
-          // read unquoted literal ended by whitespace or '>'
+          // read unquoted literal ended by whitespace or '}'
           // there is no escaping.
           int valStart = p.pos;
           for (;;) {
@@ -165,7 +167,7 @@
               throw new ParseException("Missing end to unquoted value starting 
at " + valStart + " str='" + txt +"'");
             }
             char c = p.val.charAt(p.pos);
-            if (c=='>' || Character.isWhitespace(c)) {
+            if (c==LOCALPARAM_END || Character.isWhitespace(c)) {
               val = p.val.substring(valStart, p.pos);
               break;
             }
@@ -179,11 +181,11 @@
 
   /**
    *  "foo" returns null
-   *  "<!prefix f=myfield>yes" returns type="prefix",f="myfield",v="yes"
-   *  "<!prefix f=myfield v=$p>" returns 
type="prefix",f="myfield",v=params.get("p")
+   *  "{!prefix f=myfield}yes" returns type="prefix",f="myfield",v="yes"
+   *  "{!prefix f=myfield v=$p}" returns 
type="prefix",f="myfield",v=params.get("p")
    */
   public static SolrParams getLocalParams(String txt, SolrParams params) 
throws ParseException {
-    if (txt==null || !txt.startsWith("<!")) {
+    if (txt==null || !txt.startsWith(LOCALPARAM_START)) {
       return null;      
     }
     Map<String,String> localParams = new HashMap<String,String>();

Modified: lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java?rev=652124&r1=652123&r2=652124&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java 
(original)
+++ lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java Tue 
Apr 29 14:07:25 2008
@@ -453,8 +453,8 @@
 
     // these queries should be exactly ordered and scores should exactly match
     query("q","*:*", "sort",i1+" desc");
-    query("q","<!func>"+i1);
-    query("q","<!func>"+i1, "fl","*,score");  // even scores should match 
exactly here
+    query("q","{!func}"+i1);
+    query("q","{!func}"+i1, "fl","*,score");  // even scores should match 
exactly here
 
     handle.put("highlighting", UNORDERED);
     handle.put("response", UNORDERED);

Modified: lucene/solr/trunk/src/test/org/apache/solr/search/TestQueryTypes.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/search/TestQueryTypes.java?rev=652124&r1=652123&r2=652124&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/search/TestQueryTypes.java 
(original)
+++ lucene/solr/trunk/src/test/org/apache/solr/search/TestQueryTypes.java Tue 
Apr 29 14:07:25 2008
@@ -24,6 +24,7 @@
   public String getSolrConfigFile() { return "solrconfig.xml"; }
   public String getCoreName() { return "basic"; }
 
+
   public void setUp() throws Exception {
     // if you override setUp or tearDown, you better call
     // the super classes version
@@ -39,7 +40,7 @@
   public void testQueryTypes() {
     assertU(adoc("id","1", "v_t","Hello Dude"));
     assertU(adoc("id","2", "v_t","Hello Yonik"));
-    assertU(adoc("id","3", "v_s","<!literal>"));
+    assertU(adoc("id","3", "v_s","{!literal}"));
     assertU(adoc("id","4", "v_s","other stuff"));
     assertU(adoc("id","5", "v_f","3.14159"));
     assertU(adoc("id","6", "v_f","8983"));
@@ -49,105 +50,105 @@
 
     // Some basic tests to ensure that parsing local params is working
     assertQ("test prefix query",
-            req("q","<!prefix f=v_t>hel")
+            req("q","{!prefix f=v_t}hel")
             ,"//[EMAIL PROTECTED]'2']"
             );
 
     assertQ("test raw query",
-            req("q","<!raw f=v_t>hello")
+            req("q","{!raw f=v_t}hello")
             ,"//[EMAIL PROTECTED]'2']"
             );
     assertQ("test raw query",
-            req("q","<!raw f=v_t>Hello")
+            req("q","{!raw f=v_t}Hello")
             ,"//[EMAIL PROTECTED]'0']"
             );
     assertQ("test raw query",
-            req("q","<!raw f=v_f>1.5")
+            req("q","{!raw f=v_f}1.5")
             ,"//[EMAIL PROTECTED]'0']"
             );
 
 
     assertQ("test custom plugin query",
-            req("q","<!foo f=v_t>hello")
+            req("q","{!foo f=v_t}hello")
             ,"//[EMAIL PROTECTED]'2']"
             );
 
 
     assertQ("test single term field query on text type",
-            req("q","<!field f=v_t>HELLO")
+            req("q","{!field f=v_t}HELLO")
             ,"//[EMAIL PROTECTED]'2']"
             );
 
     assertQ("test single term field query on type with diff internal rep",
-            req("q","<!field f=v_f>1.5")
+            req("q","{!field f=v_f}1.5")
             ,"//[EMAIL PROTECTED]'1']"
             );    
 
      assertQ("test multi term field query on text type",
-            req("q","<!field f=v_t>Hello  DUDE")
+            req("q","{!field f=v_t}Hello  DUDE")
             ,"//[EMAIL PROTECTED]'1']"
             );
 
 
     assertQ("test prefix query with value in local params",
-            req("q","<!prefix f=v_t v=hel>")
+            req("q","{!prefix f=v_t v=hel}")
             ,"//[EMAIL PROTECTED]'2']"
     );
 
     assertQ("test optional quotes",
-            req("q","<!prefix f='v_t' v=\"hel\">")
+            req("q","{!prefix f='v_t' v=\"hel\"}")
             ,"//[EMAIL PROTECTED]'2']"
     );
 
     assertQ("test extra whitespace",
-            req("q","<!prefix   f=v_t   v=hel   >")
+            req("q","{!prefix   f=v_t   v=hel   }")
             ,"//[EMAIL PROTECTED]'2']"
     );
 
-    assertQ("test literal with <! in it",
-            req("q","<!prefix f=v_s><!lit")
+    assertQ("test literal with {! in it",
+            req("q","{!prefix f=v_s}{!lit")
             ,"//[EMAIL PROTECTED]'1']"
     );
 
     assertQ("test param subst",
-            req("q","<!prefix f=$myf v=$my.v>"
+            req("q","{!prefix f=$myf v=$my.v}"
                 ,"myf","v_t", "my.v", "hel"
             )
             ,"//[EMAIL PROTECTED]'2']"
     );
 
     assertQ("test param subst with literal",
-            req("q","<!prefix f=$myf v=$my.v>"
-                ,"myf","v_s", "my.v", "<!lit"
+            req("q","{!prefix f=$myf v=$my.v}"
+                ,"myf","v_s", "my.v", "{!lit"
             )
             ,"//[EMAIL PROTECTED]'1']"
     );
 
    // lucene queries
    assertQ("test lucene query",
-            req("q","<!lucene>v_t:hel*")
+            req("q","{!lucene}v_t:hel*")
             ,"//[EMAIL PROTECTED]'2']"
             );
 
    // lucene queries
    assertQ("test lucene default field",
-            req("q","<!df=v_t>hel*")
+            req("q","{!df=v_t}hel*")
             ,"//[EMAIL PROTECTED]'2']"
             );
 
    // lucene operator
    assertQ("test lucene operator",
-            req("q","<!q.op=OR df=v_t>Hello Yonik")
+            req("q","{!q.op=OR df=v_t}Hello Yonik")
             ,"//[EMAIL PROTECTED]'2']"
             );
    assertQ("test lucene operator",
-            req("q","<!q.op=AND df=v_t>Hello Yonik")
+            req("q","{!q.op=AND df=v_t}Hello Yonik")
             ,"//[EMAIL PROTECTED]'1']"
             );
 
     // test boost queries
     assertQ("test boost",
-            req("q","<!boost b=sum(v_f,1)>id:[5 TO 6]"
+            req("q","{!boost b=sum(v_f,1)}id:[5 TO 6]"
                 ,"fl","*,score"
             )
             ,"//[EMAIL PROTECTED]'2']"
@@ -155,8 +156,8 @@
     );
 
     assertQ("test boost and default type of func",
-            req("q","<!boost v=$q1 b=$q2>"
-                ,"q1", "<!func>v_f", "q2","v_f"
+            req("q","{!boost v=$q1 b=$q2}"
+                ,"q1", "{!func}v_f", "q2","v_f"
                 ,"fl","*,score"
             )
             ,"//doc[./[EMAIL PROTECTED]'v_f']='1.5' and ./[EMAIL 
PROTECTED]'score']='2.25']"
@@ -165,10 +166,10 @@
 
     // dismax query from std request handler
     assertQ("test dismax query",
-             req("q","<!dismax>hello"
+             req("q","{!dismax}hello"
                 ,"qf","v_t"
                 ,"bf","sqrt(v_f)^100 log(sum(v_f,1))^50"
-                ,"bq","<!prefix f=v_t>he"
+                ,"bq","{!prefix f=v_t}he"
                 ,"debugQuery","on"
              )
              ,"//[EMAIL PROTECTED]'2']"
@@ -176,19 +177,19 @@
 
     // dismax query from std request handler, using local params
     assertQ("test dismax query w/ local params",
-             req("q","<!dismax qf=v_t>hello"
+             req("q","{!dismax qf=v_t}hello"
                 ,"qf","v_f"
              )
              ,"//[EMAIL PROTECTED]'2']"
              );
 
     assertQ("test nested query",
-            req("q","_query_:\"<!query v=$q1>\"", "q1","<!prefix f=v_t>hel")
+            req("q","_query_:\"{!query v=$q1}\"", "q1","{!prefix f=v_t}hel")
             ,"//[EMAIL PROTECTED]'2']"
             );
 
     assertQ("test nested nested query",
-            req("q","_query_:\"<!query defType=query v=$q1>\"", 
"q1","<!v=$q2>","q2","<!prefix f=v_t v=$qqq>","qqq","hel")
+            req("q","_query_:\"{!query defType=query v=$q1}\"", 
"q1","{!v=$q2}","q2","{!prefix f=v_t v=$qqq}","qqq","hel")
             ,"//[EMAIL PROTECTED]'2']"
             );
 


Reply via email to