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


#1

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”
}


#2

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.


#3

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” }

#4

@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


#5

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


#6

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


#7

Hey @ssakthi.t,

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


#8

Thank you @matthew.groves! :slight_smile: