# Adding a document to elasticsearch database with high level rest api

**URL:** <https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732>\
**Category:** Elasticsearch\
**Created:** [March 11, 2019, 10:56am UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732 "2019-03-11T10:56:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)\
**Post date:** [March 11, 2019, 10:56am UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732/1 "2019-03-11T10:56:10Z")

</div>

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

```

![index](https://us1.discourse-cdn.com/elastic/original/3X/1/5/15e716406bfd155c41e149d040c17aae7225c292.png)

how to add searchSourceJSON under kibanaSavedObjectMeta in this case ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 11, 2019, 11:10am UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732/2 "2019-03-11T11:10:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)\
**Post date:** [March 11, 2019, 11:25am UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732/3 "2019-03-11T11:25:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 11, 2019, 11:47am UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732/4 "2019-03-11T11:47:30Z")

</div>

Could you share a JSON Example?

---

<div class="post-metadata">

**Author:** ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)\
**Post date:** [March 11, 2019, 11:52am UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732/5 "2019-03-11T11:52:32Z")

</div>

{

- "\_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":{}}"}}

}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 11, 2019, 12:08pm UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732/6 "2019-03-11T12:08:00Z")

</div>

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](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) 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:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 8, 2019, 12:08pm UTC](https://discuss.elastic.co/t/adding-a-document-to-elasticsearch-database-with-high-level-rest-api/171732/7 "2019-04-08T12:08:07Z")

</div>

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