# file: lucene.aus

## class: luceneFileIndex

[123:14] (extern: com.lehman.aussom.AussomLuceneFileIndex) **extends: object** 

A file-system-backed Lucene index. Index data is persisted to disk,
allowing files to be added across multiple sessions.
Example:
idx = new luceneFileIndex();
idx.open("/path/to/index");
idx.addFile("/path/to/doc.txt");
idx.commit();
results = idx.search("keyword");
idx.close();

#### Methods

- **luceneFileIndex** ()

	> Default constructor.



- **open** (`string Path, bool Reset = false`)

	> Opens or creates a Lucene index at the specified directory path. If the directory already contains an index it is opened for appending, unless Reset is true in which case a fresh index is always created.

	- **@p** `Path` is a string with the file system directory path for the index.
	- **@p** `Reset` is an optional bool; when true the index is recreated from scratch (default false).
	- **@r** `This` object.


- **getIndexPath** ()

	> Returns the file system path of this index.

	- **@r** `A` string with the index directory path.


- **addFile** (`string Path`)

	> Adds a file to the index, auto-detecting its type by extension. Files ending in .md are treated as Markdown; all others as plain text.

	- **@p** `Path` is a string with the path to the file to add.
	- **@r** `This` object.


- **addTextFile** (`string Path`)

	> Adds a plain text file to the index.

	- **@p** `Path` is a string with the path to the text file.
	- **@r** `This` object.


- **addMarkdownFile** (`string Path`)

	> Adds a Markdown file to the index. Markdown syntax is stripped before the content is indexed.

	- **@p** `Path` is a string with the path to the Markdown file.
	- **@r** `This` object.


- **commit** ()

	> Commits pending writes and refreshes the internal reader and searcher. This must be called after adding files and before searching.

	- **@r** `This` object.


- **search** (`string Query, int MaxResults = 10`)

	> Searches the index using a keyword query string. Returns a list of result maps, each containing the keys: 'path' (string), 'score' (double), 'snippet' (string), and '_docId' (int). The '_docId' field is the internal cursor used by searchAfter() for pagination. commit() must be called before searching.

	- **@p** `Query` is a string with the Lucene query expression.
	- **@p** `MaxResults` is an optional int with the maximum number of results to return (default 10).
	- **@r** `A` list of result maps with path, score, snippet, and _docId keys.


- **searchAfter** (`map LastResult, string Query, int MaxResults = 10`)

	> Fetches the next page of results after the given cursor result. Pass the last result map from a previous search() or searchAfter() call. The result maps contain a '_docId' field used internally as the page cursor. commit() must not be called between pages as it invalidates the cursor.

	- **@p** `LastResult` is a map (the last result map from the previous page).
	- **@p** `Query` is a string with the Lucene query expression (must match the original search).
	- **@p** `MaxResults` is an optional int with the maximum number of results per page (default 10).
	- **@r** `A` list of result maps with path, score, snippet, and _docId keys, or an empty list if no more results.


- **close** ()

	> Closes the index and releases all resources. The index cannot be used after this call.

	- **@r** `Null.` 


- **getDocCount** ()

	> Returns the number of documents currently in the index, including documents that have been added but not yet committed.

	- **@r** `An` int with the document count.




## class: luceneIndex

[35:14] (extern: com.lehman.aussom.AussomLuceneIndex) **extends: object** 

Base class for Lucene indexes. Provides shared indexing and searching
functionality inherited by luceneFileIndex and luceneMemoryIndex.
Do not instantiate this class directly. Use luceneFileIndex for a
persistent file-system index or luceneMemoryIndex for an in-memory index.

#### Methods

- **luceneIndex** ()

	> Default constructor.



- **addFile** (`string Path`)

	> Adds a file to the index, auto-detecting its type by extension. Files ending in .md are treated as Markdown; all others as plain text.

	- **@p** `Path` is a string with the path to the file to add.
	- **@r** `This` object.


- **addTextFile** (`string Path`)

	> Adds a plain text file to the index.

	- **@p** `Path` is a string with the path to the text file.
	- **@r** `This` object.


- **addMarkdownFile** (`string Path`)

	> Adds a Markdown file to the index. Markdown syntax is stripped before the content is indexed.

	- **@p** `Path` is a string with the path to the Markdown file.
	- **@r** `This` object.


- **commit** ()

	> Commits pending writes and refreshes the internal reader and searcher. This must be called after adding files and before searching.

	- **@r** `This` object.


