Skip to content

Commit

Permalink
Merge pull request #21 from suxiaobai/master
Browse files Browse the repository at this point in the history
fix build and migrate doc to add '_routing'
  • Loading branch information
medcl authored Mar 4, 2019
2 parents 63a294a + 25f95d5 commit 8eb8ac6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
language: go
os:
- osx

env:
global:
- TRAVIS_GO_VERSION="1.10"
go:
- 1.10

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ https://github.com/medcl/elasticsearch-dump/releases


## Compile:

if download version is not fill you environment,you may try to compile it yourself. `go` required.

`make build`

* go version >= 1.7

## Options

Expand Down
5 changes: 5 additions & 0 deletions bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func (c *Migrator) NewBulkWorker(docCount *int, pb *pb.ProgressBar, wg *sync.Wai
source: docI["_source"].(map[string]interface{}),
Id: docI["_id"].(string),
}

// add doc "_routing"
if _, ok := docI["_routing"]; ok {
doc.Routing = docI["_routing"].(string)
}

// if channel is closed flush and gtfo
if !open {
Expand Down
7 changes: 4 additions & 3 deletions domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Document struct {
Type string `json:"_type"`
Id string `json:"_id"`
source map[string]interface{} `json:"_source"`
Routing string `json:"_routing"`
}

type Scroll struct {
Expand Down Expand Up @@ -88,10 +89,10 @@ type Config struct {
BulkSizeInMB int `short:"b" long:"bulk_size" description:"bulk size in MB" default:"5"`
ScrollTime string `short:"t" long:"time" description:"scroll time" default:"1m"`
ScrollSliceSize int `long:"sliced_scroll_size" description:"size of sliced scroll, to make it work, the size should be > 1" default:"1"`
RecreateIndex bool `short:"f" long:"force" description:"delete destination index before copying" default:"false"`
RecreateIndex bool `short:"f" long:"force" description:"delete destination index before copying"`
CopyAllIndexes bool `short:"a" long:"all" description:"copy indexes starting with . and _"`
CopyIndexSettings bool `long:"copy_settings" description:"copy index settings from source" default:"false"`
CopyIndexMappings bool `long:"copy_mappings" description:"copy index mappings from source" default:"false"`
CopyIndexSettings bool `long:"copy_settings" description:"copy index settings from source"`
CopyIndexMappings bool `long:"copy_mappings" description:"copy index mappings from source"`
ShardsCount int `long:"shards" description:"set a number of shards on newly created indexes"`
SourceIndexNames string `short:"x" long:"src_indexes" description:"indexes name to copy,support regex and comma separated list" default:"_all"`
TargetIndexName string `short:"y" long:"dest_index" description:"indexes name to save, allow only one indexname, original indexname will be used if not specified" default:""`
Expand Down
4 changes: 2 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Get(url string,auth *Auth,proxy string) (*http.Response, string, []error) {
request.SetBasicAuth(auth.User,auth.Pass)
}

request.Header["Content-Type"]= "application/json"
request.Header.Set("Content-Type", "application/json")

if(len(proxy)>0){
request.Proxy(proxy)
Expand All @@ -50,7 +50,7 @@ func Post(url string,auth *Auth, body string,proxy string)(*http.Response, strin
request.SetBasicAuth(auth.User,auth.Pass)
}

request.Header["Content-Type"]= "application/json"
request.Header.Set("Content-Type", "application/json")

if(len(proxy)>0){
request.Proxy(proxy)
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func main() {
_, err := goflags.Parse(c)
if err != nil {
log.Error(err)
// if error, print it
fmt.Print(err)
return
}

Expand Down

0 comments on commit 8eb8ac6

Please sign in to comment.