# (no subject)

**URL:** <https://discuss.elastic.co/t/no-subject/6826>\
**Category:** Elasticsearch\
**Created:** [February 28, 2012, 8:42am UTC](https://discuss.elastic.co/t/no-subject/6826 "2012-02-28T08:42:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Jajoria](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhishek\_Jajoria](https://discuss.elastic.co/u/Abhishek_Jajoria)\
**Post date:** [February 28, 2012, 8:42am UTC](https://discuss.elastic.co/t/no-subject/6826/1 "2012-02-28T08:42:30Z")

</div>

I have created a nested type field as  
String mapping =  
"{"my":{"properties":{"name":{"type":"nested"}}}}";  
How can I send nested document using java  
XContentBuilder b1 =  
XContentFactory.jsonBuilder().startObject().field("name",);

---

<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:** [February 28, 2012, 10:17am UTC](https://discuss.elastic.co/t/no-subject/6826/2 "2012-02-28T10:17:00Z")

</div>

Heya,

IMHO, if it's your _first time_ with Elasticsearch, I suggest that you test functionnalities with simple documents.

So don't try to play with nested if you just want to play with percolator.

BTW, it can be useful to add subject to your messages. Otherwise, it's difficult to follow the thread.

Then, I suggest that you provide a full curl recreation.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

HTH  
David 😉  
@dadoonet

Le 28 févr. 2012 à 09:42, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a écrit :

> I have created a nested type field as  
> String mapping = "{"my":{"properties":{"name":{"type":"nested"}}}}";  
> How can I send nested document using java  
> XContentBuilder b1 = XContentFactory.jsonBuilder().startObject().field("name",);

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 29, 2012, 7:50pm UTC](https://discuss.elastic.co/t/no-subject/6826/3 "2012-02-29T19:50:47Z")

</div>

Take a look at the test source code for a few examples:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java)

String mapping =  
XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties").startObject("nested1").field("type",  
"nested").endObject().endObject().endObject().endObject().string();

The various startObjects can be confusing, but hopefully you will  
eventually get used to it.

--  
Ivan

On Tue, Feb 28, 2012 at 12:42 AM, jajoria abhishek  
[jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) wrote:

> I have created a nested type field as  
> String mapping =  
> "{"my":{"properties":{"name":{"type":"nested"}}}}";  
> How can I send nested document using java  
> XContentBuilder b1 =  
> XContentFactory.jsonBuilder().startObject().field("name",);

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 29, 2012, 7:52pm UTC](https://discuss.elastic.co/t/no-subject/6826/4 "2012-02-29T19:52:57Z")

</div>

Sorry, the example I added was for the mapping. The source also has  
examples for creating new documents.

On Wed, Feb 29, 2012 at 11:50 AM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> Take a look at the test source code for a few examples:
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java)
> 
> String mapping =  
> XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties").startObject("nested1").field("type",  
> "nested").endObject().endObject().endObject().endObject().string();
> 
> The various startObjects can be confusing, but hopefully you will  
> eventually get used to it.
> 
> --  
> Ivan
> 
> On Tue, Feb 28, 2012 at 12:42 AM, jajoria abhishek  
> [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) wrote:
> 
> > I have created a nested type field as  
> > String mapping =  
> > "{"my":{"properties":{"name":{"type":"nested"}}}}";  
> > How can I send nested document using java  
> > XContentBuilder b1 =  
> > XContentFactory.jsonBuilder().startObject().field("name",);

---

<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:** [July 6, 2017, 3:37am UTC](https://discuss.elastic.co/t/no-subject/6826/5 "2017-07-06T03:37:48Z")

</div>


