Elasticsearch Java Mapping Builder

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.

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.

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