wukong-migrate 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTc5OTFjNjUwMzI5NzA2ODViNzZjMTBkYWY4YWE0YTg3Y2I0ZTEzZA==
4
+ OTYxYmMxOTdkZTkxZTI2ZmE5ODhhYTY5YzViOWU5YzAzMmE3OGQ5NQ==
5
5
  data.tar.gz: !binary |-
6
- ZDQ3MzMxMjM0MjUzOWI4NzcyYTg4NmFmZmI4NTVmZjYwNmNhNTA0ZQ==
6
+ Mzk3YWNkOTEzMjQyNWQ1MTQ4ZWRiZjIwYjY5NDE5Yjk1ZWEzNzMwMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmY2YTllNDBjY2E5ZjNhYjg2MzA3OGQ0ZTg2YTJkNTQzZDNkMDNiYzQ0MmE5
10
- N2Y5OWMxZjE0ZDFiNDhhOTkxYTljNTdmZmUwNWVkZDg2N2ViM2Q4Mzk2YmU4
11
- YTIxZDljNjJiMTE2YmUzOWE1OWQwY2NhNjQ3ZTQ3MGMyMjk4ZGM=
9
+ ZmU2ZWY3MWVkNjA0ZDVhNGM5YjNmZGJiYTQ0ZjIzMmU5Njk0Mzc0MWJiNTM2
10
+ NjFmY2Q3MTYwZTE3MjY0NDczZWQzMWEzODUwZjhiNmZmYmQ2YjIwM2QwZWY2
11
+ NzU1OTQwMmM3MDVkMjE0ZTcwZTBkODMxOGJmYjVkYzYwYzM3MWI=
12
12
  data.tar.gz: !binary |-
13
- ZjI0MDM3OGJkYzM1YTliOTUyZjY3NTQ0NDIzZGRmODJiYjE4OThmMDNmZjc0
14
- YjFjNzEzYmZjZDZhZTBjNGUyMDE2MjU2M2FiMWMyNjFiYWY4MGQ1NzhmYmJj
15
- NGE4OWUyYzIwMzQ0ZTFmMmRkY2JiZjRmNzBhNmM3NjJjZmM3Njg=
13
+ MGU5YWE3ZGQzN2NmNzFjOTA0ODE5MjM4NWQ4MzQwMWNjY2Y0ZDJhN2M2MDgz
14
+ MjY0MTg1ZDAyZTEyYzVjMDkxNTMxYmI2NzJiYWU4YWJhM2Y2NDA5ZGIxNTFj
15
+ ZThhZDljZjE3MTU1YjY2ZjUzNzQ1YTUxYzhhMjViMTA5Y2EyMWY=
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg/
@@ -72,19 +72,23 @@ module Gorillib
72
72
 
73
73
  Field.class_eval do
74
74
  field :es_options, Hash
75
+
76
+ def congruent?(klass, *others)
77
+ others.any?{ |o| o.ancestors.include? klass }
78
+ end
75
79
 
76
80
  def receive_as_type(factory, params)
77
- product = factory.try(:product)
81
+ products = Array[factory.try(:product) || factory].flatten
78
82
  case
79
- when product == Integer
83
+ when congruent?(Integer, *products)
80
84
  EsInteger.receive(params)
81
- when product == Float
85
+ when congruent?(Float, *products)
82
86
  EsFloat.receive(params)
83
- when product == Date
87
+ when congruent?(Date, *products) || congruent?(Time, *products)
84
88
  EsDate.receive(params)
85
- when product == [TrueClass, FalseClass]
89
+ when congruent?(TrueClass, *products) || congruent?(FalseClass, *products)
86
90
  EsBoolean.receive(params)
87
- when product == Array
91
+ when congruent?(Array, *products)
88
92
  receive_as_type(factory.items_factory, params)
89
93
  else
90
94
  EsString.receive(params)
@@ -4,7 +4,7 @@ class EsField
4
4
 
5
5
  field :index_as, String, doc: 'The name of the field that will be stored in the index. Defaults to the property/field name.'
6
6
  field :store, String, doc: 'Set to yes to store actual field in the index, no to not store it. Defaults to no (note, the JSON document itself is stored, and it can be retrieved from it).'
7
- field :index, :boolean, doc: 'Set to analyzed for the field to be indexed and searchable after being broken down into token using an analyzer. not_analyzed means that its still searchable, but does not go through any analysis process or broken down into tokens. no means that it won’t be searchable at all (as an individual field; it may still be included in _all). Setting to no disables include_in_all. Defaults to analyzed.'
7
+ field :index, String, doc: 'Set to analyzed for the field to be indexed and searchable after being broken down into token using an analyzer. not_analyzed means that its still searchable, but does not go through any analysis process or broken down into tokens. no means that it won’t be searchable at all (as an individual field; it may still be included in _all). Setting to no disables include_in_all. Defaults to analyzed.'
8
8
  field :boost, Float, doc: 'The boost value. Defaults to 1.0.'
9
9
  field :include_in_all, :boolean, doc: 'Should the field be included in the _all field (if enabled). If index is set to no this defaults to false, otherwise, defaults to true or to the parent object type setting.'
10
10
 
@@ -14,16 +14,16 @@ class EsField
14
14
  end
15
15
 
16
16
  class EsString < EsField
17
- field :index, String, default: 'not_analyzed', doc: 'Set to analyzed for the field to be indexed and searchable after being broken down into token using an analyzer. not_analyzed means that its still searchable, but does not go through any analysis process or broken down into tokens. no means that it won’t be searchable at all (as an individual field; it may still be included in _all). Setting to no disables include_in_all. Defaults to analyzed.'
18
- field :term_vector, String, doc: 'Possible values are no, yes, with_offsets, with_positions, with_positions_offsets. Defaults to no.'
19
- field :null_value, String, doc: 'When there is a (JSON) null value for the field, use the null_value as the field value. Defaults to not adding the field at all.'
20
- field :omit_norms, String, doc: 'Boolean value if norms should be omitted or not. Defaults to false for analyzed fields, and to true for not_analyzed fields.'
21
- field :index_options, String, doc: 'Allows to set the indexing options, possible values are docs (only doc numbers are indexed), freqs (doc numbers and term frequencies), and positions (doc numbers, term frequencies and positions). Defaults to positions for analyzed fields, and to docs for not_analyzed fields. Since 0.20.'
22
- field :analyzer, String, doc: 'The analyzer used to analyze the text contents when analyzed during indexing and when searching using a query string. Defaults to the globally configured analyzer.'
23
- field :index_analyzer, String, doc: 'The analyzer used to analyze the text contents when analyzed during indexing.'
24
- field :search_analyzer, String, doc: 'The analyzer used to analyze the field when part of a query string. Can be updated on an existing field.'
25
- field :ignore_above, Integer, doc: 'The analyzer will ignore strings larger than this size. Useful for generic not_analyzed fields that should ignore long text. (since @0.19.9).'
26
- field :position_offset_gap, Integer, doc: 'Position increment gap between field instances with the same field name. Defaults to 0.'
17
+ field :index, String, default: 'not_analyzed', doc: 'Set to analyzed for the field to be indexed and searchable after being broken down into token using an analyzer. not_analyzed means that its still searchable, but does not go through any analysis process or broken down into tokens. no means that it won’t be searchable at all (as an individual field; it may still be included in _all). Setting to no disables include_in_all. Defaults to analyzed.'
18
+ field :term_vector, String, doc: 'Possible values are no, yes, with_offsets, with_positions, with_positions_offsets. Defaults to no.'
19
+ field :null_value, String, doc: 'When there is a (JSON) null value for the field, use the null_value as the field value. Defaults to not adding the field at all.'
20
+ field :omit_norms, :boolean, default: true, doc: 'Boolean value if norms should be omitted or not. Defaults to false for analyzed fields, and to true for not_analyzed fields.'
21
+ field :index_options, String, default: 'docs', doc: 'Allows to set the indexing options, possible values are docs (only doc numbers are indexed), freqs (doc numbers and term frequencies), and positions (doc numbers, term frequencies and positions). Defaults to positions for analyzed fields, and to docs for not_analyzed fields. Since 0.20.'
22
+ field :analyzer, String, doc: 'The analyzer used to analyze the text contents when analyzed during indexing and when searching using a query string. Defaults to the globally configured analyzer.'
23
+ field :index_analyzer, String, doc: 'The analyzer used to analyze the text contents when analyzed during indexing.'
24
+ field :search_analyzer, String, doc: 'The analyzer used to analyze the field when part of a query string. Can be updated on an existing field.'
25
+ field :ignore_above, Integer, doc: 'The analyzer will ignore strings larger than this size. Useful for generic not_analyzed fields that should ignore long text. (since @0.19.9).'
26
+ field :position_offset_gap, Integer, doc: 'Position increment gap between field instances with the same field name. Defaults to 0.'
27
27
 
28
28
  def short_type() 'string' ; end
29
29
  end
@@ -38,6 +38,7 @@ class ObjectDsl < EsMigrationDsl
38
38
  magic :analyzer_field, String, doc: 'Specify a field this document should use as an analyzer'
39
39
  magic :boost_field, String, doc: 'Specify a field this document should use as a boost'
40
40
  magic :parent, String, doc: 'Specify this documents _parent type'
41
+ magic :routing, String, doc: 'Specify a field this document should use to route'
41
42
 
42
43
  def mapping_rules
43
44
  {}.tap do |rules|
@@ -49,6 +50,7 @@ class ObjectDsl < EsMigrationDsl
49
50
  rules[:_analyzer] = { path: analyzer_field } if attribute_set?(:analyzer_field)
50
51
  rules[:_boost] = { name: boost_field } if attribute_set?(:boost_field)
51
52
  rules[:_parent] = { type: parent } if attribute_set?(:parent)
53
+ rules[:_routing] = { path: routing } if attribute_set?(:routing)
52
54
  end
53
55
  end
54
56
 
@@ -1,5 +1,5 @@
1
1
  module Wukong
2
2
  module Migrate
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@ describe Gorillib::Model do
13
13
  subject.class_eval do
14
14
  field :foo, String, es_options: { analyzer: 'whitespace' }
15
15
  end
16
- subject.to_mapping.should eq({ properties: { foo: { type: 'string', index: 'not_analyzed', analyzer: 'whitespace' } } })
16
+ subject.to_mapping.should eq({ properties: { foo: { type: 'string', index: 'not_analyzed', analyzer: 'whitespace', omit_norms: true, index_options: 'docs' } } })
17
17
  end
18
18
 
19
19
  it 'generates integer mappings correctly' do
@@ -60,7 +60,7 @@ describe Gorillib::Model do
60
60
 
61
61
  field :bar, Bar
62
62
  end
63
- subject.to_mapping.should eq({ properties: { bar: { properties: { baz: { type: 'string', index: 'not_analyzed' } } } } })
63
+ subject.to_mapping.should eq({ properties: { bar: { properties: { baz: { type: 'string', index: 'not_analyzed', omit_norms: true, index_options: 'docs' } } } } })
64
64
  end
65
65
 
66
66
  it 'handles non-standard fields as strings' do
@@ -70,7 +70,7 @@ describe Gorillib::Model do
70
70
  end
71
71
  field :bar, Baz
72
72
  end
73
- subject.to_mapping.should eq({ properties: { bar: { type: 'string', index: 'not_analyzed' } } })
73
+ subject.to_mapping.should eq({ properties: { bar: { type: 'string', index: 'not_analyzed', omit_norms: true, index_options: 'docs' } } })
74
74
  end
75
75
  end
76
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wukong-migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Dempsey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-25 00:00:00.000000000 Z
11
+ date: 2013-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wukong-deploy
@@ -76,8 +76,8 @@ executables:
76
76
  extensions: []
77
77
  extra_rdoc_files: []
78
78
  files:
79
+ - .gitignore
79
80
  - Gemfile
80
- - Gemfile.lock
81
81
  - Rakefile
82
82
  - bin/wu-migrate
83
83
  - lib/gorillib/model/elasticsearch_ext.rb
data/Gemfile.lock DELETED
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- wukong-migrate (0.0.1)
5
- gorillib (~> 0.5)
6
- httparty (~> 0.11)
7
- rake (>= 0.8.7)
8
- wukong-deploy (>= 0.1.1)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- configliere (0.4.18)
14
- highline (>= 1.5.2)
15
- multi_json (>= 1.1)
16
- diff-lcs (1.2.4)
17
- diffy (3.0.1)
18
- erubis (2.7.0)
19
- eventmachine (1.0.3)
20
- forgery (0.5.0)
21
- gorillib (0.5.0)
22
- configliere (>= 0.4.13)
23
- json
24
- multi_json (>= 1.1)
25
- highline (1.6.19)
26
- httparty (0.11.0)
27
- multi_json (~> 1.0)
28
- multi_xml (>= 0.5.2)
29
- json (1.8.0)
30
- log4r (1.1.10)
31
- multi_json (1.7.7)
32
- multi_xml (0.5.4)
33
- rake (0.9.6)
34
- rspec (2.14.1)
35
- rspec-core (~> 2.14.0)
36
- rspec-expectations (~> 2.14.0)
37
- rspec-mocks (~> 2.14.0)
38
- rspec-core (2.14.4)
39
- rspec-expectations (2.14.0)
40
- diff-lcs (>= 1.1.3, < 2.0)
41
- rspec-mocks (2.14.1)
42
- uuidtools (2.1.4)
43
- vayacondios-client (0.2.6)
44
- configliere (>= 0.4.16)
45
- gorillib (>= 0.4.2)
46
- multi_json (>= 1.3.6)
47
- wukong (3.0.1)
48
- configliere (>= 0.4.18)
49
- eventmachine
50
- forgery
51
- gorillib (>= 0.4.2)
52
- log4r
53
- multi_json (>= 1.3.6)
54
- uuidtools
55
- vayacondios-client (>= 0.1.2)
56
- wukong-deploy (0.1.1)
57
- diffy
58
- erubis
59
- rake (~> 0.9)
60
- wukong (= 3.0.1)
61
-
62
- PLATFORMS
63
- ruby
64
-
65
- DEPENDENCIES
66
- rspec (~> 2)
67
- wukong-migrate!