0

I am new to elastic4s , I am trying to execute this example

client execute {
  search in "places"->"cities" query "london" facets (
    facet terms "landmark" field "type",
    facet range "age" field "year" range (1000->1200) to(1200) from(1400)
  )
}

however it seems that facets are not recognized by the IDE . I might be missing an import or dependency I am using

"com.sksamuel.elastic4s"  %% "elastic4s-core"                     % 2.4.0,
"com.sksamuel.elastic4s"  %% "elastic4s-streams"                  % 2.4.0
Veve
  • 6,643
  • 5
  • 39
  • 58
igx
  • 4,101
  • 11
  • 43
  • 88

1 Answers1

0

Since you're using ES 2.4.x, you should use aggregations instead of facets which have been removed in ES 2.0.

You can see an example here. So in your case you need to change your code to:

client.execute {
  search in "places" / "cities" query "london" aggregations(
    aggregation terms "landmark" field "type",
    aggregation range "age" field "year" range (1000, 1200) to(1200) 
  )
}
Val
  • 207,596
  • 13
  • 358
  • 360
  • Thanks, BTW , is there an option to get all values of specific field ? – igx Jan 09 '17 at 17:22
  • Yes, you can add `size 0` to the terms aggregation, but the performance might suffer if the cardinality of that field is big. Maybe start with 100 and see how it goes. – Val Jan 09 '17 at 17:23