# Elasticsearch Java Mapping Builder

**URL:** <https://discuss.elastic.co/t/elasticsearch-java-mapping-builder/98216>\
**Category:** Elasticsearch\
**Created:** [August 24, 2017, 11:06am UTC](https://discuss.elastic.co/t/elasticsearch-java-mapping-builder/98216 "2017-08-24T11:06:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![frekele](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frekele/32/13078_2.png) [@frekele](https://discuss.elastic.co/u/frekele)\
**Post date:** [August 24, 2017, 11:06am UTC](https://discuss.elastic.co/t/elasticsearch-java-mapping-builder/98216/1 "2017-08-24T11:06:59Z")

</div>

Hello guys,

I come here to try to contribute to the open source community.

I looked for a way to generate the mappings to use before indexing without typing json files. I wanted something I do not need to worry about the model of my entities used with java rest client.

So I created a project focused on that, using java annotations.  
If anyone wants to download, test or contribute, please feel free to use.

here is the repository in github.  
[https://github.com/frekele/elasticsearch-mapping-builder](https://github.com/frekele/elasticsearch-mapping-builder).

The artifacts is already published in the central maven.

```
<dependency>
   <groupId>org.frekele.elasticsearch</groupId>
   <artifactId>elasticsearch-mapping-builder</artifactId>
   <version>1.0.0</version>
</dependency>

```

Example usage:

```
@Inject
MappingBuilder mappingBuilder;

public String getMapping() {
    return mappingBuilder.build(BookEntity.class).getContentAsString();
}

```

.

```
@ElasticDocument("book")
public class BookEntity {

    @ElasticKeywordField
    private String isbn;

    @ElasticTextField
    @ElasticKeywordField
    @ElasticCompletionField
    private String name;

    @ElasticTextField
    private String description;

    @ElasticDateField
    private OffsetDateTime releaseDate;

    @ElasticBooleanField
    private Boolean active;

    @ElasticBinaryField
    private String imageBlob;

    @ElasticObjectField
    private AuthorEntity author;
    
    .........
}

@ElasticDocument(value = "author")
public class AuthorEntity {

    @ElasticLongField
    private Long id;

    @ElasticTextField
    private String name;

    @ElasticTextField
    @ElasticKeywordField
    private String artisticName;
    
    .........
}

```

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 21, 2017, 11:07am UTC](https://discuss.elastic.co/t/elasticsearch-java-mapping-builder/98216/2 "2017-09-21T11:07:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
