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

Can't make mappings work #167

Open
alesanmed opened this issue Jul 11, 2019 · 5 comments
Open

Can't make mappings work #167

alesanmed opened this issue Jul 11, 2019 · 5 comments

Comments

@alesanmed
Copy link

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.

@siddharthlatest
Copy link
Member

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

@alesanmed
Copy link
Author

alesanmed commented Jul 23, 2019

@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
Copy link
Author

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

@zooxmusic
Copy link

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

@alesanmed
Copy link
Author

@zooxmusic Nope... still having the same problem

@jeet-parekh jeet-parekh removed their assignment Feb 25, 2021
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

No branches or pull requests

4 participants