- **search** (`string Query, int MaxResults = 10`)

	> Searches the index using a keyword query string. Returns a list of result maps, each containing the keys: 'path' (string), 'score' (double), 'snippet' (string), and '_docId' (int). The '_docId' field is the internal cursor used by searchAfter() for pagination. commit() must be called before searching.

	- **@p** `Query` is a string with the Lucene query expression.
	- **@p** `MaxResults` is an optional int with the maximum number of results to return (default 10).
	- **@r** `A` list of result maps with path, score, snippet, and _docId keys.


- **searchAfter** (`map LastResult, string Query, int MaxResults = 10`)

	> Fetches the next page of results after the given cursor result. Pass the last result map from a previous search() or searchAfter() call. The result maps contain a '_docId' field used internally as the page cursor. commit() must not be called between pages as it invalidates the cursor.

	- **@p** `LastResult` is a map (the last result map from the previous page).
	- **@p** `Query` is a string with the Lucene query expression (must match the original search).
	- **@p** `MaxResults` is an optional int with the maximum number of results per page (default 10).
	- **@r** `A` list of result maps with path, score, snippet, and _docId keys, or an empty list if no more results.


- **close** ()

	> Closes the index and releases all resources. The index cannot be used after this call.

	- **@r** `Null.` 


- **getDocCount** ()

	> Returns the number of documents currently in the index, including documents that have been added but not yet committed.

	- **@r** `An` int with the document count.




## class: luceneMemoryIndex

[228:14] (extern: com.lehman.aussom.AussomLuceneMemoryIndex) **extends: object** 

An in-memory Lucene index backed by a ByteBuffersDirectory.
Data is ephemeral and is lost when the index is closed. This is ideal
for fast, temporary indexing and searching within a single session.
Example:
idx = new luceneMemoryIndex();
idx.create();
idx.addFile("/path/to/doc.md");
idx.commit();
results = idx.search("keyword");
idx.close();

#### Methods

- **luceneMemoryIndex** ()

	> Default constructor.



- **create** ()

	> Creates a new in-memory Lucene index. Call this before adding files.

	- **@r** `This` object.


- **addFile** (`string Path`)

	> Adds a file to the index, auto-detecting its type by extension. Files ending in .md are treated as Markdown; all others as plain text.

	- **@p** `Path` is a string with the path to the file to add.
	- **@r** `This` object.


- **addTextFile** (`string Path`)

	> Adds a plain text file to the index.

	- **@p** `Path` is a string with the path to the text file.
	- **@r** `This` object.


- **addMarkdownFile** (`string Path`)

	> Adds a Markdown file to the index. Markdown syntax is stripped before the content is indexed.

	- **@p** `Path` is a string with the path to the Markdown file.
	- **@r** `This` object.


- **commit** ()

	> Commits pending writes and refreshes the internal reader and searcher. This must be called after adding files and before searching.

	- **@r** `This` object.


- **search** (`string Query, int MaxResults = 10`)

	> Searches the index using a keyword query string. Returns a list of result maps, each containing the keys: 'path' (string), 'score' (double), 'snippet' (string), and '_docId' (int). The '_docId' field is the internal cursor used by searchAfter() for pagination. commit() must be called before searching.

	- **@p** `Query` is a string with the Lucene query expression.
	- **@p** `MaxResults` is an optional int with the maximum number of results to return (default 10).
	- **@r** `A` list of result maps with path, score, snippet, and _docId keys.


- **searchAfter** (`map LastResult, string Query, int MaxResults = 10`)

	> Fetches the next page of results after the given cursor result. Pass the last result map from a previous search() or searchAfter() call. The result maps contain a '_docId' field used internally as the page cursor. commit() must not be called between pages as it invalidates the cursor.

	- **@p** `LastResult` is a map (the last result map from the previous page).
	- **@p** `Query` is a string with the Lucene query expression (must match the original search).
	- **@p** `MaxResults` is an optional int with the maximum number of results per page (default 10).
	- **@r** `A` list of result maps with path, score, snippet, and _docId keys, or an empty list if no more results.


- **close** ()

	> Closes the index and releases all resources. The index cannot be used after this call.

	- **@r** `Null.` 


- **getDocCount** ()

	> Returns the number of documents currently in the index, including documents that have been added but not yet committed.

	- **@r** `An` int with the document count.




## class: lucene_module

[22:14] `static` **extends: object** 

Module JAR loader class. Loaded automatically when this module is included.

#### Methods

- **lucene\_module** ()




