Search code examples
scalaelasticsearchelastic4s

ElasticSearch: Elastic4s only indexing one field


I'm using ElasticSearch to index some of my models but I see that only one field updated gets indexed ;

I first create a mapping like;

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

And then, in the method Shop.save, I do the following;

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

But then, when I go to host:9200/places/shop/1, I only see:

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

What am I doing wrong?

Edit I'm using: elastic4s 1.3.2 elasticsearch 1.3.2 and Scala with the Play Framework (2.3.4)


Solution

  • Fixed: I generated a Map of the fields and then just did:

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