simple_solr_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +349 -0
  5. data/Rakefile +11 -0
  6. data/lib/simple_solr.rb +42 -0
  7. data/lib/simple_solr/client.rb +139 -0
  8. data/lib/simple_solr/client/core_admin.rb +0 -0
  9. data/lib/simple_solr/core.rb +50 -0
  10. data/lib/simple_solr/core/admin.rb +47 -0
  11. data/lib/simple_solr/core/core_data.rb +51 -0
  12. data/lib/simple_solr/core/index.rb +25 -0
  13. data/lib/simple_solr/core/search.rb +21 -0
  14. data/lib/simple_solr/response/document.rb +45 -0
  15. data/lib/simple_solr/response/generic_response.rb +19 -0
  16. data/lib/simple_solr/response/query_response.rb +54 -0
  17. data/lib/simple_solr/schema.rb +261 -0
  18. data/lib/simple_solr/schema/analysis.rb +58 -0
  19. data/lib/simple_solr/schema/copyfield.rb +42 -0
  20. data/lib/simple_solr/schema/dynamic_field.rb +23 -0
  21. data/lib/simple_solr/schema/field.rb +35 -0
  22. data/lib/simple_solr/schema/field_or_type.rb +112 -0
  23. data/lib/simple_solr/schema/field_type.rb +62 -0
  24. data/lib/simple_solr/schema/matcher.rb +16 -0
  25. data/lib/simple_solr/version.rb +3 -0
  26. data/simple_solr_client.gemspec +39 -0
  27. data/solr_sample_core/conf/_schema_analysis_stopwords_english.json +38 -0
  28. data/solr_sample_core/conf/_schema_analysis_synonyms_english.json +11 -0
  29. data/solr_sample_core/conf/admin-extra.html +24 -0
  30. data/solr_sample_core/conf/admin-extra.menu-bottom.html +25 -0
  31. data/solr_sample_core/conf/admin-extra.menu-top.html +25 -0
  32. data/solr_sample_core/conf/clustering/carrot2/kmeans-attributes.xml +19 -0
  33. data/solr_sample_core/conf/clustering/carrot2/lingo-attributes.xml +24 -0
  34. data/solr_sample_core/conf/clustering/carrot2/stc-attributes.xml +19 -0
  35. data/solr_sample_core/conf/currency.xml +67 -0
  36. data/solr_sample_core/conf/elevate.xml +38 -0
  37. data/solr_sample_core/conf/lang/contractions_ca.txt +8 -0
  38. data/solr_sample_core/conf/lang/contractions_fr.txt +15 -0
  39. data/solr_sample_core/conf/lang/contractions_ga.txt +5 -0
  40. data/solr_sample_core/conf/lang/contractions_it.txt +23 -0
  41. data/solr_sample_core/conf/lang/hyphenations_ga.txt +5 -0
  42. data/solr_sample_core/conf/lang/stemdict_nl.txt +6 -0
  43. data/solr_sample_core/conf/lang/stoptags_ja.txt +420 -0
  44. data/solr_sample_core/conf/lang/stopwords_ar.txt +125 -0
  45. data/solr_sample_core/conf/lang/stopwords_bg.txt +193 -0
  46. data/solr_sample_core/conf/lang/stopwords_ca.txt +220 -0
  47. data/solr_sample_core/conf/lang/stopwords_ckb.txt +136 -0
  48. data/solr_sample_core/conf/lang/stopwords_cz.txt +172 -0
  49. data/solr_sample_core/conf/lang/stopwords_da.txt +110 -0
  50. data/solr_sample_core/conf/lang/stopwords_de.txt +294 -0
  51. data/solr_sample_core/conf/lang/stopwords_el.txt +78 -0
  52. data/solr_sample_core/conf/lang/stopwords_en.txt +54 -0
  53. data/solr_sample_core/conf/lang/stopwords_es.txt +356 -0
  54. data/solr_sample_core/conf/lang/stopwords_eu.txt +99 -0
  55. data/solr_sample_core/conf/lang/stopwords_fa.txt +313 -0
  56. data/solr_sample_core/conf/lang/stopwords_fi.txt +97 -0
  57. data/solr_sample_core/conf/lang/stopwords_fr.txt +186 -0
  58. data/solr_sample_core/conf/lang/stopwords_ga.txt +110 -0
  59. data/solr_sample_core/conf/lang/stopwords_gl.txt +161 -0
  60. data/solr_sample_core/conf/lang/stopwords_hi.txt +235 -0
  61. data/solr_sample_core/conf/lang/stopwords_hu.txt +211 -0
  62. data/solr_sample_core/conf/lang/stopwords_hy.txt +46 -0
  63. data/solr_sample_core/conf/lang/stopwords_id.txt +359 -0
  64. data/solr_sample_core/conf/lang/stopwords_it.txt +303 -0
  65. data/solr_sample_core/conf/lang/stopwords_ja.txt +127 -0
  66. data/solr_sample_core/conf/lang/stopwords_lv.txt +172 -0
  67. data/solr_sample_core/conf/lang/stopwords_nl.txt +119 -0
  68. data/solr_sample_core/conf/lang/stopwords_no.txt +194 -0
  69. data/solr_sample_core/conf/lang/stopwords_pt.txt +253 -0
  70. data/solr_sample_core/conf/lang/stopwords_ro.txt +233 -0
  71. data/solr_sample_core/conf/lang/stopwords_ru.txt +243 -0
  72. data/solr_sample_core/conf/lang/stopwords_sv.txt +133 -0
  73. data/solr_sample_core/conf/lang/stopwords_th.txt +119 -0
  74. data/solr_sample_core/conf/lang/stopwords_tr.txt +212 -0
  75. data/solr_sample_core/conf/lang/userdict_ja.txt +29 -0
  76. data/solr_sample_core/conf/mapping-FoldToASCII.txt +3813 -0
  77. data/solr_sample_core/conf/mapping-ISOLatin1Accent.txt +246 -0
  78. data/solr_sample_core/conf/protwords.txt +21 -0
  79. data/solr_sample_core/conf/schema.xml +62 -0
  80. data/solr_sample_core/conf/scripts.conf +24 -0
  81. data/solr_sample_core/conf/solrconfig.xml +1702 -0
  82. data/solr_sample_core/conf/spellings.txt +2 -0
  83. data/solr_sample_core/conf/stopwords.txt +14 -0
  84. data/solr_sample_core/conf/syn.txt +0 -0
  85. data/solr_sample_core/conf/synonyms.txt +29 -0
  86. data/solr_sample_core/conf/token_fixing_charfilter.txt +110 -0
  87. data/solr_sample_core/conf/update-script.js +53 -0
  88. data/solr_sample_core/conf/velocity/README.txt +101 -0
  89. data/solr_sample_core/conf/velocity/VM_global_library.vm +175 -0
  90. data/solr_sample_core/conf/velocity/browse.vm +33 -0
  91. data/solr_sample_core/conf/velocity/cluster.vm +19 -0
  92. data/solr_sample_core/conf/velocity/cluster_results.vm +31 -0
  93. data/solr_sample_core/conf/velocity/debug.vm +28 -0
  94. data/solr_sample_core/conf/velocity/did_you_mean.vm +9 -0
  95. data/solr_sample_core/conf/velocity/error.vm +11 -0
  96. data/solr_sample_core/conf/velocity/facet_fields.vm +23 -0
  97. data/solr_sample_core/conf/velocity/facet_pivot.vm +12 -0
  98. data/solr_sample_core/conf/velocity/facet_queries.vm +12 -0
  99. data/solr_sample_core/conf/velocity/facet_ranges.vm +23 -0
  100. data/solr_sample_core/conf/velocity/facets.vm +10 -0
  101. data/solr_sample_core/conf/velocity/footer.vm +43 -0
  102. data/solr_sample_core/conf/velocity/head.vm +35 -0
  103. data/solr_sample_core/conf/velocity/header.vm +7 -0
  104. data/solr_sample_core/conf/velocity/hit.vm +25 -0
  105. data/solr_sample_core/conf/velocity/hit_grouped.vm +43 -0
  106. data/solr_sample_core/conf/velocity/hit_plain.vm +25 -0
  107. data/solr_sample_core/conf/velocity/join_doc.vm +20 -0
  108. data/solr_sample_core/conf/velocity/jquery.autocomplete.css +48 -0
  109. data/solr_sample_core/conf/velocity/jquery.autocomplete.js +763 -0
  110. data/solr_sample_core/conf/velocity/layout.vm +24 -0
  111. data/solr_sample_core/conf/velocity/main.css +230 -0
  112. data/solr_sample_core/conf/velocity/mime_type_lists.vm +68 -0
  113. data/solr_sample_core/conf/velocity/pagination_bottom.vm +22 -0
  114. data/solr_sample_core/conf/velocity/pagination_top.vm +29 -0
  115. data/solr_sample_core/conf/velocity/product_doc.vm +32 -0
  116. data/solr_sample_core/conf/velocity/query.vm +42 -0
  117. data/solr_sample_core/conf/velocity/query_form.vm +64 -0
  118. data/solr_sample_core/conf/velocity/query_group.vm +43 -0
  119. data/solr_sample_core/conf/velocity/query_spatial.vm +75 -0
  120. data/solr_sample_core/conf/velocity/results_list.vm +22 -0
  121. data/solr_sample_core/conf/velocity/richtext_doc.vm +153 -0
  122. data/solr_sample_core/conf/velocity/suggest.vm +8 -0
  123. data/solr_sample_core/conf/velocity/tabs.vm +50 -0
  124. data/solr_sample_core/conf/xslt/example.xsl +132 -0
  125. data/solr_sample_core/conf/xslt/example_atom.xsl +67 -0
  126. data/solr_sample_core/conf/xslt/example_rss.xsl +66 -0
  127. data/solr_sample_core/conf/xslt/luke.xsl +337 -0
  128. data/solr_sample_core/conf/xslt/updateXml.xsl +70 -0
  129. data/spec/client_basics_spec.rb +26 -0
  130. data/spec/connect_spec.rb +25 -0
  131. data/spec/core_basics.rb +21 -0
  132. data/spec/index_spec.rb +31 -0
  133. data/spec/load_spec.rb +7 -0
  134. data/spec/minitest_helper.rb +36 -0
  135. data/spec/schema_spec.rb +113 -0
  136. metadata +284 -0
