Adding a document to elasticsearch database with high level rest api

IndexRequest   request = new IndexRequest  ();
        request.index("indextest")
                .type(type)
                .id(id)            .source("title",v.getTitle(),"visState",v.getVisState(),"kibanaSavedObjectMeta",v.getKibanaSavedObjectMeta().getSearchSourceJSON());

index

how to add searchSourceJSON under kibanaSavedObjectMeta in this case ?

Not sure what is wrong. What result would you like to see?

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with </> icon. Check the preview window.

1 Like

thank you for your response , in fact i want to add a document in my elasticsearch database under the index indextest but i have a property called kibanaSavedObjectMeta , under this property i have another property called searchSourceJSON , i cant figure out how to create the index request to perform this query

Could you share a JSON Example?

1 Like

{

  • "_index": "indextest",
  • "_type": "visualization",
  • "_id": "vis1",
  • "_version": 6,
  • "_score": 1,
  • "_source": {
    • "title": "vis1",
    • "visState": "{"title":"vis1","type":"metric","aggs":[{"id":"metric_1","enabled":true,"type":"min","schema":"metric","params":{"field":"interval_ms"}}]}",
    • "kibanaSavedObjectMeta": {
      • "searchSourceJSON": "{"index":".monitoring-es-6-2019.02.26","query":{}}"}}

}

This is the same thing you already shared, no?

Could you share an example of what you would like it to be?

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.