abc icon indicating copy to clipboard operation
abc copied to clipboard

Can't make mappings work

Open alesanmed opened this issue 4 years ago • 5 comments

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 avatar Jul 11 '19 15:07 alesanmed

@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 avatar Jul 22 '19 18:07 siddharthlatest

@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.

alesanmed avatar Jul 23 '19 06:07 alesanmed

Any news on this @siddharthlatest? Thank you very much for your time.

alesanmed avatar Jul 31 '19 07:07 alesanmed

@alesanmed Hi, I am having the same issue, have you figured out a way to make this work?

zooxmusic avatar Sep 16 '19 17:09 zooxmusic

@zooxmusic Nope... still having the same problem

alesanmed avatar Sep 25 '19 07:09 alesanmed