estella 2.0.0 → 5.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 005678de72fb7aef97a46d6cbc64d198ea6104cb
4
- data.tar.gz: d9dae12511d40cd83781a63946e0bf00c500165b
3
+ metadata.gz: 9f1958b160694e75e7771648c51db035971f5977
4
+ data.tar.gz: a178684df8dbcfdfbc73464aaac3c40cbdaf9611
5
5
  SHA512:
6
- metadata.gz: da680ba976b1deb2ccc3a88185caaf3a95e36e0523da8fe9f29ddd1a085e33f56ede8a2deef3b7d48bf3386828c88fd37f26428f1cf36876bce4e69691a1f785
7
- data.tar.gz: c2bd518ae2d407d72cdc78e130b63873c2dee8889987e81e481395a54abb771e4ba514304aeb59361c8e5af2ef1fa6dbc7d8097ef9a0ea4581d4c942abda4e16
6
+ metadata.gz: 7664182130bd8c9016e7d6a606e733a7d88039c97167247b46d48a01ee18ebb01fe36a88a6aa1c55bd5c702727e31bff6eaa740151fa1aaac48d1fbea7b7b031
7
+ data.tar.gz: 75e4fcbb9b614af1b498d5d143b3cc0508d9801cbb248d6231e8455fff27a42e096be8b5794b799406d35e0a3a09138f246ad15f241a5dad16dd3a0eb535e5e1
@@ -1,30 +1,30 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-01-27 12:52:56 -0500 using RuboCop version 0.47.1.
3
+ # on 2019-05-20 16:29:39 -0400 using RuboCop version 0.60.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
9
+ # Offense count: 3
10
10
  Metrics/AbcSize:
11
11
  Max: 18
12
12
 
13
13
  # Offense count: 3
14
14
  # Configuration parameters: CountComments, ExcludedMethods.
15
+ # ExcludedMethods: refine
15
16
  Metrics/BlockLength:
16
17
  Max: 134
17
18
 
18
- # Offense count: 30
19
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
20
- # URISchemes: http, https
21
- Metrics/LineLength:
22
- Max: 135
23
-
24
19
  # Offense count: 1
25
20
  # Configuration parameters: CountComments.
21
+ Metrics/ClassLength:
22
+ Max: 103
23
+
24
+ # Offense count: 1
25
+ # Configuration parameters: CountComments, ExcludedMethods.
26
26
  Metrics/MethodLength:
27
- Max: 13
27
+ Max: 12
28
28
 
29
29
  # Offense count: 3
30
30
  # Cop supports --auto-correct.
@@ -65,8 +65,14 @@ Style/MutableConstant:
65
65
 
66
66
  # Offense count: 2
67
67
  # Cop supports --auto-correct.
68
- # Configuration parameters: EnforcedStyle, SupportedStyles.
68
+ # Configuration parameters: EnforcedStyle.
69
69
  # SupportedStyles: only_raise, only_fail, semantic
70
70
  Style/SignalException:
71
71
  Exclude:
72
72
  - 'lib/estella/parser.rb'
73
+
74
+ # Offense count: 30
75
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
76
+ # URISchemes: http, https
77
+ Metrics/LineLength:
78
+ Max: 135
@@ -6,14 +6,12 @@ before_script:
6
6
  - bundle exec danger
7
7
 
8
8
  env:
9
- - ELASTICSEARCH=https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.4.5/elasticsearch-2.4.5.deb
10
- - ELASTICSEARCH=https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.deb
9
+ - ELASTICSEARCH=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.deb
11
10
 
12
11
  before_install:
13
12
  - gem update --system
14
13
  - gem update bundler
15
14
  - curl -O $ELASTICSEARCH && sudo dpkg -i --force-confnew elasticsearch-*.deb
16
- - "echo 'script.inline: on' | sudo tee -a /etc/elasticsearch/elasticsearch.yml"
17
15
  - sudo /etc/init.d/elasticsearch start
18
16
  - until curl --silent -XGET --fail http://localhost:9200; do printf '.'; sleep 1; done
19
17
 
