0

I am trying to create using the Java API a new river between MongoDB and ElasticSearch. Using the REST API is pretty easy making a PUT request with the following JSON

{
  "type": "mongodb",
  "mongodb": {
    "servers": [
      { "host": "127.0.0.1", "port": 27017 }
    ],
    "options": { "secondary_read_preference": true },
    "db": "test",
    "collection": "collectionTest"
  },
  "index": {
    "name": "testIndex",
    "type": "default"
  }
}

But I am having several problems with the Java API. I am trying to use the CreateIndexRequestBuilder class but I don't know how to specify the params.

Are they custom params? What about source? I'm pretty lost...

Thank you in advance!

1 Answer 1

4

You need to add a document with id _meta to the _river index. The type is the name that you want to give to your index. The document to send is a json containing the configuration needed for your river. Beyond the custom configuration that depends on the river, the json document needs to contain the property type, which contains the name used within the river itself to register the RiverModule. For the mongodb river it's mongodb. The json that you posted is exactly the source that you have to send.

Here is the code that you need:

client.index(Requests.indexRequest("_river").type("my_river").id("_meta").source(source)).actionGet();
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you!! I want to emphasize that my_river is the name of the index to create
Didn't realize that, I guess that's the case when you don't specify the index object within the configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.