@@ -0,0 +1,2 @@
1
+ pizza
2
+ history
@@ -0,0 +1,14 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
File without changes
@@ -0,0 +1,29 @@
1
+ # The ASF licenses this file to You under the Apache License, Version 2.0
2
+ # (the "License"); you may not use this file except in compliance with
3
+ # the License. You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ #-----------------------------------------------------------------------
14
+ #some test synonym mappings unlikely to appear in real input text
15
+ aaafoo => aaabar
16
+ bbbfoo => bbbfoo bbbbar
17
+ cccfoo => cccbar cccbaz
18
+ fooaaa,baraaa,bazaaa
19
+
20
+ # Some synonym groups specific to this example
21
+ GB,gib,gigabyte,gigabytes
22
+ MB,mib,megabyte,megabytes
23
+ Television, Televisions, TV, TVs
24
+ #notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming
25
+ #after us won't split it into two words.
26
+
27
+ # Synonym mappings can be used for spelling correction too
28
+ pixima => pixma
29
+
@@ -0,0 +1,110 @@
1
+ # NOTE THAT EVERYTHING IS LOWERCASE!
2
+ # You'll want to put this after a case folder, e.g.,
3
+ # <charFilter class="solr.ICUNormalizer2CharFilterFactory"/>
4
+
5
+
6
+
7
+ # Programming
8
+ "+" => "plus"
9
+
10
+ ".net" => "dotnet"
11
+
12
+ # Common punctuation
13
+
14
+ " & " => " and "
15
+
16
+
17
+ # Science and Math
18
+ "±" => "plusorminus"
19
+ # prime, double-prime, triple-prime
20
+ "′" => "'"
21
+ "″" => "''"
22
+ "‴" => "'''"
23
+
24
+
25
+ # Numeric Subscripts
26
+ # Commented out, because they're handled by the normalizer
27
+ #"₀" => "0"
28
+ #"₁" => "1"
29
+ #"₂" => "2"
30
+ #"₃" => "3"
31
+ #"₄" => "4"
32
+ #"₅" => "5"
33
+ #"₆" => "6"
34
+ #"₇" => "7"
35
+ #"₈" => "8"
36
+ #"₉" => "9"
37
+
38
+
39
+ # Music
40
+
41
+ "a♯" => "asharp"
42
+ "b♯" => "bsharp"
43
+ "c♯" => "csharp"
44
+ "d♯" => "dsharp"
45
+ "e♯" => "esharp"
46
+ "f♯" => "fsharp"
47
+ "g♯" => "gsharp"
48
+
49
+ "a#" => "asharp"
50
+ "b#" => "bsharp"
51
+ "c#" => "csharp"
52
+ "d#" => "dsharp"
53
+ "e#" => "esharp"
54
+ "f#" => "fsharp"
55
+ "g#" => "gsharp"
56
+
57
+ "a sharp" => "asharp"
58
+ "b sharp" => "bsharp"
59
+ "c sharp" => "csharp"
60
+ "d sharp" => "dsharp"
61
+ "e sharp" => "esharp"
62
+ "f sharp" => "fsharp"
63
+ "g sharp" => "gsharp"
64
+
65
+ "a-sharp" => "asharp"
66
+ "b-sharp" => "bsharp"
67
+ "c-sharp" => "csharp"
68
+ "d-sharp" => "dsharp"
69
+ "e-sharp" => "esharp"
70
+ "f-sharp" => "fsharp"
71
+ "g-sharp" => "gsharp"
72
+
73
+ "a♭" => "aflat"
74
+ "b♭" => "bflat"
75
+ "c♭" => "cflat"
76
+ "d♭" => "dflat"
77
+ "e♭" => "eflat"
78
+ "f♭" => "fflat"
79
+ "g♭" => "gflat"
80
+
81
+ "a-flat" => "aflat"
82
+ "b-flat" => "bflat"
83
+ "c-flat" => "cflat"
84
+ "d-flat" => "dflat"
85
+ "e-flat" => "eflat"
86
+ "f-flat" => "fflat"
87
+ "g-flat" => "gflat"
88
+
89
+
90
+ "a♮" => "anatural"
91
+ "b♮" => "bnatural"
92
+ "c♮" => "cnatural"
93
+ "d♮" => "dnatural"
94
+ "e♮" => "enatural"
95
+ "f♮" => "fnatural"
96
+ "g♮" => "gnatural"
97
+
98
+ "a-natural" => "anatural"
99
+ "b-natural" => "bnatural"
100
+ "c-natural" => "cnatural"
101
+ "d-natural" => "dnatural"
102
+ "e-natural" => "enatural"
103
+ "f-natural" => "fnatural"
104
+ "g-natural" => "gnatural"
105
+
106
+
107
+
108
+
109
+
110
+
@@ -0,0 +1,53 @@
1
+ /*
2
+ This is a basic skeleton JavaScript update processor.
3
+
4
+ In order for this to be executed, it must be properly wired into solrconfig.xml; by default it is commented out in
5
+ the example solrconfig.xml and must be uncommented to be enabled.
6
+
7
+ See http://wiki.apache.org/solr/ScriptUpdateProcessor for more details.
8
+ */
9
+
10
+ function processAdd(cmd) {
11
+
12
+ doc = cmd.solrDoc; // org.apache.solr.common.SolrInputDocument
13
+ id = doc.getFieldValue("id");
14
+ logger.info("update-script#processAdd: id=" + id);
15
+
16
+ // Set a field value:
17
+ // doc.setField("foo_s", "whatever");
18
+
19
+ // Get a configuration parameter:
20
+ // config_param = params.get('config_param'); // "params" only exists if processor configured with <lst name="params">
21
+
22
+ // Get a request parameter:
23
+ // some_param = req.getParams().get("some_param")
24
+
25
+ // Add a field of field names that match a pattern:
26
+ // - Potentially useful to determine the fields/attributes represented in a result set, via faceting on field_name_ss
27
+ // field_names = doc.getFieldNames().toArray();
28
+ // for(i=0; i < field_names.length; i++) {
29
+ // field_name = field_names[i];
30
+ // if (/attr_.*/.test(field_name)) { doc.addField("attribute_ss", field_names[i]); }
31
+ // }
32
+
33
+ }
34
+
35
+ function processDelete(cmd) {
36
+ // no-op
37
+ }
38
+
39
+ function processMergeIndexes(cmd) {
40
+ // no-op
41
+ }
42
+
43
+ function processCommit(cmd) {
44
+ // no-op
45
+ }
46
+
47
+ function processRollback(cmd) {
48
+ // no-op
49
+ }
50
+
51
+ function finish() {
52
+ // no-op
53
+ }
@@ -0,0 +1,101 @@
1
+ Introduction
2
+ ------------
3
+ Solr Search Velocity Templates
4
+
5
+ A quick demo of using Solr using http://wiki.apache.org/solr/VelocityResponseWriter
6
+
7
+ You typically access these templates via:
8
+ http://localhost:8983/solr/collection1/browse
9
+
10
+ It's called "browse" because you can click around with your mouse
11
+ without needing to type any search terms. And of course it
12
+ also works as a standard search app as well.
13
+
14
+ Known Limitations
15
+ -----------------
16
+ * The /browse and the VelocityResponseWriter component
17
+ serve content directly from Solr, which usually requires
18
+ Solr's HTTP API to be exposed. Advanced users could
19
+ potentially access other parts of Solr directly.
20
+ * There are some hard coded fields in these templates.
21
+ Since these templates live under conf, they should be
22
+ considered part of the overall configuration, and
23
+ must be coordinated with schema.xml and solrconfig.xml
24
+
25
+ Velocity Info
26
+ -------------
27
+ Java-based template language.
28
+
29
+ It's nice in this context because change to the templates
30
+ are immediately visible in browser on the next visit.
31
+
32
+ Links:
33
+ http://velocity.apache.org
34
+ http://wiki.apache.org/velocity/
35
+ http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html
36
+
37
+
38
+ File List
39
+ ---------
40
+
41
+ System and Misc:
42
+ VM_global_library.vm - Macros used other templates,
43
+ exact filename is important for Velocity to see it
44
+ error.vm - shows errors, if any
45
+ debug.vm - includes toggle links for "explain" and "all fields"
46
+ activated by debug link in footer.vm
47
+ README.txt - this file
48
+
49
+ Overall Page Composition:
50
+ browse.vm - Main entry point into templates
51
+ layout.vm - overall HTML page layout
52
+ head.vm - elements in the <head> section of the HTML document
53
+ header.vm - top section of page visible to users
54
+ footer.vm - bottom section of page visible to users,
55
+ includes debug and help links
56
+ main.css - CSS style for overall pages
57
+ see also jquery.autocomplete.css
58
+
59
+ Query Form and Options:
60
+ query_form.vm - renders query form
61
+ query_group.vm - group by fields
62
+ e.g.: Manufacturer or Poplularity
63
+ query_spatial.vm - select box for location based Geospacial search
64
+
65
+ Spelling Suggestions:
66
+ did_you_mean.vm - hyperlinked spelling suggestions in results
67
+ suggest.vm - dynamic spelling suggestions
68
+ as you type in the search form
69
+ jquery.autocomplete.js - supporting files for dynamic suggestions
70
+ jquery.autocomplete.css - Most CSS is defined in main.css
71
+
72
+
73
+ Search Results, General:
74
+ (see also browse.vm)
75
+ tabs.vm - provides navigation to advanced search options
76
+ pagination_top.vm - paging and staticis at top of results
77
+ pagination_bottom.vm - paging and staticis at bottom of results
78
+ results_list.vm
79
+ hit.vm - called for each matching doc,
80
+ decides which template to use
81
+ hit_grouped.vm - display results grouped by field values
82
+ product_doc.vm - display a Product
83
+ join_doc.vm - display a joined document
84
+ richtext_doc.vm - display a complex/misc. document
85
+ hit_plain.vm - basic display of all fields,
86
+ edit results_list.vm to enable this
87
+
88
+
89
+ Search Results, Facets & Clusters:
90
+ facets.vm - calls the 4 facet and 1 cluster template
91
+ facet_fields.vm - display facets based on field values
92
+ e.g.: fields specified by &facet.field=
93
+ facet_queries.vm - display facets based on specific facet queries
94
+ e.g.: facets specified by &facet.query=
95
+ facet_ranges.vm - display facets based on ranges
96
+ e.g.: ranges specified by &facet.range=
97
+ facet_pivot.vm - display pivot based facets
98
+ e.g.: facets specified by &facet.pivot=
99
+ cluster.vm - if clustering is available
100
+ then call cluster_results.vm
101
+ cluster_results.vm - actual rendering of clusters
@@ -0,0 +1,175 @@
1
+ #**
2
+ * Global macros used by other templates.
3
+ * This file must be named VM_global_library.vm
4
+ * in order for Velocity to find it.
5
+ *#
6
+
7
+ #macro(param $key)$request.params.get($key)#end
8
+
9
+ #macro(url_root)/solr#end
10
+
11
+ ## TODO: s/url_for_solr/url_for_core/ and s/url_root/url_for_solr/
12
+ #macro(core_name)$request.core.name#end
13
+ #macro(url_for_solr)#{url_root}#if($request.core.name != "")/$request.core.name#end#end
14
+ #macro(url_for_home)#url_for_solr/browse#end
15
+
16
+ #macro(q)&q=$!{esc.url($params.get('q'))}#end
17
+
18
+ #macro(fqs $p)#foreach($fq in $p)#if($velocityCount>1)&#{end}fq=$esc.url($fq)#end#end
19
+
20
+ #macro(debug)#if($request.params.get('debugQuery'))&debugQuery=true#end#end
21
+
22
+ #macro(boostPrice)#if($request.params.get('bf') == 'price')&bf=price#end#end
23
+
24
+ #macro(annotate)#if($request.params.get('annotateBrowse'))&annotateBrowse=true#end#end
25
+
26
+ #macro(annTitle $msg)#if($annotate == true)title="$msg"#end#end
27
+
28
+ #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
29
+
30
+ #macro(qOpts)#set($queryOpts = $request.params.get("queryOpts"))#if($queryOpts && $queryOpts != "")&queryOpts=$queryOpts#end#end
31
+
32
+ #macro(group)#if($request.params.getBool("group") == true)&group=true#end#if($request.params.get("group.field"))#foreach($grp in $request.params.getParams('group.field'))&group.field=$grp#end#end#end
33
+
34
+ #macro(sort $p)#if($p)#foreach($s in $p)&sort=$esc.url($s)#end#end#end
35
+
36
+ #macro(lensNoQ)?#if($request.params.getParams('fq') and $list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#sort($request.params.getParams('sort'))#debug#boostPrice#annotate#spatial#qOpts#group#end
37
+ #macro(lens)#lensNoQ#q#end
38
+
39
+
40
+ #macro(url_for_lens)#{url_for_home}#lens#end
41
+
42
+ #macro(url_for_start $start)#url_for_home#lens&start=$start#end
43
+
44
+ #macro(url_for_filters $p)#url_for_home?#q#boostPrice#spatial#qOpts#if($list.size($p) > 0)&#fqs($p)#end#debug#end
45
+
46
+ #macro(url_for_nested_facet_query $field)#url_for_home#lens&fq=$esc.url($field)#end
47
+
48
+ ## TODO: convert to use {!raw f=$field}$value (with escaping of course)
49
+ #macro(url_for_facet_filter $field $value)#url_for_home#lens&fq=$esc.url($field):%22$esc.url($value)%22#end
50
+
51
+ #macro(url_for_facet_date_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end
52
+
53
+ #macro(url_for_facet_range_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end
54
+
55
+
56
+ #macro(link_to_previous_page $text)
57
+ #if($page.current_page_number > 1)
58
+ #set($prev_start = $page.start - $page.results_per_page)
59
+ <a class="prev-page" href="#url_for_start($prev_start)">$text</a>
60
+ #end
61
+ #end
62
+
63
+ #macro(link_to_next_page $text)
64
+ #if($page.current_page_number < $page.page_count)
65
+ #set($next_start = $page.start + $page.results_per_page)
66
+ <a class="next-page" href="#url_for_start($next_start)">$text</a>
67
+ #end
68
+ #end
69
+
70
+ #macro(link_to_page $page_number $text)
71
+ #if($page_number == $page.current_page_number)
72
+ $text
73
+ #else
74
+ #if($page_number <= $page.page_count)
75
+ #set($page_start = $page_number * $page.results_per_page - $page.results_per_page)
76
+ <a class="page" href="#url_for_start($page_start)">$text</a>
77
+ #end
78
+ #end
79
+ #end
80
+
81
+ #macro(display_facet_query $field, $display, $fieldName)
82
+ #if($field.size() > 0)
83
+ <span class="facet-field">$display</span>
84
+ <ul>
85
+ #foreach ($facet in $field)
86
+ #if ($facet.value > 0)
87
+ #set($facetURL = "#url_for_nested_facet_query($facet.key)")
88
+ #if ($facetURL != '')
89
+ <li><a href="$facetURL">$facet.key</a> ($facet.value)</li>
90
+ #end
91
+ #end
92
+ #end
93
+ </ul>
94
+ #end
95
+ #end
96
+
97
+
98
+ #macro(display_facet_range $field, $display, $fieldName, $start, $end, $gap, $before, $after)
99
+ <span class="facet-field">$display</span>
100
+ <ul>
101
+ #if($before && $before != "")
102
+ #set($value = "[* TO " + "#format_value($start)" + "}")
103
+ #set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
104
+ <li><a href="$facetURL">Less than #format_value($start)</a> ($before)</li>
105
+ #end
106
+ #foreach ($facet in $field)
107
+ #set($rangeEnd = "#range_get_to_value($facet.key, $gap)")
108
+ #set($value = "[" + $facet.key + " TO " + $rangeEnd + "}")
109
+ #set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
110
+ #if ($facetURL != '')
111
+ <li><a href="$facetURL">$facet.key - #format_value($rangeEnd)</a> ($facet.value)</li>
112
+ #end
113
+ #end
114
+ #if($end && $end != "" && $after > 0)
115
+ #set($value = "[" + "#format_value($end)" + " TO *}")
116
+ #set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
117
+ <li><a href="$facetURL">More than #format_value($end)</a> ($after)</li>
118
+ #end
119
+ </ul>
120
+ #end
121
+
122
+ ## $pivots is a list of facet_pivot
123
+ #macro(display_facet_pivot $pivots, $display)
124
+ #if($pivots.size() > 0)
125
+ <span class="facet-field">$display</span>
126
+ <ul>
127
+ #foreach ($pivot in $pivots)
128
+ #foreach ($entry in $pivot.value)
129
+ <a href="#url_for_facet_filter($entry.field, $entry.value)">$entry.field::$entry.value</a> ($entry.count)
130
+ <ul>
131
+ #foreach($nest in $entry.pivot)
132
+ <a href="#url_for_facet_filter($entry.field, $entry.value)&fq=$esc.url($nest.field):%22$esc.url($nest.value)%22">$nest.field::$nest.value</a> ($nest.count)
133
+ #end
134
+ </ul>
135
+ #end
136
+ #end
137
+ </ul>
138
+ #end
139
+ #end
140
+
141
+ #macro(field $f)
142
+ #if($response.response.highlighting.get($docId).get($f).get(0))
143
+ #set($pad = "")
144
+ #foreach($v in $response.response.highlighting.get($docId).get($f))
145
+ $pad$v##
146
+ #set($pad = " ... ")
147
+ #end
148
+ #else
149
+ #foreach($v in $doc.getFieldValues($f))
150
+ $v##
151
+ #end
152
+ #end
153
+ #end
154
+
155
+ #macro(utc_date $theDate)
156
+ $date.format("yyyy-MM-dd'T'HH:mm:ss'Z'",$theDate,$date.getLocale(),$date.getTimeZone().getTimeZone("UTC"))##
157
+ #end
158
+
159
+ #macro(format_value $val)
160
+ #if(${val.class.name} == "java.util.Date")
161
+ #utc_date($val)##
162
+ #else
163
+ $val##
164
+ #end
165
+ #end
166
+
167
+ #macro(range_get_to_value $inval, $gapval)
168
+ #if(${gapval.class.name} == "java.lang.String")
169
+ $inval$gapval##
170
+ #elseif(${gapval.class.name} == "java.lang.Float" || ${inval.class.name} == "java.lang.Float")
171
+ $math.toDouble($math.add($inval,$gapval))##
172
+ #else
173
+ $math.add($inval,$gapval)##
174
+ #end
175
+ #end