solrbee 0.1.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Makefile +1 -4
- data/README.md +1 -11
- data/config/api.yml +22 -0
- data/lib/rom/solr.rb +56 -0
- data/lib/rom/solr/array.rb +10 -0
- data/lib/rom/solr/commands.rb +17 -0
- data/lib/rom/solr/commands/create_documents.rb +15 -0
- data/lib/rom/solr/commands/delete_documents.rb +15 -0
- data/lib/rom/solr/commands/delete_documents_by_query.rb +15 -0
- data/lib/rom/solr/commands/update_documents.rb +15 -0
- data/lib/rom/solr/dataset.rb +68 -0
- data/lib/rom/solr/document_repo.rb +45 -0
- data/lib/rom/solr/documents_dataset.rb +62 -0
- data/lib/rom/solr/documents_paginator.rb +21 -0
- data/lib/rom/solr/gateway.rb +14 -0
- data/lib/rom/solr/query.rb +135 -0
- data/lib/rom/solr/query_builder.rb +36 -0
- data/lib/rom/solr/query_templates.rb +34 -0
- data/lib/rom/solr/relation.rb +39 -0
- data/lib/rom/solr/relations/documents_relation.rb +215 -0
- data/lib/rom/solr/relations/schema_info_relation.rb +78 -0
- data/lib/rom/solr/repository.rb +9 -0
- data/lib/rom/solr/request_handler.rb +52 -0
- data/lib/rom/solr/response_handler.rb +12 -0
- data/lib/rom/solr/schema.rb +7 -0
- data/lib/rom/solr/schema_info_dataset.rb +19 -0
- data/lib/rom/solr/schema_info_repo.rb +29 -0
- data/lib/rom/solr/utils.rb +36 -0
- data/lib/solrbee.rb +22 -28
- data/lib/solrbee/version.rb +1 -1
- data/solrbee.gemspec +3 -1
- data/test.sh +14 -0
- metadata +58 -9
- data/lib/solrbee/api_methods.rb +0 -94
- data/lib/solrbee/client.rb +0 -31
- data/lib/solrbee/cursor.rb +0 -37
- data/lib/solrbee/query.rb +0 -35
- data/lib/solrbee/request.rb +0 -45
- data/lib/solrbee/response.rb +0 -25
data/lib/solrbee/query.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'hashie'
|
2
|
-
|
3
|
-
module Solrbee
|
4
|
-
#
|
5
|
-
# A query targeting the JSON Request API.
|
6
|
-
#
|
7
|
-
class Query < Hashie::Trash
|
8
|
-
property :query, from: :q, default: '*:*'
|
9
|
-
property :filter, from: :fq
|
10
|
-
property :limit, from: :rows, default: 10
|
11
|
-
property :fields, from: :fl
|
12
|
-
property :sort
|
13
|
-
property :offset, from: :start
|
14
|
-
property :facet
|
15
|
-
property :queries
|
16
|
-
property :params, default: {}
|
17
|
-
|
18
|
-
# Build a query for a Cursor
|
19
|
-
def self.cursor(params, unique_key)
|
20
|
-
Query.new(params).tap do |q|
|
21
|
-
q.delete(:offset) # incompatible with cursor
|
22
|
-
q.params[:cursorMark] = '*' # initial cursor mark
|
23
|
-
|
24
|
-
# Sort on unique key is required for cursor
|
25
|
-
q.sort = "#{unique_key} ASC" unless q.sort
|
26
|
-
unless q.sort =~ /\b#{unique_key}\b/
|
27
|
-
clauses = q.sort.split(/,/)
|
28
|
-
clauses << "#{unique_key} ASC"
|
29
|
-
q.sort = clauses.join(',')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
data/lib/solrbee/request.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module Solrbee
|
2
|
-
class Request
|
3
|
-
|
4
|
-
attr_reader :client, :path, :data, :params
|
5
|
-
|
6
|
-
def self.execute(*args)
|
7
|
-
new(*args).execute
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(client, path, data: nil, params: {})
|
11
|
-
@client = client
|
12
|
-
@path = path
|
13
|
-
@data = data
|
14
|
-
@params = params
|
15
|
-
end
|
16
|
-
|
17
|
-
def request_class
|
18
|
-
data ? Net::HTTP::Post : Net::HTTP::Get
|
19
|
-
end
|
20
|
-
|
21
|
-
def headers
|
22
|
-
Hash.new.tap do |h|
|
23
|
-
h['Accept'] = 'application/json'
|
24
|
-
h['Content-Type'] = 'application/json' if data
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def uri
|
29
|
-
client.uri.dup.tap do |u|
|
30
|
-
u.path += path
|
31
|
-
unless params.empty?
|
32
|
-
u.query = URI.encode_www_form(params)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def execute
|
38
|
-
req = request_class.new(uri, headers)
|
39
|
-
req.body = JSON.dump(data) if data
|
40
|
-
http_response = client.connection.request(req)
|
41
|
-
Response.new JSON.parse(http_response.body)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
data/lib/solrbee/response.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'hashie'
|
2
|
-
|
3
|
-
module Solrbee
|
4
|
-
class Response < Hashie::Mash
|
5
|
-
|
6
|
-
disable_warnings
|
7
|
-
|
8
|
-
def header
|
9
|
-
responseHeader
|
10
|
-
end
|
11
|
-
|
12
|
-
def num_found
|
13
|
-
response.numFound
|
14
|
-
end
|
15
|
-
|
16
|
-
def docs
|
17
|
-
response.docs
|
18
|
-
end
|
19
|
-
|
20
|
-
def doc
|
21
|
-
response.doc
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|