Skip to content
ElasticSearch OSEM
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

ElasticSearch OSEM

Object Search Engine Mapper for ElasticSearch


Configure your model with the annotations:

import org.elasticsearch.osem.annotations.Indexable;
import org.elasticsearch.osem.annotations.Searchable;

public class Tweet {
    private String message;
    private String user;
    private Date date;

    public String getMessage() { return message; }

    public void setMessage(String message) { this.message = message; }

    public String getUser() { return user; }

    public void setUser(String user) { this.user = user; }

    public Date getDate() { return date; }

    @Indexable(indexName = "post_date")
    public void setDate(Date date) { = date; }

Configure an ObjectContext instance with your(s) class(es):

import org.elasticsearch.osem.core.ObjectContext;
import org.elasticsearch.osem.core.ObjectContextFactory;


ObjectContext context = ObjectContextFactory.create();

Then you can write objects to the ElasticSearch client:

node.client().prepareIndex("twitter", "tweet", "1").setSource(context.write(tweet)).execute().actionGet();

And read them from search hits:

for (SearchHit hit : searchResponse.getHits()) {
    Tweet t =;

You can view a full example in

Maven Repository


    <id>aloiscochard snapshots</id>
Something went wrong with that request. Please try again.