-
Notifications
You must be signed in to change notification settings - Fork 40
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
Conversation
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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, ",") |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indexing.go
Outdated
} | ||
|
||
//enigma end |
There was a problem hiding this comment.
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
Completed the changes. Hope it is fine now. |
Thanks a lot! I created a new release adding these changes: 0.4.3 |
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