indexers 4.1.0.1 → 5.1.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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +17 -23
  4. data/Rakefile +1 -3
  5. data/lib/indexers.rb +1 -1
  6. data/lib/indexers/collection.rb +10 -12
  7. data/lib/indexers/concern.rb +1 -1
  8. data/lib/indexers/version.rb +1 -1
  9. metadata +18 -129
  10. data/test/dsl_test.rb +0 -127
  11. data/test/dummy/Rakefile +0 -5
  12. data/test/dummy/app/assets/javascripts/application.js +0 -13
  13. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  14. data/test/dummy/app/controllers/application_controller.rb +0 -5
  15. data/test/dummy/app/helpers/application_helper.rb +0 -2
  16. data/test/dummy/app/indexers/product_indexer.rb +0 -55
  17. data/test/dummy/app/indexers/shop_indexer.rb +0 -28
  18. data/test/dummy/app/models/product.rb +0 -5
  19. data/test/dummy/app/models/shop.rb +0 -5
  20. data/test/dummy/app/views/layouts/application.html.erb +0 -12
  21. data/test/dummy/bin/bundle +0 -4
  22. data/test/dummy/bin/rails +0 -5
  23. data/test/dummy/bin/rake +0 -5
  24. data/test/dummy/bin/setup +0 -30
  25. data/test/dummy/config.ru +0 -4
  26. data/test/dummy/config/application.rb +0 -25
  27. data/test/dummy/config/boot.rb +0 -5
  28. data/test/dummy/config/database.yml +0 -10
  29. data/test/dummy/config/database.yml.travis +0 -3
  30. data/test/dummy/config/elasticsearch.yml +0 -15
  31. data/test/dummy/config/environment.rb +0 -5
  32. data/test/dummy/config/environments/development.rb +0 -41
  33. data/test/dummy/config/environments/production.rb +0 -79
  34. data/test/dummy/config/environments/test.rb +0 -42
  35. data/test/dummy/config/initializers/assets.rb +0 -11
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  37. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  39. data/test/dummy/config/initializers/indexers.rb +0 -65
  40. data/test/dummy/config/initializers/inflections.rb +0 -16
  41. data/test/dummy/config/initializers/mime_types.rb +0 -4
  42. data/test/dummy/config/initializers/session_store.rb +0 -3
  43. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  44. data/test/dummy/config/locales/en.yml +0 -23
  45. data/test/dummy/config/routes.rb +0 -56
  46. data/test/dummy/config/secrets.yml +0 -22
  47. data/test/dummy/db/migrate/20161104164148_create_products.rb +0 -14
  48. data/test/dummy/db/migrate/20161104182219_create_shops.rb +0 -9
  49. data/test/dummy/db/schema.rb +0 -36
  50. data/test/dummy/log/development.log +0 -114
  51. data/test/dummy/log/test.log +0 -21168
  52. data/test/dummy/public/404.html +0 -61
  53. data/test/dummy/public/422.html +0 -61
  54. data/test/dummy/public/500.html +0 -60
  55. data/test/dummy/public/favicon.ico +0 -0
  56. data/test/generator_test.rb +0 -26
  57. data/test/index_test.rb +0 -42
  58. data/test/record_test.rb +0 -25
  59. data/test/search_test.rb +0 -164
  60. data/test/task_test.rb +0 -31
  61. data/test/test_helper.rb +0 -14
