Add as-you-type instant search to example/files /browse

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1683778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2015-06-05 15:05:20 +00:00
parent b04702292f
commit f2291c1356
8 changed files with 84 additions and 105 deletions

View File

@ -141,6 +141,9 @@ Other Changes
This is no longer supported by the underlying Lucene locking This is no longer supported by the underlying Lucene locking
framework. (Uwe Schindler, Mike McCandless, Robert Muir) framework. (Uwe Schindler, Mike McCandless, Robert Muir)
* SOLR-3719: Add as-you-type "instant search" to example/files /browse.
(Esther Quansah, ehatcher)
================== 5.2.0 ================== ================== 5.2.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -30,3 +30,41 @@
#macro(url_for_facet_date_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end #macro(url_for_facet_date_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end
#macro(url_for_facet_range_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end #macro(url_for_facet_range_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end
# TODO: make this parameterized fully, no context sensitivity
#macro(field $f)
#if($response.response.highlighting.get($docId).get($f).get(0))
#set($pad = "")
#foreach($v in $response.response.highlighting.get($docId).get($f))
$pad$v## #TODO: $esc.html() or maybe make that optional?
#set($pad = " ... ")
#end
#else
#foreach($v in $doc.getFieldValues($f))$esc.html($v)#end
#end
#end
#macro(link_to_previous_page)
#if($page.current_page_number > 1)
#set($prev_start = $page.start - $page.results_per_page)
<a class="prev-page" href="#url_for_start($prev_start)">$resource.previous</a>
#end
#end
#macro(link_to_next_page)
#if($page.current_page_number < $page.page_count)
#set($next_start = $page.start + $page.results_per_page)
<a class="next-page" href="#url_for_start($next_start)">$resource.next</a>
#end
#end
#macro(link_to_page $page_number $text)
#if($page_number == $page.current_page_number)
$text
#else
#if($page_number <= $page.page_count)
#set($page_start = $page_number * $page.results_per_page - $page.results_per_page)
<a class="page" href="#url_for_start($page_start)">$text</a>
#end
#end
#end

View File

@ -1,38 +0,0 @@
# TODO: make this parameterized fully, no context sensitivity
#macro(field $f)
#if($response.response.highlighting.get($docId).get($f).get(0))
#set($pad = "")
#foreach($v in $response.response.highlighting.get($docId).get($f))
$pad$v## #TODO: $esc.html() or maybe make that optional?
#set($pad = " ... ")
#end
#else
#foreach($v in $doc.getFieldValues($f))$esc.html($v)
#end
#end
#end
#macro(link_to_previous_page)
#if($page.current_page_number > 1)
#set($prev_start = $page.start - $page.results_per_page)
<a class="prev-page" href="#url_for_start($prev_start)">$resource.previous</a>
#end
#end
#macro(link_to_next_page)
#if($page.current_page_number < $page.page_count)
#set($next_start = $page.start + $page.results_per_page)
<a class="next-page" href="#url_for_start($next_start)">$resource.next</a>
#end
#end
#macro(link_to_page $page_number $text)
#if($page_number == $page.current_page_number)
$text
#else
#if($page_number <= $page.page_count)
#set($page_start = $page_number * $page.results_per_page - $page.results_per_page)
<a class="page" href="#url_for_start($page_start)">$text</a>
#end
#end
#end

View File

@ -8,6 +8,7 @@
"facets":{ "facets":{
"facet":"on", "facet":"on",
"facet.mincount":"1", "facet.mincount":"1",
"f.doc_type.facet.mincount":"0",
"facet.field":["text_shingles","{!ex=type}doc_type"], "facet.field":["text_shingles","{!ex=type}doc_type"],
"f.text_shingles.facet.limit":10, "f.text_shingles.facet.limit":10,
"facet.query":"{!ex=type key=all_types}*:*", "facet.query":"{!ex=type key=all_types}*:*",

View File

@ -27,25 +27,6 @@
<div id="browse_results"> <div id="browse_results">
<div id="facets"> #parse("results.vm")
#parse("facets.vm")
</div>
<div id="results_list">
<div class="pagination">
<span class="results-found">$page.results_found</span> $resource.results_found_in.insert(${response.responseHeader.QTime})
$resource.page_of.insert($page.current_page_number,$page.page_count)
</div>
#parse("results_list.vm")
<div class="pagination">
#link_to_previous_page
<span class="results-found">$page.results_found</span> $resource.results_found.
$resource.page_of.insert($page.current_page_number,$page.page_count)
#link_to_next_page
</div>
</div>
</div> </div>

View File

@ -13,15 +13,23 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
$("#tagcloud").tx3TagCloud({ $("#tagcloud").tx3TagCloud({
multiplier: 5 multiplier: 5
}); });
$('.menu').dropit();
$('.menu').dropit(); $( document ).ajaxComplete(function() {
$("#tagcloud").tx3TagCloud({
multiplier: 5
});
});
$('\#q').keyup(function() {
$('#browse_results').load('#{url_for_home}?#lensNoQ&v.layout.enabled=false&v.template=results&q='+encodeURI($('\#q').val()));
});
}); });
</script> </script>
<style> <style>
@ -219,4 +227,7 @@
margin: 0; margin: 0;
} }
.dropit .dropit-open .dropit-submenu { display: block; } .dropit .dropit-open .dropit-submenu { display: block; }
</style> </style>

