Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:33:05+00:00 2026-06-01T23:33:05+00:00

I am working on ElasticSearch. Here I wanted to index an array of nested

  • 0

I am working on ElasticSearch. Here I wanted to index an array of nested type fields through an JAVA api. Could any one give an example on this. I tried few yet they failed.

XContentBuilder xb1 =  XContentFactory.jsonBuilder().startObject(); 
XContentBuilder xb2 =  XContentFactory.jsonBuilder().startObject(); 

xb1.startArray("eventnested"); 
for(int j=0;j<2;j++) { 
    xb2.field("event_type",eventType); 
    xb2.field("event_attribute_instance",eventInstance); 
    xb2.startArray("attributes"); 
    for(int i=0;i<2;i++) { 
        XContentBuilder xb3 = XContentFactory.jsonBuilder().startObject(); 
        xb3.field("event_attribute_name", attrName); 
        xb3.field("event_attribute_value", attrValue); 
        xb2.value(xb3.copiedBytes()); 
    } 
    xb1.value(xb2.copiedBytes()); 
}

After indexing the data, when I read the response the data of the
particular field looked like

“e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JdfQ==”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:33:06+00:00Added an answer on June 1, 2026 at 11:33 pm
    XContentBuilder xb =  XContentFactory.jsonBuilder().startObject();
    
    xb.startArray("eventnested");
    for(int j=0;j<2;j++) {
        xb.startObject();
        xb.field("event_type", eventType);
        xb.field("event_attribute_instance", eventInstance);
        xb.startArray("attributes");
        for(int i=0;i<2;i++) {
            xb.startObject();
            xb.field("event_attribute_name", attrName);
            xb.field("event_attribute_value", attrValue);
            xb.endObject();
        }
        xb.endArray();
        xb.endObject();
    }
    xb.endArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working through trace tables and wanted to check to see if my results where
Working with an api and I need to one of the first responses alongside
Working in Scala-IDE, I have a Java library, in which one of the methods
Working on a project where I need to add points to an array. Here
Working on my first Android app here. I've searched and tried everything I can
Working on writing a custom property Handler for our custom file type in windows
Working through the five minute Xtext tutorial (http://www.eclipse.org/Xtext/documentation/2_1_0/010-xtext-in-5-minutes.php) I get to Generating The Language
Working with the Box2djs plugin here: http://www.crackin.com/dev/mms/physics/ ... and all I'm trying to do
Working with an API where I need to send a value over in an
Working : urlpatterns = patterns('', (r'^$', views.index), (r'^test/$|test/(\d+)/$', views.test_page), (r'^(name)/$', views.index), (r'^(username)/$', views.index), )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.