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 2010/10/21 22:28:11 UTC

svn commit: r1026129 - in /lucene/dev/trunk/solr/example: exampledocs/ solr/conf/ solr/conf/velocity/

Author: gsingers
Date: Thu Oct 21 20:28:11 2010
New Revision: 1026129

URL: http://svn.apache.org/viewvc?rev=1026129&view=rev
Log:
SOLR-2178: Added in spatial support, including maps, More Like This, etc.

Added:
    lucene/dev/trunk/solr/example/solr/conf/velocity/query.vm
Modified:
    lucene/dev/trunk/solr/example/exampledocs/hd.xml
    lucene/dev/trunk/solr/example/exampledocs/ipod_video.xml
    lucene/dev/trunk/solr/example/exampledocs/mem.xml
    lucene/dev/trunk/solr/example/exampledocs/monitor.xml
    lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml
    lucene/dev/trunk/solr/example/solr/conf/velocity/VM_global_library.vm
    lucene/dev/trunk/solr/example/solr/conf/velocity/browse.vm
    lucene/dev/trunk/solr/example/solr/conf/velocity/footer.vm
    lucene/dev/trunk/solr/example/solr/conf/velocity/hit.vm
    lucene/dev/trunk/solr/example/solr/conf/velocity/layout.vm
    lucene/dev/trunk/solr/example/solr/conf/velocity/main.css

Modified: lucene/dev/trunk/solr/example/exampledocs/hd.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/exampledocs/hd.xml?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/exampledocs/hd.xml (original)
+++ lucene/dev/trunk/solr/example/exampledocs/hd.xml Thu Oct 21 20:28:11 2010
@@ -28,7 +28,8 @@
   <field name="popularity">6</field>
   <field name="inStock">true</field>
   <field name="manufacturedate_dt">2006-02-13T15:26:37Z</field>
-  <field name="store">45.17614,-93.87341</field>
+  <!-- Near Oklahoma city -->
+  <field name="store">35.0752,-97.032</field>
 </doc>
 
 <doc>

Modified: lucene/dev/trunk/solr/example/exampledocs/ipod_video.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/exampledocs/ipod_video.xml?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/exampledocs/ipod_video.xml (original)
+++ lucene/dev/trunk/solr/example/exampledocs/ipod_video.xml Thu Oct 21 20:28:11 2010
@@ -32,7 +32,7 @@
   <field name="price">399.00</field>
   <field name="popularity">10</field>
   <field name="inStock">true</field>
-  <!-- San Francisco store -->
-  <field name="store">37.7752,-122.4232</field>
+  <!-- Dodge City store -->
+  <field name="store">37.7752,-100.0232</field>
   <field name="manufacturedate_dt">2005-10-12T08:00:00Z</field>
 </doc></add>

Modified: lucene/dev/trunk/solr/example/exampledocs/mem.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/exampledocs/mem.xml?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/exampledocs/mem.xml (original)
+++ lucene/dev/trunk/solr/example/exampledocs/mem.xml Thu Oct 21 20:28:11 2010
@@ -43,8 +43,8 @@
   <field name="price">74.99</field>
   <field name="popularity">7</field>
   <field name="inStock">true</field>
-  <!-- San Francisco store -->
-  <field name="store">37.7752,-122.4232</field>
+  <!-- Dodge City store -->
+  <field name="store">37.7752,-100.0232</field>
   <field name="manufacturedate_dt">2006-02-13T15:26:37Z</field>
 
   <field name="payloads">electronics|4.0 memory|2.0</field>

Modified: lucene/dev/trunk/solr/example/exampledocs/monitor.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/exampledocs/monitor.xml?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/exampledocs/monitor.xml (original)
+++ lucene/dev/trunk/solr/example/exampledocs/monitor.xml Thu Oct 21 20:28:11 2010
@@ -28,6 +28,6 @@
   <field name="popularity">6</field>
   <field name="inStock">true</field>
   <!-- Buffalo store -->
-  <field name="store">45.17614,-93.87341</field>
+  <field name="store">43.17614,-90.57341</field>
 </doc></add>
 

Modified: lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml Thu Oct 21 20:28:11 2010
@@ -513,13 +513,18 @@
        <str name="title">Solritas</str>
 
        <!-- Query settings -->
-       <str name="defType">dismax</str>
+       <str name="defType">edismax</str>
        <str name="qf">
           text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
        </str>
        <str name="q.alt">*:*</str>
        <str name="rows">10</str>
        <str name="fl">*,score</str>
+       <str name="mlt.qf">
+         text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
+       </str>
+       <str name="mlt.fl">text,features,name,sku,id,manu,cat</str>
+       <int name="mlt.count">3</int>
 
        <!-- Faceting defaults -->
        <str name="facet">on</str>

