ElasticSearch:Elastic4s仅索引一个字段

时间:2014-09-11 14:05:10

标签: scala elasticsearch elastic4s

我使用ElasticSearch为我的某些模型编制索引,但我发现只有一个字段updated被编入索引;

我首先创建一个像;

这样的映射
client execute {
  create index "places" mappings(
    "shop" as (
      "location" typed GeoPointType,
      "available" typed BooleanType,
      "posted" typed DateType,
      "updated" typed DateType
      )
    )
}

然后,在方法Shop.save中,我执行以下操作;

posted = new Date
updated = new Date
super.save
// index in ES
client execute {
  index into "places" -> "shop" id id fields {
    "location" -> GeoPoint.parseFromLatLon(lat.toString + "," + lon.toString)
    "available" -> true
    "posted" -> posted // field in the object
    "updated" -> updated // field in the object
  }
}

但是,当我去host:9200/places/shop/1时,我只看到:

{
  _index: "places",
  _type: "shop",
  _id: "1",
  _version: 1,
  found: true,
  _source: {
    updated: "2014-09-11T13:52:40.072Z"
  }
}

我做错了什么?

编辑 我使用的是:elastic4s 1.3.2 elasticsearch 1.3.2 和Scala与Play Framework(2.3.4)

1 个答案:

答案 0 :(得分:1)

修正:我生成了一个字段Map,然后就是:

client execute {
  index into "places" -> "shop" id id fields indexMap
}