# Cast mongodb \_id object to string

**URL:** <https://discuss.elastic.co/t/cast-mongodb-id-object-to-string/114844>\
**Category:** Logstash\
**Created:** [January 10, 2018, 11:23am UTC](https://discuss.elastic.co/t/cast-mongodb-id-object-to-string/114844 "2018-01-10T11:23:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahajan344](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mahajan344](https://discuss.elastic.co/u/mahajan344)\
**Post date:** [January 10, 2018, 11:23am UTC](https://discuss.elastic.co/t/cast-mongodb-id-object-to-string/114844/1 "2018-01-10T11:23:07Z")

</div>

Hi,  
I am working on creating a pipeline to get data from MongoDB to Elasticsearch using Logstash.  
I am using dbschema mongodb jdbc drivers. I am able to connect to database using driver but I am facing issue with `_id` . As in MongoDB its of type `object` So I am getting issue with converter. Here is error I am getting

> Exception when executing JDBC query {:exception=\>#\<Sequel::DatabaseError: Java::OrgLogstash::MissingConverterException: Missing Converter handling for full class name=org.bson.types.ObjectId, simple name=ObjectId\>}

My pipeline is as below :

> input{  
> jdbc{  
> jdbc\_driver\_library =\> "C:/logstash-6.1.0/logstash-6.1.0/bin/driver/mongo/dbschema/mongojdbc1.2.jar"  
> jdbc\_driver\_class =\> "Java::com.dbschema.MongoJdbcDriver"  
> jdbc\_connection\_string =\> "jdbc:mongodb://abc.com:27017/test"  
> jdbc\_user =\> ""  
> statement =\> "db.getCollection('Employee').find({})"  
> codec =\> json  
> }  
> }
> 
> output {  
> elasticsearch {  
> hosts =\> '[http://localhost:9200](http://localhost:9200)'  
> index =\> 'mongodbschema'  
> codec =\> json   
> }  
> stdout { codec =\> rubydebug }  
> }

Is there any way I can convert/cast or do something in filter to change datatype of \_id from object to string

---

<div class="post-metadata">

**Author:** ![mahajan344](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mahajan344](https://discuss.elastic.co/u/mahajan344)\
**Post date:** [January 11, 2018, 5:56am UTC](https://discuss.elastic.co/t/cast-mongodb-id-object-to-string/114844/2 "2018-01-11T05:56:51Z")

</div>

no one faced this problem.. where they want to keep \_id same in Elasticsearch ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 8, 2018, 5:57am UTC](https://discuss.elastic.co/t/cast-mongodb-id-object-to-string/114844/3 "2018-02-08T05:57:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
