Search code examples
elasticsearchcouchbaseelasticsearch-plugin

Couchbase - Elasticsearch - transport. Mapping to types


I have next problem:

I have bucket in couchbase - named cars. I Have index in elasticsearch - named test

I mapped my document. In elasticsearch config i set:

couchbase.typeSelector.defaultDocumentType: 'Test'
couchbase.typeSelector.documentTypeDelimiter: '_'

I started replication from couchbase to elasticsearch. BUT! All my documents going to default type (Test)

I also tried mapping with doc.NameOfProperty - but it doesn't help me :(

I don't have idea why it doesn't work.

My target - set documents from couchbase to elasticsearch by TYPE.

Thank you.


Solution

  • You're missing the document type selector setting. By default the plugin uses the DefaultTypeSelector, which just assigns all documents to the defaultDocumentType, which in your case is "Test".

    To have the plugin assign documents to types by splitting the id according to a delimiter, you need to tell the plugin to use the DelimiterTypeSelector. Add the following line to your elasticsearch.yml to go with what you already have in your config:

    couchbase.typeSelector: org.elasticsearch.transport.couchbase.capi.DelimiterTypeSelector
    

    This way the plugin will assign any documents with ids in the form of "Something_123" to the type "Something" and all other documents to the type "Test".

    Your total couchbase related settings should look something like this:

    couchbase.username: Administrator
    couchbase.password: 12345 # Same as the combination on my luggage
    couchbase.ignoreFailures: true
    couchbase.wrapCounters: true
    couchbase.ignoreDotIndexes: true
    couchbase.typeSelector: org.elasticsearch.transport.couchbase.capi.DelimiterTypeSelector
    couchbase.typeSelector.documentTypeDelimiter: '_'
    couchbase.typeSelector.defaultDocumentType: 'Test'