Skip to content

Commit

Permalink
Cherry pick some doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazwazza committed Jul 21, 2023
1 parent 95a82ce commit bec80d1
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 3 deletions.
102 changes: 99 additions & 3 deletions docs/articles/indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,112 @@ Data is easily deleted from the index by the unique identifier you provided in y

This event is part of the base interface [`IIndex`](xref:Examine.IIndex) so it is available to use on any implementation of an Examine index. This can be useful to know when an indexing operation is completed.

Example of how to listen the event:

```csharp
if (!_examineManager.TryGetIndex(indexName, out var index))
{
throw new ArgumentException($"Index '{indexName}' not found");
}

index.IndexOperationComplete += IndexOperationComplete;
```

```csharp
private void IndexOperationComplete(object sender, IndexOperationEventArgs e)
{
// Index operation completed
}
```

#### [IIndex.TransformingIndexValues](xref:Examine.IIndex#Examine_IIndex_TransformingIndexValues)

This event allows for customizing the [`ValueSet`](xref:Examine.ValueSet) before it is passed to the indexer to be indexed. You can use this event to add additional field values or modify existing field values.
This event is part of the base interface [`IIndex`](xref:Examine.IIndex) so it is available to use on any implementation of an Examine index. This event allows for customizing the [`ValueSet`](xref:Examine.ValueSet) before it is passed to the indexer to be indexed. You can use this event to add additional field values or modify existing field values.

Example of how to listen the event:

```csharp
if (!_examineManager.TryGetIndex(indexName, out var index))
{
throw new ArgumentException($"Index '{indexName}' not found");
}

index.TransformingIndexValues += TransformingIndexValues;
```

```csharp
private void TransformingIndexValues(object sender, IndexingItemEventArgs e)
{
// Customize the ValueSet
}
```

#### [IIndex.IndexingError](xref:Examine.IIndex#Examine_IIndex_IndexingError)

This event can be used for reacting to when an error occurs during index. For example, you could add an event handler for this event to facilitate error logging.
This event is part of the base interface [`IIndex`](xref:Examine.IIndex) so it is available to use on any implementation of an Examine index. This event can be used for reacting to when an error occurs during index. For example, you could add an event handler for this event to facilitate error logging.

Example of how to listen the event:

```csharp
if (!_examineManager.TryGetIndex(indexName, out var index))
{
throw new ArgumentException($"Index '{indexName}' not found");
}

index.IndexingError += IndexingError;
```

```csharp
private void IndexingError(object sender, IndexingErrorEventArgs e)
{
// An indexing error occored
}
```

#### [LuceneIndex.DocumentWriting](xref:Examine.Lucene.Providers.LuceneIndex#Examine_Lucene_Providers_LuceneIndex_DocumentWriting)

If using Examine with the default Lucene implementation then the [`IIndex`](xref:Examine.IIndex) implementation will be [`LuceneIndex`](xref:Examine.Lucene.Providers.LuceneIndex). This event provides access to the Lucene [`Document`](https://lucenenet.apache.org/docs/4.8.0-beta00016/api/core/Lucene.Net.Documents.Document.html) object before it gets added to the Lucene Index.
You can use this event to entirely customize how the data is stored in the Lucene index, including adding custom boosting profiles, changing the [`Document`](https://lucenenet.apache.org/docs/4.8.0-beta00016/api/core/Lucene.Net.Documents.Document.html)'s field values or types, etc...
You can use this event to entirely customize how the data is stored in the Lucene index, including adding custom boosting profiles, changing the [`Document`](https://lucenenet.apache.org/docs/4.8.0-beta00016/api/core/Lucene.Net.Documents.Document.html)'s field values or types, etc...
Example of how to listen the event:

```csharp
if (!_examineManager.TryGetIndex(indexName, out var index))
{
throw new ArgumentException($"Index '{indexName}' not found");
}

if (index is LuceneIndex luceneIndex){
luceneIndex.DocumentWriting += DocumentWriting;
}
```

```csharp
private void DocumentWriting(object sender, DocumentWritingEventArgs e)
{
// Customize how the data is stored in the Lucene index
}
```

### [LuceneIndex.IndexCommitted](xref:Examine.Lucene.Providers.LuceneIndex#Examine_Lucene_Providers_LuceneIndex_IndexCommitted)
If using Examine with the default Lucene implementation then the [`IIndex`](xref:Examine.IIndex) implementation will be [`LuceneIndex`](xref:Examine.Lucene.Providers.LuceneIndex). This event is triggered when the index is commited. For example when clearing the index this event is run once when commiting. When rebuilding the event will be run once the rebuild commits a clearing of the index and when it's commiting the rebuilt index.
Example of how to listen the event:

```csharp
if (!_examineManager.TryGetIndex(indexName, out var index))
{
throw new ArgumentException($"Index '{indexName}' not found");
}

if (index is LuceneIndex luceneIndex){
luceneIndex.IndexCommitted += IndexCommited;
}
```

```csharp
private void IndexCommited(object sender, EventArgs e)
{
// Triggered when the index is commited
}
```
3 changes: 3 additions & 0 deletions src/Examine.Lucene/Providers/LuceneIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ internal LuceneIndex(
/// </summary>
public event EventHandler<DocumentWritingEventArgs> DocumentWriting;

/// <summary>
/// Occors when the index is commited
/// </summary>
public event EventHandler IndexCommitted;

#endregion
Expand Down

0 comments on commit bec80d1

Please sign in to comment.