You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2011/03/02 17:17:46 UTC

svn commit: r1076274 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/example/solr/conf/velocity/ solr/src/java/org/apache/solr/response/

Author: gsingers
Date: Wed Mar  2 16:17:45 2011
New Revision: 1076274

URL: http://svn.apache.org/viewvc?rev=1076274&view=rev
Log:
SOLR-2178: 3.x backport

Added:
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/doc.vm
      - copied unchanged from r1027788, lucene/dev/trunk/solr/example/solr/conf/velocity/doc.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/head.vm
      - copied, changed from r1027788, lucene/dev/trunk/solr/example/solr/conf/velocity/head.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/querySpatial.vm
      - copied unchanged from r1027788, lucene/dev/trunk/solr/example/solr/conf/velocity/querySpatial.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/tabs.vm
      - copied, changed from r1027788, lucene/dev/trunk/solr/example/solr/conf/velocity/tabs.vm
Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/VM_global_library.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/browse.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/facet_ranges.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/hit.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/layout.vm
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/main.css
    lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/query.vm
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/PageTool.java

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/VM_global_library.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/VM_global_library.vm?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/VM_global_library.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/VM_global_library.vm Wed Mar  2 16:17:45 2011
@@ -16,16 +16,19 @@
 
 #macro(annTitle $msg)#if($annotate == true)title="$msg"#end#end
 
-#macro(spatial)#if($request.params.get('sfield'))&sfield=store#end#if($request.params.get('pt'))&pt=$request.params.get('pt')#end#if($request.params.get('d'))&d=$request.params.get('d')#end#end        
+#macro(spatial)#if($request.params.get('sfield'))&sfield=store#end#if($request.params.get('pt'))&pt=$request.params.get('pt')#end#if($request.params.get('d'))&d=$request.params.get('d')#end#end
 
-#macro(lensNoQ)?#if($request.params.getParams('fq') and $list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#debug#boostPrice#annotate#spatial#end
+#macro(qOpts)#set($queryOpts = $request.params.get("queryOpts"))#if($queryOpts && $queryOpts != "")&queryOpts=$queryOpts#end#end
+
+#macro(lensNoQ)?#if($request.params.getParams('fq') and $list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#debug#boostPrice#annotate#spatial#qOpts#group#end
 #macro(lens)#lensNoQ#q#end
+        
 
 #macro(url_for_lens)#{url_for_home}#lens#end
 
 #macro(url_for_start $start)#url_for_home#lens&start=$start#end
 
-#macro(url_for_filters $p)#url_for_home?#q#boostPrice#spatial#if($list.size($p) > 0)&#fqs($p)#end#debug#end
+#macro(url_for_filters $p)#url_for_home?#q#boostPrice#spatial#qOpts#if($list.size($p) > 0)&#fqs($p)#end#debug#end
 
 #macro(url_for_nested_facet_query $field)#url_for_home#lens&fq=$esc.url($field)#end
 
@@ -165,4 +168,14 @@
       #end
     </ul>
   #end
-#end
\ No newline at end of file
+#end
+
+#macro(field $f)
+  #if($response.response.highlighting.get($docId).get($f).get(0))
+    $!response.response.highlighting.get($docId).get($f).get(0)
+  #else
+    #foreach($v in $doc.getFieldValues($f))
+      $v
+    #end
+  #end
+#end  
\ No newline at end of file

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/browse.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/browse.vm?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/browse.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/browse.vm Wed Mar  2 16:17:45 2011
@@ -13,23 +13,33 @@
 </div>
 
 <div class="pagination">
-  <span><span class="results-found">$page.results_found</span> results found in ${response.responseHeader.QTime} ms</span>
+  #if($response.response.get('grouped'))
+    <span><span class="results-found">$response.response.get('grouped').size() group(s)</span> found in ${response.responseHeader.QTime} ms</span>
+  #else<span><span class="results-found">$page.results_found</span> results found in ${response.responseHeader.QTime} ms</span>
   Page <span class="page-num">$page.current_page_number</span> of <span
