From 2629d2cbbca5803585e9a0829f67539b6476a661 Mon Sep 17 00:00:00 2001 From: Grant Ingersoll Date: Thu, 21 Oct 2010 20:28:11 +0000 Subject: [PATCH] SOLR-2178: Added in spatial support, including maps, More Like This, etc. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1026129 13f79535-47bb-0310-9956-ffa450edef68 --- solr/example/exampledocs/hd.xml | 3 +- solr/example/exampledocs/ipod_video.xml | 4 +- solr/example/exampledocs/mem.xml | 4 +- solr/example/exampledocs/monitor.xml | 2 +- solr/example/solr/conf/solrconfig.xml | 7 +- .../solr/conf/velocity/VM_global_library.vm | 11 ++-- solr/example/solr/conf/velocity/browse.vm | 30 +-------- solr/example/solr/conf/velocity/footer.vm | 23 +++---- solr/example/solr/conf/velocity/hit.vm | 35 ++++++++-- solr/example/solr/conf/velocity/layout.vm | 1 + solr/example/solr/conf/velocity/main.css | 22 ++++++- solr/example/solr/conf/velocity/query.vm | 66 +++++++++++++++++++ 12 files changed, 151 insertions(+), 57 deletions(-) create mode 100644 solr/example/solr/conf/velocity/query.vm diff --git a/solr/example/exampledocs/hd.xml b/solr/example/exampledocs/hd.xml index 470b2e71697..7555100d8d7 100644 --- a/solr/example/exampledocs/hd.xml +++ b/solr/example/exampledocs/hd.xml @@ -28,7 +28,8 @@ 6 true 2006-02-13T15:26:37Z - 45.17614,-93.87341 + + 35.0752,-97.032 diff --git a/solr/example/exampledocs/ipod_video.xml b/solr/example/exampledocs/ipod_video.xml index 8f5dc60f5b2..7895860ea19 100644 --- a/solr/example/exampledocs/ipod_video.xml +++ b/solr/example/exampledocs/ipod_video.xml @@ -32,7 +32,7 @@ 399.00 10 true - - 37.7752,-122.4232 + + 37.7752,-100.0232 2005-10-12T08:00:00Z diff --git a/solr/example/exampledocs/mem.xml b/solr/example/exampledocs/mem.xml index 52f7a610be1..115d6645a03 100644 --- a/solr/example/exampledocs/mem.xml +++ b/solr/example/exampledocs/mem.xml @@ -43,8 +43,8 @@ 74.99 7 true - - 37.7752,-122.4232 + + 37.7752,-100.0232 2006-02-13T15:26:37Z electronics|4.0 memory|2.0 diff --git a/solr/example/exampledocs/monitor.xml b/solr/example/exampledocs/monitor.xml index 99bed66f62d..035f61891da 100644 --- a/solr/example/exampledocs/monitor.xml +++ b/solr/example/exampledocs/monitor.xml @@ -28,6 +28,6 @@ 6 true - 45.17614,-93.87341 + 43.17614,-90.57341 diff --git a/solr/example/solr/conf/solrconfig.xml b/solr/example/solr/conf/solrconfig.xml index f7065814501..f934c6df70b 100755 --- a/solr/example/solr/conf/solrconfig.xml +++ b/solr/example/solr/conf/solrconfig.xml @@ -513,13 +513,18 @@ Solritas - dismax + edismax text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 *:* 10 *,score + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + text,features,name,sku,id,manu,cat + 3 on diff --git a/solr/example/solr/conf/velocity/VM_global_library.vm b/solr/example/solr/conf/velocity/VM_global_library.vm index a42f4c51c76..6d87daff407 100644 --- a/solr/example/solr/conf/velocity/VM_global_library.vm +++ b/solr/example/solr/conf/velocity/VM_global_library.vm @@ -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 diff --git a/solr/example/solr/conf/velocity/browse.vm b/solr/example/solr/conf/velocity/browse.vm index ce7f233b2d9..6830870f618 100644 --- a/solr/example/solr/conf/velocity/browse.vm +++ b/solr/example/solr/conf/velocity/browse.vm @@ -1,33 +1,9 @@ #set($searcher=$request.searcher) #set($params=$request.params) #set($clusters = $response.response.clusters) -#set($annotate = $request.params.get("annotateBrowse")) -
-
-
Find: -
Boost by Price
- #if($request.params.get('debugQuery')) - - #end - #if($annotate == true) - - #end - #foreach($fq in $request.params.getParams('fq')) - - #end -
- #foreach($fq in $params.getParams('fq')) - #set($previous_fq_count=$velocityCount - 1) - > $fq - #end -
- #if($request.params.get('debugQuery')) - toggle parsed query -
$response.response.debug.parsedquery
- #end -
-
- +#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 $response.response.spellcheck.suggestions.collation? #end diff --git a/solr/example/solr/conf/velocity/footer.vm b/solr/example/solr/conf/velocity/footer.vm index 77b7bd84a18..79c8f820afc 100644 --- a/solr/example/solr/conf/velocity/footer.vm +++ b/solr/example/solr/conf/velocity/footer.vm @@ -1,16 +1,17 @@
-Generated by VelocityResponseWriter - -#if($request.params.get('debugQuery')) +
+ Options: + #if($request.params.get('debugQuery')) disable debug -#else + #else enable debug -#end -#if($annotate) + #end + #if($annotate) disable annotation -#else + #else enable annotation -#end - - -XML \ No newline at end of file + #end + XML
+
Generated by VelocityResponseWriter
+
Documentation: Solr Home Page, Solr Wiki
+
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!
\ No newline at end of file diff --git a/solr/example/solr/conf/velocity/hit.vm b/solr/example/solr/conf/velocity/hit.vm index 5b5d2ac73b1..0f72673e3fd 100644 --- a/solr/example/solr/conf/velocity/hit.vm +++ b/solr/example/solr/conf/velocity/hit.vm @@ -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
-

