Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 122 additions & 1 deletion docs/indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ Data is easily deleted from the index by the unique identifier you provided in y

<!-- Tabs -->
<div class="container">
<input type="radio" id="tab-link-20" name="docwriting" checked />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc doesn't merge with the feature/docfx branch where the docs now live so this wasn't cherry picked. For doc updates now, They'll have to be done against feature/docfx for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fine the other file will be the one that will come on the docfx site😉

<input type="radio" id="tab-link-30" name="docwriting" checked />
<label for="tab-link-30">V3</label>
<input type="radio" id="tab-link-20" name="docwriting" />
<label for="tab-link-20">V2</label>
<input type="radio" id="tab-link-21" name="docwriting" />
<label for="tab-link-21">V1</label>
Expand Down Expand Up @@ -189,6 +191,125 @@ If using Examine with the default Lucene implementation then the `IIndex` implem

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`'s field values or types, etc...

</section>
<section class="tab-panel" id=tab-30>

### IIndex.IndexOperationComplete

This event is part of the base interface `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

This event is part of the base interface `IIndex` so it is available to use on any implementation of an Examine index. This event allows for customizing the `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

This event is part of the base interface `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

If using Examine with the default Lucene implementation then the `IIndex` implementation will be `LuceneIndex`. This event provides access to the Lucene `Document` 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`'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

If using Examine with the default Lucene implementation then the `IIndex` implementation will be `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
}
```

</section>
</div>
</div>
102 changes: 99 additions & 3 deletions docs/v2/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