-        class="page-count">$page.page_count</span>
+        class="page-count">$page.page_count</span>#end
 </div>
 
 <div class="results">
-  #foreach($doc in $response.results)
-    #parse("hit.vm")
+  #if($response.response.get('grouped'))
+    #foreach($grouping in $response.response.get('grouped'))
+      #parse("hitGrouped.vm")
+    #end
+  #else
+    #foreach($doc in $response.results)
+      #parse("hit.vm")
+    #end
   #end
 </div>
 
 <div class="pagination">
+  #if($response.response.get('grouped'))
+  #else
   #link_to_previous_page("previous")
   <span class="results-found">$page.results_found</span> results found.
   Page <span class="page-num">$page.current_page_number</span> of <span
         class="page-count">$page.page_count</span>
   #link_to_next_page("next")
-
+  #end
   <br/>
 </div>

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/facet_ranges.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/facet_ranges.vm?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/facet_ranges.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/facet_ranges.vm Wed Mar  2 16:17:45 2011
@@ -1,3 +1,20 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
 <h2 #annTitle("Facets generated by adding &facet.range= to the request")>Range Facets</h2>
 #set($field = $response.response.facet_counts.facet_ranges.price.counts)
 #set($start = $response.response.facet_counts.facet_ranges.price.start)

Copied: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/head.vm (from r1027788, lucene/dev/trunk/solr/example/solr/conf/velocity/head.vm)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/head.vm?p2=lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/head.vm&p1=lucene/dev/trunk/solr/example/solr/conf/velocity/head.vm&r1=1027788&r2=1076274&rev=1076274&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/head.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/head.vm Wed Mar  2 16:17:45 2011
@@ -1,6 +1,23 @@
 
     ## An example of using an arbitrary request parameter
-    <title>#param('title')</title>
+    <!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<title>#param('title')</title>
     <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
 
 <script type="text/javascript" src="#{url_for_solr}/admin/jquery-1.2.3.min.js"></script>

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/hit.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/hit.vm?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/hit.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/hit.vm Wed Mar  2 16:17:45 2011
@@ -1,41 +1,5 @@
 #set($docId = $doc.getFieldValue('id'))
-#macro(field $f)
-  #if($response.response.highlighting.get($docId).get($f).get(0))
-    $!response.response.highlighting.get($docId).get($f).get(0)
-  #else
-    #foreach($v in $doc.getFieldValues($f))
-      $v
-    #end
-  #end
-#end
-<div class="result-document">
-  <div class="result-title"><b>#field('name')</b><span class="mlt">#if($params.getBool('mlt', false) == false)<a href="#lensNoQ&q=id:$docId&mlt=true">More Like This</a>#end</span></div>
-  ##do we have a physical store for this product
-  #set($store = $doc.getFieldValue('store'))
-  #if($store)<div class="map"><img src="http://maps.google.com/maps/api/staticmap?&zoom=12&size=150x80&maptype=roadmap&markers=$doc.getFieldValue('store')&sensor=false" /><div><small><a target="_map" href="http://maps.google.com/?q=$store&amp;source=embed">Larger Map</a></small></div></div>#end
-  <div>Price: $!number.currency($doc.getFieldValue('price'))</div>
-  <div>Features: #field('features')</div>
-  <div>In Stock: #field('inStock')</div>
-  <div class="mlt">
-    #set($mlt = $mltResults.get($docId))
-    #set($mltOn = $params.getBool('mlt'))
-    #if($mltOn == true)<div class="field-name">Similar Items</div>#end
-    #if ($mltOn && $mlt && $mlt.size() > 0)
-    <ul>
-      #foreach($mltHit in $mlt)
-        #set($mltId = $mltHit.getFieldValue('id'))
-        <li><div><a href="#url_for_home?q=id:$mltId">$mltId</a></div><div><span class="field-name">Name:</span> $mltHit.getFieldValue('name')</div>
-          <div><span class="field-name">Price:</span> $!number.currency($mltHit.getFieldValue('price')) <span class="field-name">In Stock:</span> $mltHit.getFieldValue('inStock')</div>
 