View File

@ -1,50 +1,13 @@
#macro(lensNoQ)?#if($list.size($response.responseHeader.params.getAll("fq")) > 0)&#fqs($response.responseHeader.params.getAll("fq"))#end#sort($request.params.getParams('sort'))#end #macro(lensFilterSortOnly)?#if($list.size($response.responseHeader.params.getAll("fq")) > 0)&#fqs($response.responseHeader.params.getAll("fq"))#end#sort($request.params.getParams('sort'))#end
#macro(lensNoQ)#lensFilterSortOnly&type=#current_type#if("#current_locale"!="")&locale=#current_locale#end#end
#macro(lensNoType)#lensFilterSortOnly#q#if("#current_locale"!="")&locale=#current_locale#end#end
#macro(lensNoLocale)#lensFilterSortOnly#q&type=#current_type#end
## lens modified for example/files - to use fq from responseHeader rather than request, and #debug removed too as it is built into browse params now, also added type to lens ## lens modified for example/files - to use fq from responseHeader rather than request, and #debug removed too as it is built into browse params now, also added type to lens
#macro(lens)#lensNoQ#q&type=#current_type#if("#current_locale"!="")&locale=#current_locale#end#end #macro(lens)#lensNoQ#q#end
# TODO: make this parameterized fully, no context sensitivity
#macro(field $f)
#if($response.response.highlighting.get($docId).get($f).get(0))
#set($pad = "")
#foreach($v in $response.response.highlighting.get($docId).get($f))
$pad$v## #TODO: $esc.html() or maybe make that optional?
#set($pad = " ... ")
#end
#else
#foreach($v in $doc.getFieldValues($f))$esc.html($v)
#end
#end
#end
#macro(link_to_previous_page)
#if($page.current_page_number > 1)
#set($prev_start = $page.start - $page.results_per_page)
<a class="prev-page" href="#url_for_start($prev_start)">$resource.previous</a>
#end
#end
#macro(link_to_next_page)
#if($page.current_page_number < $page.page_count)
#set($next_start = $page.start + $page.results_per_page)
<a class="next-page" href="#url_for_start($next_start)">$resource.next</a>
#end
#end
#macro(link_to_page $page_number $text)
#if($page_number == $page.current_page_number)
$text
#else
#if($page_number <= $page.page_count)
#set($page_start = $page_number * $page.results_per_page - $page.results_per_page)
<a class="page" href="#url_for_start($page_start)">$text</a>
#end
#end
#end
## Macros defined custom for the "files" example ## Macros defined custom for the "files" example
#macro(url_for_type $type)#url_for_home#lensNoQ#q&type=$type#if("#current_locale"!="")&locale=#current_locale#end#end #macro(url_for_type $type)#url_for_home#lensNoType&type=$type#end
#macro(current_type)#if($response.responseHeader.params.type)${response.responseHeader.params.type}#{else}all#end#end #macro(current_type)#if($response.responseHeader.params.type)${response.responseHeader.params.type}#{else}all#end#end
#macro(url_for_locale $locale)#url_for_home#lensNoQ#q&type=#current_type#if($locale!="")&locale=$locale#end#end #macro(url_for_locale $locale)#url_for_home#lensNoLocale#if($locale!="")&locale=$locale#end&start=$page.start#end
#macro(current_locale)$!{response.responseHeader.params.locale}#end #macro(current_locale)$!{response.responseHeader.params.locale}#end

View File

@ -0,0 +1,20 @@
<div id="facets">
#parse("facets.vm")
</div>
<div id="results_list">
<div class="pagination">
<span class="results-found">$page.results_found</span> $resource.results_found_in.insert(${response.responseHeader.QTime})
$resource.page_of.insert($page.current_page_number,$page.page_count)
</div>
#parse("results_list.vm")
<div class="pagination">
#link_to_previous_page
<span class="results-found">$page.results_found</span> $resource.results_found.
$resource.page_of.insert($page.current_page_number,$page.page_count)
#link_to_next_page
</div>
</div>