Get single vaue from xml by Java

Hi Guys,

I'm new to Elasticsearch and i'm trying to get a single field value with an ID.

LOG.info("Starte Client für Verbindung zum Elasticsearch-Server:");
Client client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));

    GetResponse getResponse = client.prepareGet("database", "xsd", xsdid).execute().actionGet();
    LOG.info("Erhalte Antwort und Ergebnis:");
    Map<String, Object> source = getResponse.getSource();

this gets me the full file back but i just want the field < xmldata>.... </ xmldata> back.
can someone help me?

You can specify which fields you want returned in the request by doing something like:

client.prepareGet("database", "xsd", xsdid).setFields("xmldata")

You can also disable fetching the source by adding setFetchSource(false)

Thanks for the response. So now i'm not csure how to process the xmldata after setting xmldata:
I added your part:

GetResponse getResponse = client.prepareGet("database", "xsd", xsdid).setFetchSource(false).setFields("xmldata").execute().actionGet();

    LOG.info("Erhalte Antwort und Ergebnis:");
    Map<String, Object> source = getResponse.getSource();
  This has to be changed!  Map<String, Object> xmldata =  getResponse.getField("xmldata");

Can you help me?

getResponse.getField("xmldata").getValues() which will return a list of values.. presume this is what you want? I don't know what your documents look like either, so I'm not even sure if you have the "xmldata" field or if its just part of xml that is part of a larger single string field.

I want something like you wrote.
Here is my .xml

> <?xml version="1.0" encoding="UTF-8"?><XmlDoc><FunctionResult result="success"><Message>Processed Correct!</Message></FunctionResult>
> <billing>
> <billing_id>569</billing_id>
> <appid>mft</appid>
> <senderbtid>20041900-107</senderbtid>
> <receiverbtid>20041900-40</receiverbtid>
> <messagetype>M_ORDERS</messagetype>
> <messageid>15336589</messageid>
> <messageprops/>
> <tmid>841</tmid>
> <tmmsgcnt>0</tmmsgcnt>
> <tmmsgtotal>1</tmmsgtotal>
> <procdate>2014-12-01T01:00:20.405</procdate>
> <xmldata>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48WG1sRG9jPg0KPGJpbGxpbmc+DQo8YmlsbGluZ19pZD41Njk8L2JpbGxpbmdfaWQ+DQo8YXBwaWQ+bWZ0PC9hcHBpZD4NCjxzZW5kZXJidGlkPjIwMDQxOTAwLTEwNzwvc2VuZGVyYnRpZD4NCjxyZWNlaXZlcmJ0aWQ+MjAwNDE5MDAtNDA8L3JlY2VpdmVyYnRpZD4NCjxtZXNzYWdldHlwZT5NX09SREVSUzwvbWVzc2FnZXR5cGU+DQo8bWVzc2FnZWlkPjE1MzM2NTg5PC9tZXNzYWdlaWQ+DQo8bWVzc2FnZXByb3BzLz4NCjx0bWlkPjg0MTwvdG1pZD4NCjx0bW1zZ2NudD4wPC90bW1zZ2NudD4NCjx0bW1zZ3RvdGFsPjE8L3RtbXNndG90YWw+DQo8cHJvY2RhdGU+MjAxNC0xMi0wMVQwMTowMDoyMC40MDU8L3Byb2NkYXRlPg0KPC9iaWxsaW5nPg0KPC9YbWxEb2M+DQo=</xmldata></billing>
> </XmlDoc>

And now i just want the xml-part here. I've tried many things but everytime i get the NullPointer - Error
LOG.info("Starte Client für Verbindung zum Elasticsearch-Server:");
Client client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));

        GetResponse getResponse = client.prepareGet("database", "xsd", xsdid).execute().actionGet();
        
        System.out.println("xmldata: " + getResponse.getField("xmldata").getValues());