rsolr 0.12.0 → 2.6.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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +29 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +2 -0
  5. data/CHANGES.txt +63 -260
  6. data/Gemfile +13 -0
  7. data/README.rdoc +177 -63
  8. data/Rakefile +19 -0
  9. data/lib/rsolr/char.rb +6 -0
  10. data/lib/rsolr/client.rb +344 -86
  11. data/lib/rsolr/document.rb +66 -0
  12. data/lib/rsolr/error.rb +182 -0
  13. data/lib/rsolr/field.rb +87 -0
  14. data/lib/rsolr/generator.rb +5 -0
  15. data/lib/rsolr/json.rb +60 -0
  16. data/lib/rsolr/response.rb +95 -0
  17. data/lib/rsolr/uri.rb +25 -0
  18. data/lib/rsolr/version.rb +7 -0
  19. data/lib/rsolr/xml.rb +150 -0
  20. data/lib/rsolr.rb +47 -35
  21. data/rsolr.gemspec +44 -31
  22. data/spec/api/client_spec.rb +423 -0
  23. data/spec/api/document_spec.rb +48 -0
  24. data/spec/api/error_spec.rb +158 -0
  25. data/spec/api/json_spec.rb +248 -0
  26. data/spec/api/pagination_spec.rb +31 -0
  27. data/spec/api/rsolr_spec.rb +31 -0
  28. data/spec/api/uri_spec.rb +37 -0
  29. data/spec/api/xml_spec.rb +255 -0
  30. data/spec/fixtures/basic_configs/_rest_managed.json +1 -0
  31. data/spec/fixtures/basic_configs/currency.xml +67 -0
  32. data/spec/fixtures/basic_configs/lang/stopwords_en.txt +54 -0
  33. data/spec/fixtures/basic_configs/protwords.txt +21 -0
  34. data/spec/fixtures/basic_configs/schema.xml +530 -0
  35. data/spec/fixtures/basic_configs/solrconfig.xml +572 -0
  36. data/spec/fixtures/basic_configs/stopwords.txt +14 -0
  37. data/spec/fixtures/basic_configs/synonyms.txt +29 -0
  38. data/spec/integration/solr5_spec.rb +38 -0
  39. data/spec/lib/rsolr/client_spec.rb +19 -0
  40. data/spec/spec_helper.rb +94 -0
  41. metadata +228 -54
  42. data/lib/rsolr/connection/net_http.rb +0 -48
  43. data/lib/rsolr/connection/requestable.rb +0 -43
  44. data/lib/rsolr/connection/utils.rb +0 -73
  45. data/lib/rsolr/connection.rb +0 -9
  46. data/lib/rsolr/message/document.rb +0 -48
  47. data/lib/rsolr/message/field.rb +0 -20
  48. data/lib/rsolr/message/generator.rb +0 -89
  49. data/lib/rsolr/message.rb +0 -8
@@ -1,89 +0,0 @@
1
- class RSolr::Message::Generator
2
-
3
- def build &block
4
- require 'builder'
5
- b = ::Builder::XmlMarkup.new(:indent=>0, :margin=>0, :encoding => 'UTF-8')
6
- b.instruct!
7
- block_given? ? yield(b) : b
8
- end
9
-
10
- # generates "add" xml for updating solr
11
- # "data" can be a hash or an array of hashes.
12
- # - each hash should be a simple key=>value pair representing a solr doc.
13
- # If a value is an array, multiple fields will be created.
14
- #
15
- # "add_attrs" can be a hash for setting the add xml element attributes.
16
- #
17
- # This method can also accept a block.
18
- # The value yielded to the block is a Message::Document; for each solr doc in "data".
19
- # You can set xml element attributes for each "doc" element or individual "field" elements.
20
- #
21
- # For example:
22
- #
23
- # solr.add({:id=>1, :nickname=>'Tim'}, {:boost=>5.0, :commitWithin=>1.0}) do |doc_msg|
24
- # doc_msg.attrs[:boost] = 10.00 # boost the document
25
- # nickname = doc_msg.field_by_name(:nickname)
26
- # nickname.attrs[:boost] = 20 if nickname.value=='Tim' # boost a field
27
- # end
28
- #
29
- # would result in an add element having the attributes boost="10.0"
30
- # and a commitWithin="1.0".
31
- # Each doc element would have a boost="10.0".
32
- # The "nickname" field would have a boost="20.0"
33
- # if the doc had a "nickname" field with the value of "Tim".
34
- #
35
- def add data, add_attrs={}, &block
36
- data = [data] unless data.is_a?(Array)
37
- build do |xml|
38
- xml.add(add_attrs) do |add_node|
39
- data.each do |doc|
40
- doc = RSolr::Message::Document.new(doc) if doc.respond_to?(:each_pair)
41
- yield doc if block_given?
42
- add_node.doc(doc.attrs) do |doc_node|
43
- doc.fields.each do |field_obj|
44
- doc_node.field field_obj.value, field_obj.attrs
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
51
-
52
- # generates a <commit/> message
53
- def commit(opts={})
54
- build {|xml| xml.commit opts}
55
- end
56
-
57
- # generates a <optimize/> message
58
- def optimize(opts={})
59
- build {|xml| xml.optimize opts}
60
- end
61
-
62
- # generates a <rollback/> message
63
- def rollback opts={}
64
- build {|xml| xml.rollback opts}
65
- end
66
-
67
- # generates a <delete><id>ID</id></delete> message
68
- # "ids" can be a single value or array of values
69
- def delete_by_id(ids)
70
- ids = [ids] unless ids.is_a?(Array)
71
- build do |xml|
72
- xml.delete do |delete_node|
73
- ids.each { |id| delete_node.id(id) }
74
- end
75
- end
76
- end
77
-
78
- # generates a <delete><query>ID</query></delete> message
79
- # "queries" can be a single value or an array of values
80
- def delete_by_query(queries)
81
- queries = [queries] unless queries.is_a?(Array)
82
- build do |xml|
83
- xml.delete do |delete_node|
84
- queries.each { |query| delete_node.query query }
85
- end
86
- end
87
- end
88
-
89
- end
data/lib/rsolr/message.rb DELETED
@@ -1,8 +0,0 @@
1
- # The Solr::Message::Generator class is the XML generation module for sending updates to Solr.
2
- module RSolr::Message
3
-
4
- autoload :Document, 'rsolr/message/document'
5
- autoload :Field, 'rsolr/message/field'
6
- autoload :Generator, 'rsolr/message/generator'
7
-
8
- end