【问题标题】:Spring data elasticsearch mappingSpring数据elasticsearch映射
【发布时间】:2019-02-02 05:28:50
【问题描述】:

我是使用 Elasticsearch 映射的新手,我创建了我的类 Bordereau,在类中带有注释和一个包含映射的 json 文件。

@Document(indexName = "#{@profilePrefixe}_bordereau", type = "Bordereau")
@Mapping(mappingPath = "/mapping/bordereau-mapping.json")
public class BordereauOe {
    @Id
    private String idBordereau;
    @Field(type= FieldType.Keyword)
    private String numBordereau;
    private String idCreateur;
    private int existe;
    private String dateCreation;
    private Long dateCreationMiliseconde;
    private int nbrDossier;
    private int nbrDossierTraiter;
    private boolean statut;
    private boolean statutSaturatoin;
    private String bordereauFile;
    @Field(type= FieldType.Keyword)
    private String nomClient;
    private int nbrDossierAffecter;
    private String cabinet;
    @Field(type= FieldType.Keyword)
    private String compagnie;
    private int nbrDossierAjoutes;

使用以下映射文件:bordereau-mapping.json

{

  "Bordereau" : {
    "properties" : {
      "accusedFiles" : {
        "type" : "text"
      },
      "bordereauFile" : {
        "type" : "text"
      },
      "cabinet" : {
        "type" : "keyword"
      },
      "compagnie" : {
        "type" : "keyword"
      },
      "dateCreation" : {
        "type" : "date",
        "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
      },
      "dateCreationMiliseconde" : {
        "type" : "long"
      },
      "existe" : {
        "type" : "long"
      },
      "idBordereau" : {
        "type" : "text"
      },
      "idCreateur" : {
        "type" : "text"
      },
      "nbrDossier" : {
        "type" : "long"
      },
      "nbrDossierAffecter" : {
        "type" : "long"
      },
      "nbrDossierAjoutes" : {
        "type" : "long"
      },
      "nbrDossierTraiter" : {
        "type" : "long"
      },
      "nomClient" : {
        "type" : "keyword"
      },
      "numBordereau" : {
        "type" : "keyword"
      },
      "statut" : {
        "type" : "boolean"
      },
      "statutSaturatoin" : {
        "type" : "boolean"
      }
    }
  }

}

那个项目(仍然)运行良好。 但一天后,它抛出了流动的异常

[错误] 2018-08-24 08:31:24.859 [http-nio-8080-exec-4] AcquisitionLogs:56 - ******* 例外:org.springframework.data.mapping.context。 InvalidPersistentPropertyPath:在类 ma.accolade.ged.ms.gestion.acquisition.persistance.oe.BordereauOe 上找不到属性“dateCreation”!您的意思是:dateCreation?
[错误] 2018-08-24 09:35:04.429 [http-nio-8080-exec-9] AcquisitionLogs:56 - ******* 异常:org.springframework.data.mapping.context.InvalidPersistentPropertyPath:否在类 ma.accolade.ged.ms.gestion.acquisition.persistance.oe.PreferenceAffichageOe 上找到属性“idUser”!您的意思是:idUser?
[错误] 2018-08-24 09:36:04.537 [http-nio-8080-exec-6] AcquisitionLogs:56 - ******* 异常:org.springframework.data.mapping.context.InvalidPersistentPropertyPath:否在类 ma.accolade.ged.ms.gestion.acquisition.persistance.oe.DocumentOe 上找到属性“id”!你的意思是:id?

再次提前感谢您的帮助。

【问题讨论】:

    标签: spring elasticsearch spring-data-elasticsearch


    【解决方案1】:

    您在类与映射中的类型定义错误。例如:

    public class BordereauOe {
       private String dateCreation;
    }
    
    and in mapping, you have it defined as Date
    
    "dateCreation" : {
        "type" : "date",
        "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
      }
    

    请检查类和映射之间的所有字段定义并确保它们匹配

    【讨论】:

    猜你喜欢
    • 2017-05-18
    • 2012-07-11
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 2021-04-02
    • 2016-05-19
    • 2021-08-07
    • 1970-01-01
    相关资源
    最近更新 更多