solrsan 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/solrsan/search.rb +18 -2
- data/lib/solrsan/version.rb +1 -1
- data/test/unit/search_test.rb +9 -0
- metadata +8 -8
data/lib/solrsan/search.rb
CHANGED
@@ -54,9 +54,11 @@ module Solrsan
|
|
54
54
|
:time => solr_response['responseHeader']['QTime'],
|
55
55
|
:status => solr_response['responseHeader']['status']
|
56
56
|
}
|
57
|
-
|
58
|
-
{:docs => docs, :metadata => metadata,
|
57
|
+
|
58
|
+
response = {:docs => docs, :metadata => metadata,
|
59
59
|
:facet_counts => parsed_facet_counts, :highlighting => highlighting}
|
60
|
+
|
61
|
+
embed_highlighting(response)
|
60
62
|
end
|
61
63
|
|
62
64
|
def parse_fq(fq)
|
@@ -130,6 +132,20 @@ module Solrsan
|
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
135
|
+
def embed_highlighting(search_response)
|
136
|
+
return search_response unless search_response[:highlighting]
|
137
|
+
|
138
|
+
highlighted_docs = search_response[:docs].map do |doc|
|
139
|
+
hl_metadata = search_response[:highlighting][doc['id']]
|
140
|
+
hl_metadata.each{ |k,v| doc[k] = v } if hl_metadata
|
141
|
+
|
142
|
+
doc
|
143
|
+
end
|
144
|
+
|
145
|
+
search_response[:docs] = highlighted_docs
|
146
|
+
search_response
|
147
|
+
end
|
148
|
+
|
133
149
|
end
|
134
150
|
end
|
135
151
|
end
|
data/lib/solrsan/version.rb
CHANGED
data/test/unit/search_test.rb
CHANGED
@@ -167,5 +167,14 @@ class SearchTest < Test::Unit::TestCase
|
|
167
167
|
first_result = highlighting.first
|
168
168
|
assert first_result[1]['tags'].include?("<em>solr</em>")
|
169
169
|
end
|
170
|
+
|
171
|
+
def test_embed_highlighting
|
172
|
+
Document.index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10, :tags => ["solr"]))
|
173
|
+
|
174
|
+
response = Document.search(:q => "solr",
|
175
|
+
:'hl.fl' => "*")
|
176
|
+
docs = response[:docs]
|
177
|
+
assert docs.first['tags'].include?("<em>solr</em>")
|
178
|
+
end
|
170
179
|
end
|
171
180
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solrsan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-03-
|
12
|
+
date: 2011-03-21 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
17
|
-
requirement: &
|
17
|
+
requirement: &2152897700 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2152897700
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activemodel
|
28
|
-
requirement: &
|
28
|
+
requirement: &2152897120 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 3.0.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2152897120
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: activesupport
|
39
|
-
requirement: &
|
39
|
+
requirement: &2152896640 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: 3.0.5
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2152896640
|
48
48
|
description: solrsan is a lightweight wrapper for using Apache Solr within a Ruby
|
49
49
|
application including Rails and Sinatra.
|
50
50
|
email:
|