This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree 2 files changed +17
-7
lines changed
2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change 13
13
require 'steno/search'
14
14
15
15
unless ENV [ 'BONSAI_URL' ]
16
- puts "WARNING: The env variable BONSAI_URL is not set, indexing to local Elasticsearch."
17
- puts " You probably want to set BONSAI_URL, check heroku config | fgrep BONSAI"
16
+ puts "WARNING: The env variable BONSAI_URL is not set, indexing to local Elasticsearch."
17
+ puts " You probably want to set BONSAI_URL, check heroku config | fgrep BONSAI"
18
18
end
19
19
20
- bylaws = Slaw ::DocumentCollection . new
21
- bylaws . discover ( '../za-by-laws/by-laws/' , Slaw ::ByLaw )
22
-
23
20
regions = File . open ( '../za-by-laws/regions/regions.json' ) { |f | JSON . load ( f ) }
21
+ searcher = Steno ::Search . searcher
22
+
23
+ if ARGV . empty?
24
+ bylaws = Slaw ::DocumentCollection . new
25
+ bylaws . discover ( '../za-by-laws/by-laws/' , Slaw ::ByLaw )
26
+ remap = true
27
+ else
28
+ bylaws = ARGV . map { |fname | b = Slaw ::ByLaw . new ; b . load ( fname ) ; b }
29
+ remap = false
30
+ end
31
+
32
+ # only do this if we're doing the whole set, since it cleans out the
33
+ # existing index
34
+ searcher . define_mapping! if remap
24
35
25
- Steno :: Search . searcher . reindex! ( bylaws ) do |doc , hash |
36
+ searcher . reindex! ( bylaws ) do |doc , hash |
26
37
hash [ 'region_name' ] = regions [ doc . region ] [ 'name' ]
27
38
end
28
39
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ def create_client(client_params)
32
32
end
33
33
34
34
def reindex! ( docs , &block )
35
- define_mapping!
36
35
index_documents! ( docs , &block )
37
36
end
38
37
You can’t perform that action at this time.
0 commit comments