Class ElasticsearchSchema

  • All Implemented Interfaces:
    Schema

    public class ElasticsearchSchema
    extends AbstractSchema
    Schema mapped onto an index of ELASTICSEARCH types.

    Each table in the schema is an ELASTICSEARCH type in that index.

    • Field Detail

      • index

        private final java.lang.String index
      • client

        private final org.elasticsearch.client.RestClient client
      • mapper

        private final com.fasterxml.jackson.databind.ObjectMapper mapper
      • tableMap

        private final java.util.Map<java.lang.String,​Table> tableMap
      • fetchSize

        private final int fetchSize
        Default batch size to be used during scrolling.
    • Constructor Detail

      • ElasticsearchSchema

        public ElasticsearchSchema​(org.elasticsearch.client.RestClient client,
                                   com.fasterxml.jackson.databind.ObjectMapper mapper,
                                   java.lang.String index)
        Allows schema to be instantiated from existing elastic search client. This constructor is used in tests.
        Parameters:
        client - existing client instance
        mapper - mapper for JSON (de)serialization
        index - name of ES index
      • ElasticsearchSchema

        public ElasticsearchSchema​(org.elasticsearch.client.RestClient client,
                                   com.fasterxml.jackson.databind.ObjectMapper mapper,
                                   java.lang.String index,
                                   java.lang.String type)
      • ElasticsearchSchema

        ElasticsearchSchema​(org.elasticsearch.client.RestClient client,
                            com.fasterxml.jackson.databind.ObjectMapper mapper,
                            java.lang.String index,
                            java.lang.String type,
                            int fetchSize)
    • Method Detail

      • createTables

        private java.util.Map<java.lang.String,​Table> createTables​(java.lang.Iterable<java.lang.String> types)
      • listTypesFromElastic

        private java.util.Set<java.lang.String> listTypesFromElastic()
                                                              throws java.io.IOException
        Queries _mapping definition to automatically detect all types for an index
        Returns:
        list of types associated with this index
        Throws:
        java.io.IOException - for any IO related issues
        java.lang.IllegalStateException - if reply is not understood
      • getIndex

        public java.lang.String getIndex()