Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ids with multiple fields and '.' separated JSON nested fields #8

Merged
merged 3 commits into from
Jun 29, 2017

Conversation

sakshambathla
Copy link
Contributor

@sakshambathla sakshambathla commented Jun 28, 2017

To use multiple field ids, concatenate all those field to form an id field ( comma separated after -id ). Also support for nested JSON '.' separated format.

To make a new id field with concatenated fields, the command looks like:

esbulk -index index_name -type type_name -id field1,field2 -w 10 filename.ldj

Also, in case of nested JSON, a field name can be accessed like:

field1.subfield1.ssfield1

Example
esbulk -index index_name -type type_name -id field1,field2.subfield1.ssfield1 -w 10 filename.ldj

To use multiple field ids, concatenate all those field to form an id field ( comma separated after -id ). Also support for nested JSON '.' separated format.
Update index.go to support multi field ids
@sakshambathla sakshambathla changed the title Support for ids with multiple fields and Support for ids with multiple fields and '.' separated JSON nested fields Jun 28, 2017
Copy link
Owner

@miku miku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this PR. Manually tested it and it works fine. There are some small issues with the code to sort out: Code needs to be formatted properly, usused (commented) code should be removed. In general, the logic for accessing nested values from a JSON document might be better implemented as a separate function.

indexing.go Outdated
idstr = t.String()
default:
return fmt.Errorf("cannot convert %T id value to string: %v", id, id)
var currrentId string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be names currentID.

indexing.go Outdated

idstring := options.IDField //A delimiter separates string with all the fields to be used as ID
id:=strings.FieldsFunc(idstring, func (r rune) bool { return r == ',' || r == ' '})
// idtemp := strings.Split(idstring, ",")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code is fine during development, but we should clean this up before the merge.

indexing.go Outdated
for counter:= range id{
currrentId = id[counter]
tokstr := strings.Split(currrentId,".")
if len(tokstr)>1{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

len(tokstr)>1 indicates that you did not run gofmt (or goimports, respectively) on your code. Please do that, even for a PR draft (written in Go). Most editors have support for applying gofmt or goimports automatically on save.

indexing.go Outdated
}

//enigma end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove.

Completed the requested changes
@sakshambathla
Copy link
Contributor Author

Completed the changes. Hope it is fine now.

@miku miku merged commit 08f7e42 into miku:master Jun 29, 2017
@miku
Copy link
Owner

miku commented Jun 29, 2017

Thanks a lot! I created a new release adding these changes: 0.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants