Spring数据弹性搜索映射

时间:2018-08-27 16:17:37

标签: spring elasticsearch spring-data-elasticsearch

我是使用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”!你是说:身份证吗?

再次感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

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

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"
  }

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