-        </li>
-      #end
-    </ul>
-    #elseif($mltOn && $mlt.size() == 0)
-      <div>No Similar Items Found</div>
-    #end
-  </div>
-  #if($params.getBool("debugQuery",false))
-    <a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle explain</a>
-    <pre style="display:none">$response.getExplainMap().get($doc.getFirstValue('id'))</pre>
-  #end
+<div class="result-document">
+  #parse("doc.vm")
 </div>

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/layout.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/layout.vm?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/layout.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/layout.vm Wed Mar  2 16:17:45 2011
@@ -1,47 +1,20 @@
 <html>
-  <head>
-    ## An example of using an arbitrary request parameter
-    <title>#param('title')</title>
-    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
-
-<script type="text/javascript" src="#{url_for_solr}/admin/jquery-1.4.3.min.js"></script>
-  <link rel="stylesheet" type="text/css" href="#{url_for_solr}/admin/file?file=/velocity/main.css&contentType=text/css"/>
-  <link rel="stylesheet" href="#{url_for_solr}/admin/file?file=/velocity/jquery.autocomplete.css&contentType=text/css" type="text/css" />
-  <script type="text/javascript" src="#{url_for_solr}/admin/file?file=/velocity/jquery.autocomplete.js&contentType=text/javascript"></script>
-
-
-    <script>
-    $(document).ready(function(){
-      $("\#q").autocomplete('#{url_for_solr}/terms', {  ## backslash escaped #q as that is a macro defined in VM_global_library.vm
-           extraParams:{
-             'terms.prefix': function() { return $("\#q").val();},
-             'terms.sort': 'count',
-             'terms.fl': 'name',
-             'wt': 'velocity',
-             'v.template': 'suggest'
-           }
-         }
-      );
-
-      // http://localhost:8983/solr/terms?terms.fl=name&terms.prefix=i&terms.sort=count
-    });
-  
-    </script>
-
-  </head>
+<head>
+  #parse("head.vm")
+</head>
   <body>
     <div id="admin"><a href="#url_for_solr/admin">Solr Admin</a></div>
     <div id="header">
       #parse("header.vm")
     </div>
-    
+    <div id="tabs">
+      #parse("tabs.vm")
+    </div>
     <div id="content">
       $content
     </div>
-  
     <div id="footer">
       #parse("footer.vm")
     </div>
-
   </body>