Modified: lucene/dev/trunk/solr/example/solr/conf/velocity/VM_global_library.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/VM_global_library.vm?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/VM_global_library.vm (original)
+++ lucene/dev/trunk/solr/example/solr/conf/velocity/VM_global_library.vm Thu Oct 21 20:28:11 2010
@@ -4,7 +4,7 @@
 #macro(url_for_solr)/solr#if($request.core.name != "")/$request.core.name#end#end
 #macro(url_for_home)#url_for_solr/browse#end
 
-#macro(q)q=$!{esc.url($params.get('q'))}#end
+#macro(q)&q=$!{esc.url($params.get('q'))}#end
 
 #macro(fqs $p)#foreach($fq in $p)#if($velocityCount>1)&#{end}fq=$esc.url($fq)#end#end
 
@@ -14,15 +14,18 @@
 
 #macro(annotate)#if($request.params.get('annotateBrowse'))&annotateBrowse=true#end#end
 
-#macro(annTitle $msg)#if($annotate == true)title="$msg"#end#end        
+#macro(annTitle $msg)#if($annotate == true)title="$msg"#end#end
 
-#macro(lens)?#q#if($request.params.getParams('fq') and $list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#debug#if($request.params.get('bf') == 'price')&bf=price#end#annotate#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(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#if($list.size($p) > 0)&#fqs($p)#end#debug#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_nested_facet_query $field)#url_for_home#lens&fq=$esc.url($field)#end
 

Modified: lucene/dev/trunk/solr/example/solr/conf/velocity/browse.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/browse.vm?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/browse.vm (original)
+++ lucene/dev/trunk/solr/example/solr/conf/velocity/browse.vm Thu Oct 21 20:28:11 2010
@@ -1,33 +1,9 @@
 #set($searcher=$request.searcher)
 #set($params=$request.params)
 #set($clusters = $response.response.clusters)
-#set($annotate = $request.params.get("annotateBrowse"))
-<div class="query-box">
-  <form id="query-form" action="#{url_for_home}" method="GET">
-    <div class="inputs"><span>Find: <input type="text" id="q" name="q" value="$!esc.html($params.get('q'))"/> <input type="submit"/> <input type="reset"/></span>
-    <div class="query-boost"><input type="checkbox" name="bf" #annTitle("Add the boost function &bf=price to the query") value="price" #if($request.params.get('bf') == 'price')checked="true"#end>Boost by Price</input> </div></div>
-    #if($request.params.get('debugQuery'))
-      <input type="hidden" name="debugQuery" value="true"/>
-    #end
-    #if($annotate == true)
-      <input type="hidden" name="annotateBrowse" value="true"/>
-    #end
-    #foreach($fq in $request.params.getParams('fq'))
-      <input type="hidden" name="fq" value="$esc.html($fq)"/>
-    #end
-    <div class="constraints">
-      #foreach($fq in $params.getParams('fq'))
-        #set($previous_fq_count=$velocityCount - 1)
-      &gt; <a style="{text-decoration: line-through;}" href="#url_for_filters($request.params.getParams('fq').subList(0,$previous_fq_count))">$fq</a>
-      #end
-    </div>
-     #if($request.params.get('debugQuery'))
-        <a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle parsed query</a>
-        <pre style="display:none">$response.response.debug.parsedquery</pre>
-      #end    
-  </form>
-</div>
-
+#set($mltResults = $response.response.get("moreLikeThis"))
+#set($annotate = $params.get("annotateBrowse"))
+#parse('query.vm')
 #if($response.response.spellcheck.suggestions and $response.response.spellcheck.suggestions.size() > 0)
   Did you mean <a href="#url_for_home?q=$esc.url($response.response.spellcheck.suggestions.collation)#if($list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#debug">$response.response.spellcheck.suggestions.collation</a>?
 #end

Modified: lucene/dev/trunk/solr/example/solr/conf/velocity/footer.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/footer.vm?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/footer.vm (original)
+++ lucene/dev/trunk/solr/example/solr/conf/velocity/footer.vm Thu Oct 21 20:28:11 2010
@@ -1,16 +1,17 @@
 <hr/>
-Generated by <a href="http://wiki.apache.org/solr/VelocityResponseWriter">VelocityResponseWriter</a>
-
-#if($request.params.get('debugQuery'))
+<div>
+  <span>Options:</span>
+  #if($request.params.get('debugQuery'))
   <a href="#url_for_home?#q#if($list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end">disable debug</a>
-#else
+  #else
   <a href="#url_for_lens&debugQuery=true">enable debug</a>
-#end
-#if($annotate)
+  #end
+  #if($annotate)
   <a href="#url_for_home?#q#if($list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#boostPrice">disable annotation</a>
-#else
+  #else
   <a href="#url_for_lens&annotateBrowse=true">enable annotation</a>
