org.apache.lucene.luke.models.tools

## Class IndexToolsImpl

- java.lang.Object
- - org.apache.lucene.luke.models.LukeModel
  - - org.apache.lucene.luke.models.tools.IndexToolsImpl

- All Implemented Interfaces:
    IndexTools

      public final class IndexToolsImpl
      extends LukeModel
      implements IndexTools

  Default implementation of `IndexTools`

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.luke.models.LukeModel

      `commit, dir, liveDocs, reader`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IndexToolsImpl(Directory dir, boolean useCompound, boolean keepAllCommits)` Constructs an IndexToolsImpl that holds given `Directory`.
    `IndexToolsImpl(IndexReader reader, boolean useCompound, boolean keepAllCommits)` Constructs an IndexToolsImpl that holds given `IndexReader`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDocument(Document doc, Analyzer analyzer)` Add new document to this index.
    `CheckIndex.Status` | `checkIndex(PrintStream ps)` Check the current index status.
    `void` | `createNewIndex()` Create a new index.
    `void` | `createNewIndex(String dataDir)` Create a new index with sample documents.
    `void` | `deleteDocuments(Query query)` Delete documents from this index by the specified query.
    `String` | `exportTerms(String destDir, String field, String delimiter)` Export terms from given field into a new file on the destination directory
    `void` | `optimize(boolean expunge, int maxNumSegments, PrintStream ps)` Execute force merges.
    `void` | `repairIndex(CheckIndex.Status st, PrintStream ps)` Try to repair the corrupted index using previously returned index status.

    - ### Methods inherited from class org.apache.lucene.luke.models.LukeModel

      `getFieldNames`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IndexToolsImpl

          public IndexToolsImpl(Directory dir,
                                boolean useCompound,
                                boolean keepAllCommits)

      Constructs an IndexToolsImpl that holds given `Directory`.
      Parameters:
        `dir` - - the index directory
        `useCompound` - - if true, compound file format is used
        `keepAllCommits` - - if true, all commit points are reserved

    - #### IndexToolsImpl

          public IndexToolsImpl(IndexReader reader,
                                boolean useCompound,
                                boolean keepAllCommits)

      Constructs an IndexToolsImpl that holds given `IndexReader`.
      Parameters:
        `reader` - - the index reader
        `useCompound` - - if true, compound file format is used
        `keepAllCommits` - - if true, all commit points are reserved

  - ### Method Detail

    - #### optimize

          public void optimize(boolean expunge,
                               int maxNumSegments,
                               PrintStream ps)

      Description copied from interface: `IndexTools`
      Execute force merges.

      Merges are executed until there are maxNumSegments segments.
      When expunge is true, maxNumSegments parameter is ignored.

      Specified by:
        `optimize` in interface `IndexTools`
      Parameters:
        `expunge` - - if true, only segments having deleted documents are merged
        `maxNumSegments` - - max number of segments
        `ps` - - information stream

    - #### checkIndex

          public CheckIndex.Status checkIndex(PrintStream ps)

      Description copied from interface: `IndexTools`
      Check the current index status.
      Specified by:
        `checkIndex` in interface `IndexTools`
      Parameters:
        `ps` - information stream
      Returns:
        index status

    - #### repairIndex

          public void repairIndex(CheckIndex.Status st,
                                  PrintStream ps)

      Description copied from interface: `IndexTools`
      Try to repair the corrupted index using previously returned index status.

      This method must be called with the return value from `IndexTools.checkIndex(PrintStream)`.

      Specified by:
        `repairIndex` in interface `IndexTools`
      Parameters:
        `st` - - index status
        `ps` - - information stream

    - #### addDocument

          public void addDocument(Document doc,
                                  Analyzer analyzer)

      Description copied from interface: `IndexTools`
      Add new document to this index.
      Specified by:
        `addDocument` in interface `IndexTools`
      Parameters:
        `doc` - - document to be added
        `analyzer` - - analyzer for parsing to document

    - #### deleteDocuments

          public void deleteDocuments(Query query)

      Description copied from interface: `IndexTools`
      Delete documents from this index by the specified query.
      Specified by:
        `deleteDocuments` in interface `IndexTools`
      Parameters:
        `query` - - query for deleting

    - #### createNewIndex

          public void createNewIndex()

      Description copied from interface: `IndexTools`
      Create a new index.
      Specified by:
        `createNewIndex` in interface `IndexTools`

    - #### createNewIndex

          public void createNewIndex(String dataDir)

      Description copied from interface: `IndexTools`
      Create a new index with sample documents.
      Specified by:
        `createNewIndex` in interface `IndexTools`
      Parameters:
        `dataDir` - - the directory path which contains sample documents (20 Newsgroups).

    - #### exportTerms

          public String exportTerms(String destDir,
                                    String field,
                                    String delimiter)

      Description copied from interface: `IndexTools`
      Export terms from given field into a new file on the destination directory
      Specified by:
        `exportTerms` in interface `IndexTools`
      Parameters:
        `destDir` - - destination directory
        `field` - - field name
        `delimiter` - - delimiter to separate terms and their frequency
      Returns:
        The file containing the export

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.