-</html>
+</html>
\ No newline at end of file

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/main.css
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/main.css?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/main.css (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/main.css Wed Mar  2 16:17:45 2011
@@ -122,7 +122,6 @@ a {
 
 .query-box .inputs{
   left: 180px;
-  top: -20px;
   position: relative;
   
 }
@@ -178,4 +177,8 @@ a {
 
 li.show {
   list-style: disc;
+}
+
+.group-value{
+  font-weight: bold;
 }
\ No newline at end of file

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/query.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/query.vm?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/query.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/query.vm Wed Mar  2 16:17:45 2011
@@ -1,23 +1,26 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
 <div class="query-box">
   <form id="query-form" action="#{url_for_home}" method="GET">
     <div class="inputs">
       <span #annTitle("Add the query using the &q= parameter")>Find: <input type="text" id="q" name="q" value="$!esc.html($params.get('q'))"/> <input type="submit" id="querySubmit"/> <input type="reset"/></span>
       <div class="query-boost"><span #annTitle("Add the boost function &bf=price to the query")><input type="checkbox" name="bf" value="price" #if($request.params.get('bf') == 'price')checked="true"#end>Boost by Price</input></span>
-      <span >
-        #set($loc = $request.params.get('pt'))
-        #set($dist = $request.params.get('d', "10"))
-        <label #annTitle("Add the &pt parameter")>Location Filter:
-          <select id="pt" name="pt">
-            <option value="none" #if($loc == '')selected="true"#end>No Filter</option>
-            <option value="45.17614,-93.87341" #if($loc == '45.17614,-93.87341')selected="true"#end>Buffalo, MN</option>
-            <option value="37.7752,-100.0232" #if($loc == '37.7752,-100.0232')selected="true"#end>Dodge City, KS</option>
-            <option value="35.0752,-97.032" #if($loc == '35.0752,-97.032')selected="true"#end>Oklahoma City, OK</option>
-            <option value="37.7752,-122.4232" #if($loc == '37.7752,-122.4232')selected="true"#end>San Francisco CA</option>
-          </select>
-        </label>
-        <span #annTitle("Add the &d parameter")>Distance (KM): <input id="d" name="d" type="text" size="6" value="#if($dist != '')${dist}#{else}10#end"/></span>
-        <input type="hidden" name="sfield" value="store"/>
-        <input type="hidden" id="spatialFQ" name="fq" value=""/>
+      #parse("querySpatial.vm")
       </div>
   </div>
 
@@ -44,23 +47,10 @@
         <a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle parsed query</a>
         <pre style="display:none">$response.response.debug.parsedquery</pre>
       #end
+      #set($queryOpts = $request.params.get("queryOpts"))
+      #if($queryOpts && $queryOpts != "")
+        <input type="hidden" name="queryOpts" value="$queryOpts"/>
+      #end
   </form>
-<script type="text/javascript">
-  $('#query-form').submit(function() {
-    if ($("#pt").val() != "none") {
-      $("#spatialFQ").val("{!bbox}");
-      //return false;
-    }
-    $fqs = $("#allFQs").val();
-    $fqs = $fqs.replace("{!bbox}", "");
-    if ($fqs == ''){
-      $("#allFQs").remove();
-    }
-    $("#allFQs").val($fqs);
-    //$("#spatialFQ").remove();
-    alert($fqs);
-    //alert("false");
-      return true;
-    });
-</script>
+
 </div>

Copied: lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/tabs.vm (from r1027788, lucene/dev/trunk/solr/example/solr/conf/velocity/tabs.vm)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/tabs.vm?p2=lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/tabs.vm&p1=lucene/dev/trunk/solr/example/solr/conf/velocity/tabs.vm&r1=1027788&r2=1076274&rev=1076274&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/tabs.vm (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/velocity/tabs.vm Wed Mar  2 16:17:45 2011
@@ -1,6 +1,22 @@
 ##TODO: Make some nice tabs here
 #set($queryOpts = $params.get("queryOpts"))
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
 <span #annTitle("Click the link to demonstrate various Solr capabilities")><span>Examples: </span><span class="tab">#if($queryOpts && $queryOpts != "")<a href="#url_for_home">Simple</a>#{else}Simple#end</span>
 <span class="tab">#if($queryOpts == "spatial")Spatial#else<a href="#url_for_home?&queryOpts=spatial">Spatial</a>#end</span>
-<span class="tab">#if($queryOpts == "group")Group By#else<a href="#url_for_home?&queryOpts=group&group=true&group.field=manu_exact">Group By</a>#end</span></span>
 <hr/>        
\ No newline at end of file

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/PageTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/PageTool.java?rev=1076274&r1=1076273&r2=1076274&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/PageTool.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/PageTool.java Wed Mar  2 16:17:45 2011
@@ -35,7 +35,7 @@ public class PageTool {
     if (rows != null) {
       results_per_page = new Integer(rows);
     }
-
+    //TODO: Handle group by results
     Object docs = response.getValues().get("response");
     if (docs != null) {
       if (docs instanceof DocSlice) {