@Transient@Field带批注的字段未显示在弹性服务器上的索引中



使用休眠搜索 5.9 和弹性服务器 5.6.10。

我正在尝试将 3 个字段中的数据保存到带有注释@Transient单个字段中。但是,尽管字段显示在索引结构中,但当我使用 curl/chrome 查询索引时,也不会显示相同的字段。它不存在于索引中,数据以这种方式丢失。

法典:

@Transient
                @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
                private String fullAgentNumber = "";
                public String getFullAgentNumber() {
                                return this.fillr1 +""+ this.rpt0agt0nr +""+ this.fillr2;
                }

索引结果:

{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "master_policy_index",
        "_type" : "com.csc.pt.svc.data.to.Basclt1400TO",
        "_id" : "00,0004087,WCV,05,00",
        "_score" : 1.0,
        "_source" : {
          "id" : "00,0004087,WCV,05,00",
          "location" : "00",
         "symbol" : "WCV",
          "module" : "00",
          "policy0num" : "0004087",
          "master0co" : "05",
          "cltseqnum" : 277,
          "addrseqnum" : "1",
          "policies" : [
            {
              "location" : "00",
              "symbol" : "WCV",
              "module" : "00",
              "policy0num" : "0004087",
              "master0co" : "05",
              "trans0stat" : "P",
              "id02" : "02",
              "eff0yr" : "118",
              "eff0mo" : "03",
              "eff0da" : "15",
              "exp0yr" : "119",
              "exp0mo" : "03",
              "exp0da" : "15",
              "fillr1" : "000",
              "rpt0agt0nr" : "0",
              "fillr2" : "358",
              "tot0ag0prm" : "0.00",
              "line0bus" : "WCV",
              "issue0code" : "N",
              "type0act" : "NB"
            }
          ]
        }
      }
    ]
  }
}

期望瞬态字段包含创建索引时尝试保留的数据。另外,我相信一旦字段具有数据,如果其引用的字段更新,它也会更新吗?

您在显然始终为空的对象字段上添加了@Field注释。因此,休眠搜索将始终索引空字符串。

瞬态方法不需要对象字段。试试这个:

@Transient
                @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
                public String getFullAgentNumber() {
                                return this.fillr1 +""+ this.rpt0agt0nr +""+ this.fillr2;
                }

最新更新