pdf_search 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/web_server.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44d5c7c69ebe317bcd1c609a1a93c33f2f180839f58e98180d984b1ab170cb1c
|
4
|
+
data.tar.gz: 2d607c5f7e6ffeb8b8667821486855f657681fc3c8332aebd315c3d5da8dc686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23bfdd1a6cf8da807f26e68aa48093d0afd610bf44aa580b4018c7a41de70da36a198746876287b5dcd1deb60d9aef9301b130b792ead9a77013db6d1bd24713
|
7
|
+
data.tar.gz: c5e50bb4a3b7f4c54fd69ff249feddc484ca32b4060873dfd63967b21cf09374e0ab6af9329f60d1500a1199b74afdc0d0b6665c4169a4ea0192f013d8df37f5
|
data/lib/web_server.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'webrick'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
class PdfSearch::WebServer
|
4
5
|
attr_accessor :daemon
|
@@ -9,7 +10,7 @@ class PdfSearch::WebServer
|
|
9
10
|
|
10
11
|
server.mount_proc '/search' do |request, response|
|
11
12
|
query = request.query["query"]
|
12
|
-
elastic_response =
|
13
|
+
elastic_response = ::PdfSearch::ElasticSearchClient.search q: "text:#{query}"
|
13
14
|
response.body = response_html(elastic_response)
|
14
15
|
end
|
15
16
|
|
@@ -23,9 +24,8 @@ class PdfSearch::WebServer
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
def response_html(
|
27
|
-
results =
|
28
|
-
|
27
|
+
def response_html(es_response)
|
28
|
+
results = es_response['hits']['hits']
|
29
29
|
results.map do |result|
|
30
30
|
"<li>#{result["_source"]["text"]}</li>"
|
31
31
|
end.join("\n")
|