abc
abc copied to clipboard
Can't make mappings work
I'm using abc version 1.0.0-alpha.0 and Elasticsearch version 7.2.
This is probably not a problem with abc itself but with my understanding of the documentation (or my lack of understanding to be precise).
I'm trying to force a field to be a float instead of a long. My transform file is the following one:
t.Source('source', source, '/movements/')
.Mapping({
"index.movements": {
"properties": {
"movement": {
"properties": {
"amount": { "type": "float" }
}
}
}
}
})
.Transform(otto({'filename': '/home/ubuntu/project-metrics/import-process/transforms/movements.js'}))
.Save('sink', sink, '/.*/');
And my abc transform command:
abc import --bulk_requests=100 --src_type=mongodb --src_uri='mongodb://localhost:27017/database' --transform_file='./movements.js' 'http://localhost:9200/index.movements'
My index is called index.movements and every field is called movement.[field_name]. When I run the command and look in elasticsearch the index.movements index mapping I get this:
{
"mapping": {
"properties": {
"movement": {
"properties": {
"amount": {
"type": "long"
}
}
}
}
}
}
Probably I'm missing something but I can't figure out what. Thank you all in advance.
@alesanmed Can you try the following:
t.Source('source', source, '/movements/')
.Mapping({
"properties": {
"movement": {
"properties": {
"amount": { "type": "float" }
}
}
}
})
.Transform(otto({'filename': '/home/ubuntu/project-metrics/import-process/transforms/movements.js'}))
.Save('sink', sink, '/.*/');
I removed the "index.movements"
line from the Mappings object.
@siddharthlatest Thanks for your answer, just for the records, my transform file now looks like:
t.Source('source', source, '/movements/')
.Mapping({
"properties": {
"movement": {
"properties": {
"amount": { "type": "float" }
}
}
}
})
.Transform(otto({'filename': '/home/ubuntu/project-metrics/import-process/transforms/movements.js'$
.Save('sink', sink, '/.*/');
And the index mapping in elasticsearch:
{
"mapping": {
"properties": {
"movement": {
"properties": {
"amount": {
"type": "long"
}
}
}
}
}
}
I've run the abc import command with log level debug and I extracted a sample document from the importing proccess:
{"movement.__v":0,"movement._id":"5d3...","movement.afterBalance":0,"movement.amount":156, ... }
As you see, I'm prepending the movement.
prefix to every field in the document. Maybe the mapping object in the transform file should be structured in another way? I've also tried:
t.Source('source', source, '/movements/')
.Mapping({
"properties": {
"movement.amount": {
"type": "float"
}
}
})
.Transform(otto({'filename': '/home/ubuntu/project-metrics/import-process/transforms/movements.js'$
.Save('sink', sink, '/.*/');
But I'm having the same result.
Any news on this @siddharthlatest? Thank you very much for your time.
@alesanmed Hi, I am having the same issue, have you figured out a way to make this work?
@zooxmusic Nope... still having the same problem