Example application

There is an example application at ebean-orm-examples/example-elastic which you can investigate / clone etc.


Add ebean-elastic as a dependency to your project. This will automatically register with Ebean as the document store implementation.

<dependency org="io.ebean" name="ebean-elastic" rev="${version}"/>
  @Grab(group='io.ebean', module='ebean-elastic', version='${version}')
libraryDependencies += "io.ebean" % "ebean-elastic" % "${version}"
[io.ebean/ebean-elastic "${version}"]

Bean mapping

On each of the entity beans that we want to have indexed in ElasticSearch add the @DocStore annotation.

Additionally we can add mapping for:

  • @DocCode on properties that should not be analysed
  • @DocSortable on properties that we want both analysed and not analysed
  • @DocEmbedded to include embedded documents (denormalise) for @ManyToOne and @OneToMany properties

Refer to mapping for more details.

Generated index mapping

At this point Ebean is able to generate mapping JSON for each bean type annotated with @DocStore.


ebean.docstore.url is required and specifies the url of the ElasticSearch server to use. Currently the alternative of using the native transport is not supported.

ebean.docstore.active is required to be set to true to indicate the document store integration is active.

If ebean.docstore.generateMapping is set to true Ebean will generate mapping files for each index and these will by default be generated into src/main/resources under elastic-mapping.

When ebean.docstore.dropCreate is set to true when Ebean starts it will drop and re-create all the indexes. Alternatively we can use ebean.docstore.create to create only indexes that have not already been defined.

Refer to Mapping generation for more details.

Review issues on github

Review the issues logged against the ebean-elastic to see what currently is not supported, future enhancements etc.