[英]Elasticsearch Get the values of a field - java API
Hi guys i'm new to elasticsearch and im trying to process the error im currently getting here. 嗨,大家好,我是Elasticsearch的新手,我正尝试处理目前正在此处的错误。 So i just want a single field value for example "xmldata" which i added in a earlier process in the xml file.
所以我只想要一个字段值,例如“ xmldata”,它是在较早的过程中添加到xml文件中的。 The xml is formatted to json an succesfully loaded to my ES-Server, the json file is correct.
xml格式化为json并成功加载到我的ES-Server中,该json文件是正确的。
Here my code: 这是我的代码:
Client client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
// GetResponse response = client.prepareGet("store", "xml",
// xsdid).setFields("xmldata").execute().actionGet();
GetResponse response = client.prepareGet().setIndex("store").setType("xml").setId(xsdid).setFields("xml").execute().actionGet();
String id = (String) response.getSource().get("xml");
i'm getting follow Error: 我正在关注错误:
MapperParsingException[failed to parse];
MapperParsingException [无法解析]; nested: IllegalArgumentException[Malformed content, found extra data after parsing: START_OBJECT];
嵌套:IllegalArgumentException [格式错误的内容,解析后发现额外的数据:START_OBJECT];
My XML looks like this if you need it: 如果需要,我的XML如下所示:
<?xml version="1.0" encoding="UTF-8"?><XmlDoc><FunctionResult result="success"><Message>Processed Correct!</Message></FunctionResult>
<billing>
<billing_id>571</billing_id>
<appid>mft</appid>
<senderbtid>20041900-107</senderbtid>
<receiverbtid>20041900-40</receiverbtid>
<messagetype>M_SLSRPT</messagetype>
<messageid>83815</messageid>
<messageprops/>
<tmid>842</tmid>
<tmmsgcnt>0</tmmsgcnt>
<tmmsgtotal>1</tmmsgtotal>
<procdate>2014-12-02T03:10:15.406</procdate>
<xmldata>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48WG1sRG9jPg0KPGJpbGxpbmc+DQo8YmlsbGluZ19pZD41NzE8L2JpbGxpbmdfaWQ+DQo8YXBwaWQ+bWZ0PC9hcHBpZD4NCjxzZW5kZXJidGlkPjIwMDQxOTAwLTEwNzwvc2VuZGVyYnRpZD4NCjxyZWNlaXZlcmJ0aWQ+MjAwNDE5MDAtNDA8L3JlY2VpdmVyYnRpZD4NCjxtZXNzYWdldHlwZT5NX1NMU1JQVDwvbWVzc2FnZXR5cGU+DQo8bWVzc2FnZWlkPjgzODE1PC9tZXNzYWdlaWQ+DQo8bWVzc2FnZXByb3BzLz4NCjx0bWlkPjg0MjwvdG1pZD4NCjx0bW1zZ2NudD4wPC90bW1zZ2NudD4NCjx0bW1zZ3RvdGFsPjE8L3RtbXNndG90YWw+DQo8cHJvY2RhdGU+MjAxNC0xMi0wMlQwMzoxMDoxNS40MDY8L3Byb2NkYXRlPg0KPC9iaWxsaW5nPg0KPC9YbWxEb2M+DQoNCg==</xmldata></billing>
</XmlDoc>
Please help me! 请帮我! Thanks
谢谢
Client client = TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
GetResponse getResponse = client.prepareGet("database", "xsd", xsdid).execute().actionGet();
Map<String, Object> source = getResponse.getSource();
Like this i'm getting the full json-file back 像这样我得到了完整的json文件
but is there a better way just to get the single one (xmldata)? 但是有没有更好的方法来获取单个(xmldata)呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.