-#end
-
-
-<a href="#url_for_lens&wt=xml#if($request.params.get('debugQuery'))&debugQuery=true#end">XML</a>
\ No newline at end of file
+  #end
+  <a #annTitle("Click to switch to an XML response: &wt=xml") href="#url_for_lens&wt=xml#if($request.params.get('debugQuery'))&debugQuery=true#end">XML</a></div>
+<div>Generated by <a href="http://wiki.apache.org/solr/VelocityResponseWriter">VelocityResponseWriter</a></div>
+<div><span>Documentation: </span> <a href="http://lucene.apache.org/solr">Solr Home Page</a>, <a href="http://wiki.apache.org/solr">Solr Wiki</a></div>
+<div>Disclaimer: The locations displayed in this demonstration are purely fictional.  It is more than likely that no store with the items listed actually exists at that location!</div>        
\ No newline at end of file

Modified: lucene/dev/trunk/solr/example/solr/conf/velocity/hit.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/hit.vm?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/hit.vm (original)
+++ lucene/dev/trunk/solr/example/solr/conf/velocity/hit.vm Thu Oct 21 20:28:11 2010
@@ -1,6 +1,7 @@
+#set($docId = $doc.getFieldValue('id'))
 #macro(field $f)
-  #if($response.response.highlighting.get($doc.getFieldValue('id')).get($f).get(0))
-    $!response.response.highlighting.get($doc.getFieldValue('id')).get($f).get(0)
+  #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
@@ -8,11 +9,31 @@
   #end
 #end
 <div class="result-document">
-  <p><b>#field('name')</b></p>
-  <p>Price: $!number.currency($doc.getFieldValue('price'))</p>
-  <p>Features: #field('features')</p>
-  <p>In Stock: #field('inStock')</p>
-  
+  <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>

Modified: lucene/dev/trunk/solr/example/solr/conf/velocity/layout.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/layout.vm?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/layout.vm (original)
+++ lucene/dev/trunk/solr/example/solr/conf/velocity/layout.vm Thu Oct 21 20:28:11 2010
@@ -25,6 +25,7 @@
 
       // http://localhost:8983/solr/terms?terms.fl=name&terms.prefix=i&terms.sort=count
     });
+  
     </script>
 
   </head>

Modified: lucene/dev/trunk/solr/example/solr/conf/velocity/main.css
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/main.css?rev=1026129&r1=1026128&r2=1026129&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/main.css (original)
+++ lucene/dev/trunk/solr/example/solr/conf/velocity/main.css Thu Oct 21 20:28:11 2010
@@ -89,6 +89,8 @@ a {
   width: 80%;
 }
 
+
+
 .query-box, .constraints {
   padding: 5px;
   margin: 5px;
@@ -111,7 +113,7 @@ a {
 }
 
 .query-boost {
-  width: 20%;
+  
   top: 10px;
   left: 50px;
   position: relative;
@@ -147,6 +149,24 @@ a {
   margin-bottom: 15px;
 }
 
+.result-document div{
+  padding: 5px;
+}
+
+.result-title{
+  width:60%;
+}
+
+.mlt{
+  
+}
+
+.map{
+  float: right;
+  position: relative;
+  top: -25px;  
+}
+
 .result-document:nth-child(2n+1) {
   background-color: #eee;
 }

Added: lucene/dev/trunk/solr/example/solr/conf/velocity/query.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/query.vm?rev=1026129&view=auto
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/velocity/query.vm (added)
+++ lucene/dev/trunk/solr/example/solr/conf/velocity/query.vm Thu Oct 21 20:28:11 2010
@@ -0,0 +1,66 @@
+<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'))
+        <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=""/>
+      </div>
+  </div>
+
+    #if($request.params.get('debugQuery'))
+      <input type="hidden" name="debugQuery" value="true"/>
+    #end
+    #if($annotate == true)
+      <input type="hidden" name="annotateBrowse" value="true"/>
+    #end
+    #foreach($fq in $request.params.getParams('fq'))
+      #if ($fq != "{!bbox}")
+        <input type="hidden" name="fq" id="allFQs" value="$esc.html($fq)"/>
+      #end
+    #end
+    <div class="constraints" #annTitle("Lists out the &fq filters.  Click to remove.")>
+      #foreach($fq in $params.getParams('fq'))
+        #set($previous_fq_count=$velocityCount - 1)
+        #if($fq != '')
+        &gt; <a style="{text-decoration: line-through;}" href="#url_for_filters($request.params.getParams('fq').subList(0,$previous_fq_count))">$fq</a>
+        #end
+      #end
+    </div>
+     #if($request.params.get('debugQuery'))
+        <a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle parsed query</a>
+        <pre style="display:none">$response.response.debug.parsedquery</pre>
+      #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>