Class NoneDocStore

    • Method Detail

      • indexSettings

        public void indexSettings​(String indexName,
                                  Map<String,​Object> settings)
        Description copied from interface: DocumentStore
        Modify the settings on an index.

        For example, this can be used be used to set elasticSearch refresh_interval on an index before a bulk update.

        
        
           // refresh_interval -1 ... disable refresh while bulk loading
        
           Map<String,Object> settings = new LinkedHashMap<>();
           settings.put("refresh_interval", "-1");
        
           documentStore.indexSettings("product", settings);
        
         
        
        
           // refresh_interval 1s ... restore after bulk loading
        
           Map<String,Object> settings = new LinkedHashMap<>();
           settings.put("refresh_interval", "1s");
        
           documentStore.indexSettings("product", settings);
        
         
        Specified by:
        indexSettings in interface DocumentStore
        Parameters:
        indexName - the name of the index to update settings on
        settings - the settings to set on the index
      • dropIndex

        public void dropIndex​(String newIndex)
        Description copied from interface: DocumentStore
        Drop the index from the document store (similar to DDL drop table).
        
        
           DocumentStore documentStore = database.docStore();
        
           documentStore.dropIndex("product_copy");
        
         
        Specified by:
        dropIndex in interface DocumentStore
      • createIndex

        public void createIndex​(String indexName,
                                String alias)
        Description copied from interface: DocumentStore
        Create an index given a mapping file as a resource in the classPath (similar to DDL create table).
        
        
           DocumentStore documentStore = database.docStore();
        
           // uses product_copy.mapping.json resource
           // ... to define mappings for the index
        
           documentStore.createIndex("product_copy", null);
        
         
        Specified by:
        createIndex in interface DocumentStore
        Parameters:
        indexName - the name of the new index
        alias - the alias of the index
      • indexAll

        public void indexAll​(Class<?> countryClass)
        Description copied from interface: DocumentStore
        Update the document store for all beans of this type.

        This is the same as indexByQuery where the query has no predicates and so fetches all rows.

        Specified by:
        indexAll in interface DocumentStore
      • copyIndex

        public long copyIndex​(Class<?> beanType,
                              String newIndex)
        Description copied from interface: DocumentStore
        Copy the index to a new index.

        This copy process does not use the database but instead will copy from the source index to a destination index.

        
        
          long copyCount = documentStore.copyIndex(Product.class, "product_copy");
        
         
        Specified by:
        copyIndex in interface DocumentStore
        Parameters:
        beanType - The bean type of the source index
        newIndex - The name of the index to copy to
        Returns:
        the number of documents copied to the new index
      • copyIndex

        public long copyIndex​(Class<?> beanType,
                              String newIndex,
                              long epochMillis)
        Description copied from interface: DocumentStore
        Copy entries from an index to a new index but limiting to documents that have been modified since the sinceEpochMillis time.

        To support this the document needs to have a @WhenModified property.

        
        
          long copyCount = documentStore.copyIndex(Product.class, "product_copy", sinceMillis);
        
         
        Specified by:
        copyIndex in interface DocumentStore
        Parameters:
        beanType - The bean type of the source index
        newIndex - The name of the index to copy to
        Returns:
        the number of documents copied to the new index
      • copyIndex

        public long copyIndex​(Query<?> query,
                              String newIndex,
                              int bulkBatchSize)
        Description copied from interface: DocumentStore
        Copy from a source index to a new index taking only the documents matching the given query.
        
        
          // predicates to select the source documents to copy
          Query<Product> query = database.find(Product.class)
            .where()
              .ge("whenModified", new Timestamp(since))
              .ge("name", "A")
              .lt("name", "D")
              .query();
        
          // copy from the source index to "product_copy" index
          long copyCount = documentStore.copyIndex(query, "product_copy", 1000);
        
         
        Specified by:
        copyIndex in interface DocumentStore
        Parameters:
        query - The query to select the source documents to copy
        newIndex - The target index to copy the documents to
        bulkBatchSize - The ElasticSearch bulk batch size, if 0 uses the default.
        Returns:
        The number of documents copied to the new index.
      • indexByQuery

        public <T> void indexByQuery​(Query<T> query)
        Description copied from interface: DocumentStore
        Update the associated document store using the result of the query.

        This will execute the query against the database creating a document for each bean graph and sending this to the document store.

        Note that the select and fetch paths of the query is set for you to match the document structure needed based on @DocStore and @DocStoreEmbedded so what this query requires is the predicates only.

        This query will be executed using findEach so it is safe to use a query that will fetch a lot of beans. The default bulkBatchSize is used.

        Specified by:
        indexByQuery in interface DocumentStore
        Parameters:
        query - The query that selects object to send to the document store.
      • indexByQuery

        public <T> void indexByQuery​(Query<T> query,
                                     int bulkBatchSize)
        Description copied from interface: DocumentStore
        Update the associated document store index using the result of the query additionally specifying a bulkBatchSize to use for sending the messages to ElasticSearch.
        Specified by:
        indexByQuery in interface DocumentStore
        Parameters:
        query - The query that selects object to send to the document store.
        bulkBatchSize - The batch size to use when bulk sending to the document store.
      • find

        public <T> T find​(DocQueryRequest<T> request)
        Description copied from interface: DocumentStore
        Return the bean by fetching it's content from the document store. If the document is not found null is returned.

        Typically this is called indirectly by findOne() on the query.

        
        
         Customer customer =
           database.find(Customer.class)
             .setUseDocStore(true)
             .setId(42)
             .findOne();
        
         
        Specified by:
        find in interface DocumentStore
      • findPagedList

        public <T> PagedList<T> findPagedList​(DocQueryRequest<T> request)
        Description copied from interface: DocumentStore
        Execute the query against the document store returning the paged list.

        The query should have firstRow or maxRows set prior to calling this method.

        Typically this is called indirectly by findPagedList() on the query that has setUseDocStore(true).

        
        
         PagedList<Customer> newCustomers =
          database.find(Customer.class)
            .setUseDocStore(true)
            .where().eq("status, Customer.Status.NEW)
            .setMaxRows(50)
            .findPagedList();
        
         
        Specified by:
        findPagedList in interface DocumentStore
      • findList

        public <T> List<T> findList​(DocQueryRequest<T> request)
        Description copied from interface: DocumentStore
        Execute the find list query. This request is prepared to execute secondary queries.

        Typically this is called indirectly by findList() on the query that has setUseDocStore(true).

        
        
         List<Customer> newCustomers =
          database.find(Customer.class)
            .setUseDocStore(true)
            .where().eq("status, Customer.Status.NEW)
            .findList();
        
         
        Specified by:
        findList in interface DocumentStore
      • findEach

        public <T> void findEach​(DocQueryRequest<T> query,
                                 Consumer<T> consumer)
        Description copied from interface: DocumentStore
        Execute the query against the document store with the expectation of a large set of results that are processed in a scrolling resultSet fashion.

        For example, with the ElasticSearch doc store this uses SCROLL.

        Typically this is called indirectly by findEach() on the query that has setUseDocStore(true).

        
        
          database.find(Order.class)
            .setUseDocStore(true)
            .where()... // perhaps add predicates
            .findEach((Order order) -> {
              // process the bean ...
            });
        
         
        Specified by:
        findEach in interface DocumentStore
      • findEachWhile

        public <T> void findEachWhile​(DocQueryRequest<T> query,
                                      Predicate<T> consumer)
        Description copied from interface: DocumentStore
        Execute the query against the document store with the expectation of a large set of results that are processed in a scrolling resultSet fashion.

        Unlike findEach() this provides the opportunity to stop iterating through the large query.

        For example, with the ElasticSearch doc store this uses SCROLL.

        Typically this is called indirectly by findEachWhile() on the query that has setUseDocStore(true).

        {@code
        
          database.find(Order.class)
            .setUseDocStore(true)
            .where()... // perhaps add predicates
            .findEachWhile(new Predicate() {
        Specified by:
        findEachWhile in interface DocumentStore
      • findEach

        public void findEach​(String indexNameType,
                             String rawQuery,
                             Consumer<RawDoc> consumer)
        Description copied from interface: DocumentStore
        Find each processing raw documents.
        Specified by:
        findEach in interface DocumentStore
        Parameters:
        indexNameType - The full index name and type
        rawQuery - The query to execute
        consumer - Consumer to process each document
      • findEachWhile

        public void findEachWhile​(String indexNameType,
                                  String rawQuery,
                                  Predicate<RawDoc> consumer)
        Description copied from interface: DocumentStore
        Find each processing raw documents stopping when the predicate returns false.
        Specified by:
        findEachWhile in interface DocumentStore
        Parameters:
        indexNameType - The full index name and type
        rawQuery - The query to execute
        consumer - Consumer to process each document until false is returned