Class BackgroundIndexer

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class BackgroundIndexer
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • Constructor Summary

      Constructors 
      Constructor Description
      BackgroundIndexer​(java.lang.String index, java.lang.String type, Client client)
      Start indexing in the background using a random number of threads.
      BackgroundIndexer​(java.lang.String index, java.lang.String type, Client client, int numOfDocs)
      Start indexing in the background using a random number of threads.
      BackgroundIndexer​(java.lang.String index, java.lang.String type, Client client, int numOfDocs, int writerCount)
      Start indexing in the background using a given number of threads.
      BackgroundIndexer​(java.lang.String index, java.lang.String type, Client client, int numOfDocs, int writerCount, boolean autoStart, java.util.Random random)
      Start indexing in the background using a given number of threads.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assertNoFailures()  
      void close()  
      void continueIndexing()
      Continue indexing after it has paused.
      void continueIndexing​(int numOfDocs)
      Continue indexing after it has paused.
      java.lang.Throwable[] getFailures()  
      java.util.Set<java.lang.String> getIds()
      Returns the ID set of all documents indexed by this indexer run
      void pauseIndexing()
      Pausing indexing by setting current document limit to 0
      void setMaxFieldSize​(int fieldSize)
      the minimum size in code points of a payload field in the indexed documents
      void setMinFieldSize​(int fieldSize)
      the minimum size in code points of a payload field in the indexed documents
      void start()
      Start indexing with no limit to the number of documents
      void start​(int numOfDocs)
      Start indexing
      void stop()
      Stop all background threads *
      long totalIndexedDocs()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BackgroundIndexer

        public BackgroundIndexer​(java.lang.String index,
                                 java.lang.String type,
                                 Client client)
        Start indexing in the background using a random number of threads.
        Parameters:
        index - index name to index into
        type - document type
        client - client to use
      • BackgroundIndexer

        public BackgroundIndexer​(java.lang.String index,
                                 java.lang.String type,
                                 Client client,
                                 int numOfDocs)
        Start indexing in the background using a random number of threads. Indexing will be paused after numOfDocs docs has been indexed.
        Parameters:
        index - index name to index into
        type - document type
        client - client to use
        numOfDocs - number of document to index before pausing. Set to -1 to have no limit.
      • BackgroundIndexer

        public BackgroundIndexer​(java.lang.String index,
                                 java.lang.String type,
                                 Client client,
                                 int numOfDocs,
                                 int writerCount)
        Start indexing in the background using a given number of threads. Indexing will be paused after numOfDocs docs has been indexed.
        Parameters:
        index - index name to index into
        type - document type
        client - client to use
        numOfDocs - number of document to index before pausing. Set to -1 to have no limit.
        writerCount - number of indexing threads to use
      • BackgroundIndexer

        public BackgroundIndexer​(java.lang.String index,
                                 java.lang.String type,
                                 Client client,
                                 int numOfDocs,
                                 int writerCount,
                                 boolean autoStart,
                                 java.util.Random random)
        Start indexing in the background using a given number of threads. Indexing will be paused after numOfDocs docs has been indexed.
        Parameters:
        index - index name to index into
        type - document type
        client - client to use
        numOfDocs - number of document to index before pausing. Set to -1 to have no limit.
        writerCount - number of indexing threads to use
        autoStart - set to true to start indexing as soon as all threads have been created.
        random - random instance to use
    • Method Detail

      • start

        public void start()
        Start indexing with no limit to the number of documents
      • start

        public void start​(int numOfDocs)
        Start indexing
        Parameters:
        numOfDocs - number of document to index before pausing. Set to -1 to have no limit.
      • pauseIndexing

        public void pauseIndexing()
        Pausing indexing by setting current document limit to 0
      • continueIndexing

        public void continueIndexing()
        Continue indexing after it has paused. No new document limit will be set
      • continueIndexing

        public void continueIndexing​(int numOfDocs)
        Continue indexing after it has paused.
        Parameters:
        numOfDocs - number of document to index before pausing. Set to -1 to have no limit.
      • stop

        public void stop()
                  throws java.lang.InterruptedException
        Stop all background threads *
        Throws:
        java.lang.InterruptedException
      • totalIndexedDocs

        public long totalIndexedDocs()
      • getFailures

        public java.lang.Throwable[] getFailures()
      • assertNoFailures

        public void assertNoFailures()
      • setMinFieldSize

        public void setMinFieldSize​(int fieldSize)
        the minimum size in code points of a payload field in the indexed documents
      • setMaxFieldSize

        public void setMaxFieldSize​(int fieldSize)
        the minimum size in code points of a payload field in the indexed documents
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • getIds

        public java.util.Set<java.lang.String> getIds()
        Returns the ID set of all documents indexed by this indexer run