|
1 | 1 | # couchbase-java-importer |
2 | | -This is a pluggable importer for Couchbase |
| 2 | + |
| 3 | +This is a pluggable importer for Couchbase. So far it supports importing documents from a CSV file, a MongoDB or CouchDB instance. |
| 4 | + |
| 5 | +## How to Build |
| 6 | + |
| 7 | +``` |
| 8 | +$ ./gradlew build |
| 9 | +``` |
| 10 | + |
| 11 | +## How to Use |
| 12 | + |
| 13 | +``` |
| 14 | +$ cd build/distributions/ |
| 15 | +$ unzip couchbase-java-importer.zip |
| 16 | +``` |
| 17 | + |
| 18 | +At this step you need to choose what kind of import you want to do. Configuration samples are available at the root of the repository. Let's pretend you want to import a MongoDB collection called `restaurants` from the database `test` and add a field called `couchbaseType` with the value `restaurant` for every imported documents. Let's also pretend you have a local MongoDB and local Couchbase instance. For that you would need the following configuration |
| 19 | + |
| 20 | +``` |
| 21 | +# Hostnames, comma separated list of Couchbase node IP or hostname |
| 22 | +hostnames: localhost,127.0.0.1 |
| 23 | +# Buket name |
| 24 | +bucket: default |
| 25 | +# Bucket password |
| 26 | +password: |
| 27 | +# Log to write succesfully imported keys |
| 28 | +successLogFilename: succes.out |
| 29 | +# Log to write unsuccesfully imported keys |
| 30 | +errorLogFilename: error.out |
| 31 | +# Default RequestCancelledException delay in milliseconds and maximum number of retries |
| 32 | +requestCancelledExceptionDelay: 31000 |
| 33 | +requestCancelledExceptionRetries: 100 |
| 34 | +# Default TemporaryFailureException delay in milliseconds and maximum number of retries |
| 35 | +temporaryFailureExceptionDelay: 100 |
| 36 | +temporaryFailureExceptionRetries: 100 |
| 37 | +# Default upsert timeout in milliseconds |
| 38 | +importTimeout: 500 |
| 39 | +# Choose between CSV, COUCHDB, MONGODB |
| 40 | +choosenImporter: MONGODB |
| 41 | +mongodb: |
| 42 | + # Give a valid connection string to connect to a MongoDB instance |
| 43 | + connectionString: "mongodb://127.0.0.1:27017/" |
| 44 | + # Name of the MondoDB database to connect to |
| 45 | + dbName: "test" |
| 46 | + # Name of the collection to import |
| 47 | + collectionName: "restaurants" |
| 48 | + # Couchbase does not have collection, we usually use a type field. As there could already be a type field in Mongo, you can specify another fieldName to be used as type |
| 49 | + typeField: "type" |
| 50 | + # type of the documents that will be imported |
| 51 | + type: "restaurant" |
| 52 | +``` |
| 53 | + |
| 54 | +This is the content of the MongoDB sample configuration. To run the import copy the configuration file and run the importer: |
| 55 | + |
| 56 | +``` |
| 57 | +$ cp ../../../application-mongodb.yml.sample application.yml |
| 58 | +$ ./bin/couchbase-java-importer |
| 59 | +``` |
| 60 | + |
| 61 | +Once the import as ran you should have one file called `success.out` that contains the id of every document imported. If something went wrong you should also have a file called `error.out`. |
| 62 | + |
| 63 | +Every configuration samples contains comments that should help you understand the various import options. |
0 commit comments