@@ -1,5 +1,9 @@
1
1
  ## Changelog
2
2
 
3
+ ### 5.0.0
4
+
5
+ * [#29](https://github.com/artsy/estella/pull/29): Support Elasticsearch 5.x - [@izakp](https://github.com/izakp).
6
+
3
7
  ### 2.0.0
4
8
 
5
9
  * [#25](https://github.com/artsy/estella/pull/25): Support ElasticSearch 1.5.x - [@dblock](https://github.com/dblock).
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.add_runtime_dependency 'activemodel'
18
18
  gem.add_runtime_dependency 'activesupport'
19
- gem.add_runtime_dependency 'elasticsearch-model', '~> 2.0'
19
+ gem.add_runtime_dependency 'elasticsearch-model', '~> 5.0'
20
20
 
21
21
  gem.add_development_dependency 'activerecord'
22
22
  gem.add_development_dependency 'rake', '~> 11.0'
@@ -18,6 +18,9 @@ module Estella
18
18
  NGRAM_ANALYZER =
19
19
  { type: 'custom', tokenizer: 'standard_tokenizer', filter: %w[lowercase asciifolding front_ngram_filter] }
20
20
 
21
+ EMAIL_ANALYZER =
22
+ { type: 'custom', tokenizer: 'uax_url_email', filter: %w[lowercase stop] }
23
+
21
24
  DEFAULT_ANALYSIS = {
22
25
  tokenizer: {
23
26
  standard_tokenizer: { type: 'standard' }
@@ -30,15 +33,17 @@ module Estella
30
33
  snowball_analyzer: SNOWBALL_ANALYZER,
31
34
  shingle_analyzer: SHINGLE_ANALYZER,
32
35
  ngram_analyzer: NGRAM_ANALYZER,
36
+ email_analyzer: EMAIL_ANALYZER,
33
37
  search_analyzer: DEFAULT_ANALYZER
34
38
  }
35
39
  }
36
40
 
37
41
  DEFAULT_FIELDS = {
38
- default: { type: 'string', analyzer: 'default_analyzer' },
39
- snowball: { type: 'string', analyzer: 'snowball_analyzer' },
40
- shingle: { type: 'string', analyzer: 'shingle_analyzer' },
41
- ngram: { type: 'string', analyzer: 'ngram_analyzer', search_analyzer: 'search_analyzer' }
42
+ default: { type: 'text', analyzer: 'default_analyzer' },
43
+ snowball: { type: 'text', analyzer: 'snowball_analyzer' },
44
+ shingle: { type: 'text', analyzer: 'shingle_analyzer' },
45
+ ngram: { type: 'text', analyzer: 'ngram_analyzer', search_analyzer: 'search_analyzer' },
46
+ email: { type: 'text', analyzer: 'email_analyzer' }
42
47
  }
43
48
 
44
49
  DEFAULT_FIELD_FACTORS = {
@@ -46,7 +51,8 @@ module Estella
46
51
  ngram: 10,
47
52
  snowball: 3,
48
53
  shingle: 2,
49
- search: 2
54
+ search: 2,
55
+ email: 2
50
56
  }
51
57
 
52
58
  FULLTEXT_ANALYSIS = DEFAULT_FIELDS.keys
@@ -18,7 +18,8 @@ module Estella
18
18
  using = opts[:using] || name
19
19
  analysis = opts[:analysis] & @model.default_analysis_fields.keys
20
20
  opts[:fields] ||= Hash[analysis.zip(@model.default_analysis_fields.values_at(*analysis))] if analysis
21
-
21
+ include_raw = opts.delete(:include_raw)
22
+ opts[:fields][:raw] = { type: 'keyword' } if include_raw
22
23
  @model.indexed_json.merge!(name => using)
23
24
  @model.indexed_fields.merge!(name => opts)
24
25
  end
@@ -8,10 +8,7 @@ module Estella
8
8
  @params = params
9
9
  @query = {
10
10
  _source: false,
11
- query: {},
12
- filter: {
13
- bool: { must: [], must_not: [] }
14
- },
11
+ query: { bool: { must: [{ match_all: {} }], must_not: [], filter: [] } },
15
12
  aggregations: {}
16
13
  }
17
14
  add_query
@@ -21,14 +18,22 @@ module Estella
21
18
  end
22
19
 
23
20
  def must(filter)
24
- query[:filter][:bool][:must] << filter
21
+ if query[:query][:function_score]
22
+ query[:query][:function_score][:query][:bool][:filter] << filter
23
+ else
24
+ query[:query][:bool][:filter] << filter
25
+ end
25
26
  end
26
27
 
27
28
  def exclude(filter)
28
- query[:filter][:bool][:must_not] << filter
29
+ if query[:query][:function_score]
30
+ query[:query][:function_score][:query][:bool][:must_not] << filter
31
+ else
32
+ query[:query][:bool][:must_not] << filter
33
+ end
29
34
  end
30
35
 
31
- def query_definition
36
+ def term_query_definition
32
37
  {
33
38
  multi_match: {
34
39
  type: 'most_fields',
@@ -50,18 +55,22 @@ module Estella
50
55
  end
51
56
 
52
57
  def add_query
53
- if params[:term] && params[:indexed_fields]
54
- add_term_query
55
- else
56
- query[:query] = { match_all: {} }
57
- end
58
+ return unless params[:term] && params[:indexed_fields]
59
+
60
+ add_term_query
58
61
  end
59
62
 
60
63
  # fulltext search across all string fields
61
64
  def add_term_query
62
65
  query[:query] = {
63
66
  function_score: {
64
- query: query_definition
67
+ query: {
68
+ bool: {
69
+ must: term_query_definition,
70
+ filter: [],
71
+ must_not: []
72
+ }
73
+ }
65
74
  }
66
75
  }
67
76
 
@@ -88,7 +97,7 @@ module Estella
88
97
  # boost them by factor if provided
89
98
  def term_search_fields
90
99
  params[:indexed_fields]
91
- .select { |_, opts| opts[:type].to_s == 'string' }
100
+ .select { |_, opts| opts[:type].to_s == 'text' }
92
101
  .reject { |_, opts| opts[:analysis].nil? }
93
102
  .map do |field, opts|
94
103
  opts[:analysis].map do |analyzer|
@@ -59,7 +59,7 @@ module Estella
59
59
  # indexes slug attribute by default
60
60
  def index_slug
61
61
  if defined? slug
62
- indexed_fields.merge!(slug: { type: :string, index: :not_analyzed })
62
+ indexed_fields.merge!(slug: { type: :keyword })
63
63
  indexed_json.merge!(slug: :slug)
64
64
  end
65
65
  end
@@ -77,7 +77,7 @@ module Estella
77
77
  settings(settings) do
78
78
  mapping do
79
79
  indexed_fields.each do |name, opts|
80
- indexes name, opts.except(:analysis, :using, :factor, :filter)
80
+ indexes name, opts.except(:analysis, :using, :factor, :filter, :include_raw)
81
81
  end
82
82
  end
83
83
  end
@@ -1,3 +1,3 @@
1
1
  module Estella
2
- VERSION = '2.0.0'
2
+ VERSION = '5.0.0'
3
3
  end
@@ -18,8 +18,8 @@ describe Estella::Searchable, type: :model do
18
18
  end
19
19
 
20
20
  searchable do
21
- field :title, type: :string, analysis: Estella::Analysis::FULLTEXT_ANALYSIS, factor: 1.0
22
- field :keywords, type: :string, analysis: %i[default snowball], factor: 0.5
21
+ field :title, type: :text, analysis: Estella::Analysis::FULLTEXT_ANALYSIS, factor: 1.0
22
+ field :keywords, type: :text, analysis: %i[default snowball], factor: 0.5
23
23
  field :follows_count, type: :integer
24
24
  field :published, type: :boolean, filter: true
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: estella
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anil Bawa-Cavia
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '2.0'
48
+ version: '5.0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '2.0'
55
+ version: '5.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: activerecord
58
58
  requirement: !ruby/object:Gem::Requirement