当前位置: 首页 > 知识库问答 >
问题:

requestPayload]的对象映射试图将字段[requestPayload]解析为对象,但发现了一个具体值

赵雅懿
2023-03-14

我在elasticsearch中存储了一个JSON字符串作为Object,但在下面的requestPayload作为JSON字符串正文的地方得到了异常:[requestPayload]的对象映射试图将字段[requestPayload]解析为Object,但发现了一个具体的值

方法如下:

@Override
public PushBookingNotification save(PushBookingNotification pushBookingNotification) {
    log.debug("Request to save PushBookingNotification : {}", pushBookingNotification);
    PushBookingNotification result = pushBookingNotificationRepository.save(pushBookingNotification);
    pushBookingNotificationSearchRepository.save(result);
    return result;
}

====以下实体=====

公共类PushBookingNotification实现Serializable{

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotNull
@Column(name = "ota_hotel_id", nullable = false)
private Long otaHotelId;

@Column(name = "hotel_name")
private String hotelName;

@NotNull
@Column(name = "reference_no", nullable = false)
private String referenceNo;

@NotNull
@Type(type = "jsonb")
@Column(name = "request_payload", columnDefinition = "jsonb", nullable = false)
@Field(type = FieldType.Object)
private String requestPayload;

//Getter和setter方法

=====错误-日志========

 ERROR 10409 --- [ XNIO-2 task-11] c.atithih.cms.aop.logging.LoggingAspect  : Exception in com.atithih.cms.service.impl.PushBookingNotificationServiceImpl.save() with cause = 'NULL' and exception = 'object mapping for [requestPayload] tried to parse field [requestPayload] as object, but found a concrete value'

org.elasticsearch.index.mapper.MapperParsingException: object mapping for [requestPayload] tried to parse field [requestPayload] as object, but found a concrete value
    at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:350)
    at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:465)
    at org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:591)
    at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:396)
    at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:373)
    at org.elasticsearch.index.mapper.DocumentParser.internalParseDocument(DocumentParser.java:93)
    at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:66)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:277)
    at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:529)
    at org.elasticsearch.index.shard.IndexShard.prepareIndexOnPrimary(IndexShard.java:506)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.prepareIndexOperationOnPrimary(TransportShardBulkAction.java:450)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.executeIndexRequestOnPrimary(TransportShardBulkAction.java:458)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.executeBulkItemRequest(TransportShardBulkAction.java:143)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:113)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:69)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryShardReference.perform(TransportReplicationAction.java:939)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryShardReference.perform(TransportReplicationAction.java:908)
    at org.elasticsearch.action.support.replication.ReplicationOperation.execute(ReplicationOperation.java:113)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncPrimaryAction.onResponse(TransportReplicationAction.java:322)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncPrimaryAction.onResponse(TransportReplicationAction.java:264)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$1.onResponse(TransportReplicationAction.java:888)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$1.onResponse(TransportReplicationAction.java:885)
    at org.elasticsearch.index.shard.IndexShardOperationsLock.acquire(IndexShardOperationsLock.java:147)
    at org.elasticsearch.index.shard.IndexShard.acquirePrimaryOperationLock(IndexShard.java:1657)
    at org.elasticsearch.action.support.replication.TransportReplicationAction.acquirePrimaryShardReference(TransportReplicationAction.java:897)
    at org.elasticsearch.action.support.replication.TransportReplicationAction.access$400(TransportReplicationAction.java:93)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncPrimaryAction.doRun(TransportReplicationAction.java:281)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:260)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:252)
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69)
    at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

共有1个答案

华福
2023-03-14

为什么在字段RequestPayload上有这个注释@field(type=fieldType.Object)。也许试着移除它,它可能会起作用。

 类似资料:
  • 问题内容: 我正在尝试为以下文档工作进行映射: 我将排除buildInfo和其他一些字段,因此我相应地创建了一个映射: 这给了我一个MapperParsingException。被认为是JSON对象的每一个都将包含的列表,和。如您所见,还包含json对象。 (是的清单,每个都包含,和。还包含一些字段和一个名为。的对象。尽管我在映射中将所有这些都映射了出来,但是我没有明确地将每个字段的值移交给最后一

  • 我有一个对象,我正试图映射到。现在这个有一个名为的枚举,其中包含一些值。我想使用将它们映射到中的其他枚举值。以下是我到目前为止的代码: 当我尝试编译它时,我得到了错误:

  • 我需要将多个dto映射到实体。几乎所有的dto都有一个指向另一个dto的引用,我不知道在映射dto时如何传递引用。 以下是该地址的一个业务实现: 这是地图绘制者 所有实现者都从同一个dto读取,然后将它们映射到dto和entites。 以下是针对客户实施的建议: 以及我希望引用映射地址实体的映射(我的客户实体有一个地址类型字段)。 非常感谢你。

  • 假设我有这样的映射: 现在,我需要将子列表映射到子列表,但它们都有相同的父对象。我希望这样做: 但不管用,有机会做吗?

  • 问题内容: 尝试使用gson将以下json字符串解析为java对象 我有我的java类 转换后,我得到的提示对象为空。 有人可以纠正我吗 问题答案: 试试这个JSON: 使用此Java类: 奇迹般有效 输出:

  • 我有Object1和Object2。现在,我想映射对象3,属性来自1 比方说,我有两个目标: 现在,有了这些,我想把它映射进去 哪里,first_name 现在,我的问题是,怎么做? 然而,目前,我正在这样做 但是,在这里,我必须在addressToView()中手动编写映射。 因此,有没有办法避免这种情况? 或者,处理此类情况的首选方式是什么?