#field('name')

-

Price: $!number.currency($doc.getFieldValue('price'))

-

Features: #field('features')

-

In Stock: #field('inStock')

- +
#field('name')#if($params.getBool('mlt', false) == false)More Like This#end
+ ##do we have a physical store for this product + #set($store = $doc.getFieldValue('store')) + #if($store)#end +
Price: $!number.currency($doc.getFieldValue('price'))
+
Features: #field('features')
+
In Stock: #field('inStock')
+
+ #set($mlt = $mltResults.get($docId)) + #set($mltOn = $params.getBool('mlt')) + #if($mltOn == true)
Similar Items
#end + #if ($mltOn && $mlt && $mlt.size() > 0) +
    + #foreach($mltHit in $mlt) + #set($mltId = $mltHit.getFieldValue('id')) +
  • Name: $mltHit.getFieldValue('name')
    +
    Price: $!number.currency($mltHit.getFieldValue('price')) In Stock: $mltHit.getFieldValue('inStock')
    + +
  • + #end +
+ #elseif($mltOn && $mlt.size() == 0) +
No Similar Items Found
+ #end +
#if($params.getBool("debugQuery",false)) toggle explain
$response.getExplainMap().get($doc.getFirstValue('id'))
diff --git a/solr/example/solr/conf/velocity/layout.vm b/solr/example/solr/conf/velocity/layout.vm index fc912d03128..400a2c97c41 100644 --- a/solr/example/solr/conf/velocity/layout.vm +++ b/solr/example/solr/conf/velocity/layout.vm @@ -25,6 +25,7 @@ // http://localhost:8983/solr/terms?terms.fl=name&terms.prefix=i&terms.sort=count }); + diff --git a/solr/example/solr/conf/velocity/main.css b/solr/example/solr/conf/velocity/main.css index 351f340e56f..fca2b01c4c0 100644 --- a/solr/example/solr/conf/velocity/main.css +++ b/solr/example/solr/conf/velocity/main.css @@ -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; } diff --git a/solr/example/solr/conf/velocity/query.vm b/solr/example/solr/conf/velocity/query.vm new file mode 100644 index 00000000000..4dd23569aca --- /dev/null +++ b/solr/example/solr/conf/velocity/query.vm @@ -0,0 +1,66 @@ +
+
+
+ Find: +
Boost by Price + + #set($loc = $request.params.get('pt')) + #set($dist = $request.params.get('d')) + + Distance (KM): + + +
+
+ + #if($request.params.get('debugQuery')) + + #end + #if($annotate == true) + + #end + #foreach($fq in $request.params.getParams('fq')) + #if ($fq != "{!bbox}") + + #end + #end +
+ #foreach($fq in $params.getParams('fq')) + #set($previous_fq_count=$velocityCount - 1) + #if($fq != '') + > $fq + #end + #end +
+ #if($request.params.get('debugQuery')) + toggle parsed query +
$response.response.debug.parsedquery
+ #end +
+ +