data/test/dsl_test.rb DELETED
@@ -1,127 +0,0 @@
1
- require 'test_helper'
2
-
3
- class DslTest < ActiveSupport::TestCase
4
-
5
- test 'search' do
6
- shop = Shop.create
7
- seed = rand
8
- days = [1,2,3]
9
- opens_at = Time.now.to_i
10
- closes_at = (Time.now + 1.day).to_i
11
- assert_equal(
12
- {
13
- query: {
14
- function_score: {
15
- functions: [
16
- { random_score: { seed: seed } },
17
- {
18
- weight: 400,
19
- filter: {
20
- bool: {
21
- must: [
22
- { term: {} }
23
- ]
24
- }
25
- }
26
- }
27
- ]
28
- },
29
- query: {
30
- filtered: {
31
- filter: {
32
- bool: {
33
- should: [
34
- { term: { :'schedules.days' => days } }
35
- ],
36
- must: [
37
- { range: { :'schedules.opens_at' => { lte: opens_at } } }
38
- ],
39
- must_not: [
40
- {
41
- has_parent: {
42
- type: 'products',
43
- query: {
44
- filtered: {
45
- filter: {
46
- bool: {
47
- must: [
48
- {
49
- term: {
50
- _parent: shop.id
51
- }
52
- }
53
- ]
54
- }
55
- },
56
- query: {
57
- match_all: {}
58
- }
59
- }
60
- }
61
- }
62
- }
63
- ]
64
- }
65
- }
66
- }
67
- }
68
- },
69
- sort: [
70
- { name: 'asc' }
71
- ],
72
- size: {}
73
- },
74
- build do
75
- query do
76
- function_score do
77
- functions do
78
- random_score do
79
- seed seed
80
- end
81
- filter weight: 400 do
82
- bool do
83
- must do
84
- term
85
- end
86
- end
87
- end
88
- end
89
- end
90
- query do
91
- filtered do
92
- filter do
93
- bool do
94
- should do
95
- term 'schedules.days' => days
96
- end
97
- must do
98
- range 'schedules.opens_at' do
99
- lte opens_at
100
- end
101
- end
102
- must_not do
103
- has_parent do
104
- type 'products'
105
- query :product, shop: shop
106
- end
107
- end
108
- end
109
- end
110
- end
111
- end
112
- end
113
- sort %w(asc) do |order|
114
- name order
115
- end
116
- size
117
- end
118
- )
119
- end
120
-
121
- private
122
-
123
- def build(&block)
124
- Indexers::Dsl::Search.new(&block).to_h
125
- end
126
-
127
- end
data/test/dummy/Rakefile DELETED
@@ -1,5 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
- Rails.application.load_tasks
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,55 +0,0 @@
1
- Indexers.define :product do
2
-
3
- mappings do
4
- properties :name, :category, :shop_id, :price, :currency, :product_suggestions
5
- _parent type: 'shop'
6
- end
7
-
8
- serialize do |record|
9
- extract record, :name, :category, :shop_id, :price, :currency
10
- product_suggestions do
11
- input [record.name, transliterate(record.name)].uniq
12
- output record.name
13
- context do
14
- shop_id [record.shop_id.to_s, 'all'].compact
15
- end
16
- end
17
- end
18
-
19
- search do |*args|
20
- options = args.extract_options!
21
- shop = options[:shop]
22
- term = args.first
23
- query do
24
- filtered do
25
- traits :filter
26
- query do
27
- if term.present?
28
- multi_match do
29
- query term
30
- type 'phrase_prefix'
31
- fields %w(name category)
32
- end
33
- else
34
- match_all
35
- end
36
- end
37
- end
38
- end
39
- end
40
-
41
- trait :filter do
42
- filter do
43
- bool do
44
- must do
45
- if shop
46
- term do
47
- _parent shop.id
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end
54
-
55
- end
@@ -1,28 +0,0 @@
1
- Indexers.define :shop do
2
-
3
- mappings do
4
- properties :name
5
- end
6
-
7
- serialize do |record|
8
- name record.name
9
- end
10
-
11
- search do |*args|
12
- options = args.extract_options!
13
- term = args.first
14
- query do
15
- if term.present?
16
- match do
17
- name do
18
- query term
19
- type 'phrase_prefix'
20
- end
21
- end
22
- else
23
- match_all
24
- end
25
- end
26
- end
27
-
28
- end
@@ -1,5 +0,0 @@
1
- class Product < ActiveRecord::Base
2
-
3
- belongs_to :shop
4
-
5
- end
@@ -1,5 +0,0 @@
1
- class Shop < ActiveRecord::Base
2
-
3
- has_many :products
4
-
5
- end
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
- <%= yield %>
11
- </body>
12
- </html>
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
4
- load Gem.bin_path('bundler', 'bundle')
data/test/dummy/bin/rails DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- APP_PATH = File.expand_path('../../config/application', __FILE__)
4
- require_relative '../config/boot'
5
- require 'rails/commands'
data/test/dummy/bin/rake DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../config/boot'
4
- require 'rake'
5
- Rake.application.run
data/test/dummy/bin/setup DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'pathname'
4
-
5
- # path to your application root.
6
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7
-
8
- Dir.chdir APP_ROOT do
9
- # This script is a starting point to setup your application.
10
- # Add necessary setup steps to this file:
11
-
12
- puts '== Installing dependencies =='
13
- system 'gem install bundler --conservative'
14
- system 'bundle check || bundle install'
15
-
16
- # puts "\n== Copying sample files =="
17
- # unless File.exist?('config/database.yml')
18
- # system 'cp config/database.yml.sample config/database.yml'
19
- # end
20
-
21
- puts "\n== Preparing database =="
22
- system 'bin/rake db:setup'
23
-
24
- puts "\n== Removing old logs and tempfiles =="
25
- system 'rm -f log/*'
26
- system 'rm -rf tmp/cache'
27
-
28
- puts "\n== Restarting application server =="
29
- system 'touch tmp/restart.txt'
30
- end
data/test/dummy/config.ru DELETED
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails.application
@@ -1,25 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require(*Rails.groups)
6
- require 'indexers'
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
-
22
- # Do not swallow errors in after_commit/after_rollback callbacks.
23
- config.active_record.raise_in_transactional_callbacks = true
24
- end
25
- end
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,10 +0,0 @@
1
- default: &default
2
- adapter: postgresql
3
-
4
- development:
5
- <<: *default
6
- database: indexers_development
7
-
8
- test:
9
- <<: *default
10
- database: indexers_test
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: <%= 'jdbc' if RUBY_ENGINE == 'jruby' %>postgresql
3
- database: travis
@@ -1,15 +0,0 @@
1
- default: &default
2
- hosts: localhost
3
- port: 9200
4
-
5
- development:
6
- <<: *default
7
-
8
- test:
9
- <<: *default
10
-
11
- production:
12
- <<: *default
13
-
14
- staging:
15
- <<: *default
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the Rails application.
5
- Rails.application.initialize!
@@ -1,41 +0,0 @@
1
- Rails.application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Do not eager load code on boot.
10
- config.eager_load = false
11
-
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send.
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger.
20
- config.active_support.deprecation = :log
21
-
22
- # Raise an error on page load if there are pending migrations.
23
- config.active_record.migration_error = :page_load
24
-
25
- # Debug mode disables concatenation and preprocessing of assets.
26
- # This option may cause significant delays in view rendering with a large
27
- # number of complex assets.
28
- config.assets.debug = true
29
-
30
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
- # yet still be able to expire them through the digest params.
32
- config.assets.digest = true
33
-
34
- # Adds additional error checking when serving assets at runtime.
35
- # Checks for improperly declared sprockets dependencies.
36
- # Raises helpful error messages.
37
- config.assets.raise_runtime_errors = true
38
-
39
- # Raises error for missing translations
40
- # config.action_view.raise_on_missing_translations = true
41
- end