Class SearchService
Lucene.Net implementation of ISearchService. Provides full-text search capabilities using Lucene.Net indexes stored on the file system.
Implements
Inherited Members
Namespace: DataWeb.Search.Lucene
Assembly: DataWeb.Search.Lucene.dll
Syntax
public class SearchService : ISearchService
Constructors
SearchService(IEnvironmentService)
Lucene.Net implementation of ISearchService. Provides full-text search capabilities using Lucene.Net indexes stored on the file system.
Declaration
public SearchService(IEnvironmentService environmentService)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironmentService | environmentService |
Properties
Name
Gets the unique name that identifies this search service provider.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
AddOrUpdateEntries(string, IEnumerable<AddEntry>)
Adds or updates entries in the index. Existing entries with the same Id and Culture are removed first.
Declaration
public void AddOrUpdateEntries(string indexName, IEnumerable<AddEntry> entries)
Parameters
| Type | Name | Description |
|---|---|---|
| string | indexName | The name of the index. Must not be null or empty. |
| IEnumerable<AddEntry> | entries | The entries to add or update. Must not be null. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
| ArgumentNullException | Thrown when |
Clear(string)
Clears all entries from the specified index.
Declaration
public void Clear(string indexName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | indexName | The name of the index to clear. Must not be null or empty. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
GetDirectory(string)
Gets the Lucene index directory for the specified index name. Creates the directory if it does not exist.
Declaration
public FSDirectory GetDirectory(string indexName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | indexName | The name of the index. Must not be null or empty. |
Returns
| Type | Description |
|---|---|
| FSDirectory | An Lucene.Net.Store.FSDirectory instance for the index. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
IndexExists(string)
Checks whether a Lucene index exists for the specified index name.
Declaration
public bool IndexExists(string indexName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | indexName | The name of the index. Must not be null or empty. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
RemoveEntries(string, IEnumerable<RemoveEntry>)
Removes entries from the index by Id and Culture.
Declaration
public void RemoveEntries(string indexName, IEnumerable<RemoveEntry> entries)
Parameters
| Type | Name | Description |
|---|---|---|
| string | indexName | The name of the index. Must not be null or empty. |
| IEnumerable<RemoveEntry> | entries | The entries to remove, identified by Id and Culture. Must not be null. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
| ArgumentNullException | Thrown when |
Search(string, SearchFilter, bool)
Searches the index for entries matching the specified filter criteria. Supports both simple wildcard search and advanced Lucene query syntax.
Declaration
public IEnumerable<SearchEntry> Search(string indexName, SearchFilter filter, bool isAdvancedSyntax = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | indexName | The name of the index to search. Must not be null or empty. |
| SearchFilter | filter | The search filter with query and optional criteria. Must not be null. |
| bool | isAdvancedSyntax | If |
Returns
| Type | Description |
|---|---|
| IEnumerable<SearchEntry> | A list of SearchEntry results matching the criteria, or an empty list if no results or index does not exist. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
| ArgumentNullException | Thrown when |