aboutsummaryrefslogtreecommitdiff
blob: a36f0ca2396a7fcd55dffe41c3d41cd50e22ecd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Kkuleomi::Store

  def self.create_index(force = false)
		repositories = [
			CategoryRepository,
			PackageRepository,
			VersionRepository,
			ChangeRepository,
			UseflagRepository,
		]

    base_settings = {
        analysis: {
            filter: {
                autocomplete_filter: {
                    type: 'edge_ngram',
                    min_gram: 1,
                    max_gram: 20,
                }
            },
            analyzer: {
                autocomplete: {
                    type: 'custom',
                    tokenizer: 'standard',
                    filter: %w(lowercase autocomplete_filter)
                }
            }
        },
				index: { mapper: { dynamic: false } },
				mapping: { total_fields: { limit: 50000 } }
    }

		settings = JSON.parse('{ "mapping": { "total_fields": { "limit": 50000 } } }')

		# In ES 1.5, we could use 1 mega-index. But in ES6, each model needs its own.
		repositories.each { |repository|
						repository.instance.create_index!(force: true, settings: settings)
		}
  end
end