我对弹性搜索没有什么新意,我有一个正则表达式,我试图使用Java插入弹性搜索,我一直在尝试使用/作为转义的解析错误角色,它仍然失败。有人可以告诉我我错过了什么吗?
String workflow = "{\"WORKFLOW_ID\":1,\"NAME\":\"Test Workflow\",\"DESCRIPTION\":\"This workflow will be used for testing\",\"COMPANY_ID\":237,\"SOURCE_ID\":1,\"NODES\":[{\"NODE_ID\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf4\",\"POSITION_X\":0,\"POSITION_Y\":120,\"WORKFLOW_ID\":1,\"NAME\":\"Start Node\",\"TYPE\":\"START_NODE\",\"COMPANY_ID\":237,\"CONNECTIONS_TO\":[{\"FROM\":\"a\",\"TO_NODE\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf5\"}],\"VALUES\":{}},{\"NODE_ID\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf5\",\"POSITION_X\":120,\"POSITION_Y\":240,\"WORKFLOW_ID\":1,\"NAME\":\"Route Node1\",\"TYPE\":\"ROUTE_NODE\",\"COMPANY_ID\":237,\"CONNECTIONS_TO\":[{\"FROM\":\"a\",\"TO_NODE\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf6\"},{\"FROM\":\"b\",\"TO_NODE\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf7\"}],\"VALUES\":{\"VARIABLE\":{\"NAME\":\"Subject\",\"TYPE\":\"String\"},\"CONDITIONS\":[{\"ORDER\":0,\"OPERATOR\":\"Regex\",\"VALUE\":\"\\[#([0-9]+)\\]\",\"TO_NODE\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf6\"},{\"ORDER\":1,\"OPERATOR\":\"\",\"VALUE\":null,\"TO_NODE\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf7\"}]}},{\"NODE_ID\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf6\",\"POSITION_X\":120,\"POSITION_Y\":240,\"WORKFLOW_ID\":1,\"NAME\":\"Work action1\",\"TYPE\":\"WORK_ACTION_NODE\",\"COMPANY_ID\":237,\"CONNECTIONS_TO\":[],\"VALUES\":{\"WORK_ACTION_TYPE\":\"Ticket\",\"STATUS\":\"New\"}},{\"NODE_ID\":\"node-220ae87b-f74d-22a5-8661-a1d189983bf7\",\"POSITION_X\":120,\"POSITION_Y\":240,\"WORKFLOW_ID\":1,\"NAME\":\"Work action2\",\"TYPE\":\"WORK_ACTION_NODE\",\"COMPANY_ID\":237,\"CONNECTIONS_TO\":[],\"VALUES\":{\"WORK_ACTION_TYPE\":\"Ticket\",\"STATUS\":\"Open\"}}]}";
这是我用来将数据放入elasticsearch
的代码IndexResponse rescreate = Consumer.client.prepareIndex("workflows", "workflow").setSource(workflow.toString(), XContentType.JSON).get();
这是我的jsonobject,这是我得到的错误,我的正则表达式我尝试传递的值是\ [#([0-9] +)\]。
线程中的异常" main" MapperParsingException [无法解析[NODES.VALUES.CONDITIONS.VALUE]];嵌套:IOException [无法识别的字符转义' [' (代码91) 在[来源:org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@670fc0a6; line:1,column:823]]; 在org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:302) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:485) 在org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:607) at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:407) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:384) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:482) 在org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:500) 在org.elasticsearch.index.mapper.DocumentParser.parseNonDynamicArray(DocumentParser.java:584) 在org.elasticsearch.index.mapper.DocumentParser.parseArray(DocumentParser.java:542) at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:396) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:384) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:482) 在org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:500) at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:394) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:384) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:482) 在org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:500) 在org.elasticsearch.index.mapper.DocumentParser.parseNonDynamicArray(DocumentParser.java:584) 在org.elasticsearch.index.mapper.DocumentParser.parseArray(DocumentParser.java:542) at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:396) at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:384) 在org.elasticsearch.index.mapper.DocumentParser.internalParseDocument(DocumentParser.java:93) 在org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:67) 在org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:261) 在org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:708) at org.elasticsearch.index.shard.IndexShard.applyIndexOperation(IndexShard.java:686) at org.elasticsearch.index.shard.IndexShard.applyIndexOperationOnPrimary(IndexShard.java:667) at org.elasticsearch.action.bulk.TransportShardBulkAction.executeIndexRequestOnPrimary(TransportShardBulkAction.java:548) at org.elasticsearch.action.bulk.TransportShardBulkAction.executeIndexRequest(TransportShardBulkAction.java:140) at org.elasticsearch.action.bulk.TransportShardBulkAction.executeBulkItemRequest(TransportShardBulkAction.java:236) 在org.elasticsearch.action.bulk.TransportShardBulkAction.performOnPrimary(TransportShardBulkAction.java:123) 在org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:110) at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:72) at org.elasticsearch.action.support.replication.TransportReplicationAction $ PrimaryShardReference.perform(TransportReplicationAction.java:1033) at org.elasticsearch.action.support.replication.TransportReplicationAction $ PrimaryShardReference.perform(TransportReplicationAction.java:1011) at org.elasticsearch.action.support.replication.ReplicationOperation.execute(ReplicationOperation.java:104) at org.elasticsearch.action.support.replication.TransportReplicationAction $ AsyncPrimaryAction.onResponse(TransportReplicationAction.java:358) at org.elasticsearch.action.support.replication.TransportReplicationAction $ AsyncPrimaryAction.onResponse(TransportReplicationAction.java:298) at org.elasticsearch.action.support.replication.TransportReplicationAction $ 1.onResponse(TransportReplicationAction.java:974) at org.elasticsearch.action.support.replication.TransportReplicationAction $ 1.onResponse(TransportReplicationAction.java:971) at org.elasticsearch.index.shard.IndexShardOperationPermits.acquire(IndexShardOperationPermits.java:238) at org.elasticsearch.index.shard.IndexShard.acquirePrimaryOperationPermit(IndexShard.java:2211) at org.elasticsearch.action.support.replication.TransportReplicationAction.acquirePrimaryShardReference(TransportReplicationAction.java:983) at org.elasticsearch.action.support.replication.TransportReplicationAction.access $ 500(TransportReplicationAction.java:97) at org.elasticsearch.action.support.replication.TransportReplicationAction $ AsyncPrimaryAction.doRun(TransportReplicationAction.java:319) 在org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at org.elasticsearch.action.support.replication.TransportReplicationAction $ PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:294) at org.elasticsearch.action.support.replication.TransportReplicationAction $ PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:281) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:66) at org.elasticsearch.transport.TransportService $ 7.doRun(TransportService.java:652) at org.elasticsearch.common.util.concurrent.ThreadContext $ ContextPreservingAbstractRunnable.doRun(ThreadContext.java:637) 在org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624) 在java.lang.Thread.run(Thread.java:748)
答案 0 :(得分:0)
适用于可能遇到此问题的任何人。我再次将String格式的json对象转换为String,因此遇到了此问题。
字符串工作流程=“ {\” WORKFLOW_ID \“:1,\” NAME \“:\”测试工作流程\“,\” DESCRIPTION \“:\”此工作流程将用于测试\“,\” COMPANY_ID \“:237,\” SOURCE_ID \“:1,\” NODES \“:[{\” NODE_ID \“:\” node-220ae87b-f74d-22a5-8661-a1d189983bf4 \“,\” POSITION_X \“:0 ,\“ POSITION_Y \”:120,\“ WORKFLOW_ID \”:1,\“ NAME \”:\“起始节点\”,\“ TYPE \”:\“ START_NODE \”,\“ COMPANY_ID \”:237, \“ CONNECTIONS_TO \”:[{\“ FROM \”:\“ a \”,\“ TO_NODE \”:\“ node-220ae87b-f74d-22a5-8661-a1d189983bf5 \”}],\“ VALUES \”: {}},{\“ NODE_ID \”:\“ node-220ae87b-f74d-22a5-8661-a1d189983bf5 \”,\“ POSITION_X \”:120,\“ POSITION_Y \”:240,\“ WORKFLOW_ID \”:1 ,\“ NAME \”:\“ Route Node1 \”,\“ TYPE \”:\“ ROUTE_NODE \”,\“ COMPANY_ID \”:237,\“ CONNECTIONS_TO \”:[{\“ FROM \”:\“ a \“,\” TO_NODE \“:\” node-220ae87b-f74d-22a5-8661-a1d189983bf6 \“},{\” FROM \“:\” b \“,\” TO_NODE \“:\” node- 220ae87b-f74d-22a5-8661-a1d189983bf7 \“}],\” VALUES \“:{\” VARIABLE \“:{\” NAME \“:\” Subject \“,\” TYPE \“:\” String \ “},\” CONDITIONS \“:[{\” ORDER \“:0,\” OPERATOR \“:\” Regex \“,\” VALUE \“:\” \ [#([0-9] +) \] \“,\” TO_NODE \“:\” node-220ae87b-f74d- 22a5-8661-a1d189983bf6 \“},{\” ORDER \“:1,\” OPERATOR \“:\” \“,\” VALUE \“:null,\” TO_NODE \“:\” node-220ae87b-f74d -22a5-8661-a1d189983bf7 \“}]}},{\” NODE_ID \“:\” node-220ae87b-f74d-22a5-8661-a1d189983bf6 \“,\” POSITION_X \“:120,\” POSITION_Y \“: 240,\“ WORKFLOW_ID \”:1,\“ NAME \”:\“工作动作1 \”,\“ TYPE \”:\“ WORK_ACTION_NODE \”,\“ COMPANY_ID \”:237,\“ CONNECTIONS_TO \”:[ ],\“ VALUES \”:{\“ WORK_ACTION_TYPE \”:\“ Ticket \”,\“ STATUS \”:\“ New \”}},{\“ NODE_ID \”:\“ node-220ae87b-f74d- 22a5-8661-a1d189983bf7 \“,\” POSITION_X \“:120,\” POSITION_Y \“:240,\” WORKFLOW_ID \“:1,\” NAME \“:\” Work action2 \“,\” TYPE \“ :\“ WORK_ACTION_NODE \”,\“ COMPANY_ID \”:237,\“ CONNECTIONS_TO \”:[],\“ VALUES \”:{\“ WORK_ACTION_TYPE \”:\“ Ticket \”,\“ STATUS \”:\ “打开\”}}]}“;
IndexResponse rescreate = Consumer.client.prepareIndex(“ workflows”,“ workflow”)。setSource(workflow,XContentType.JSON).get();
仅执行工作流程即可。 stream.toString()会引起问题