Can I have document ID in the documents themselves that we import?

Can I have document ID in the documents themselves that we import? using cbimport.

My json file is this,
{
“id”: “key:siva-1”,
“name”: “Siva”,
“Role”: “Employee”
}

Hi @ssakthi.t,

I don’t quite understand completely. You have a JSON file with JSON objects. These objects contain an “id” field. Do you want to import these documents and use the value in the “id” field as the document key? You absolutely can do that with the –generate-key flag of cbimport.

Thank You @matthew.groves, Yes… We can but I want to insert row without inserting the id. Id is used only for Document ID. Can we do that?

eg:

> ID (DocumentID)      Content Sample 
> key:siva-1           { “name”: “Siva”, “Role”: “Employee” }

@ssakthi.t,

I think I understand now. You have an ID field in your CSV but you don’t want that field to be in the content.

Currently, I don’t think cbimport allows you to select/omit specific fields. But what you can do is run an UNSET N1QL query after the data is imported to remove fields.

Something like: UPDATE mybucket UNSET id

This sounds like a useful feature, so I created a ticket. You might want to keep an eye on it to see if/when progress is made: https://issues.couchbase.com/browse/MB-29468

Yes! Thank you @matthew.groves! :slight_smile:

1 Like

Hey @ssakthi.t,

Looks like this feature has been added: https://issues.couchbase.com/browse/MB-27676 and will be in a future release!

Thank you @matthew.groves! :slight_smile: