Skip to content

Commit

Permalink
chore: Update/Added XML in the project
Browse files Browse the repository at this point in the history
  • Loading branch information
nikcio committed Dec 6, 2022
1 parent a0faff0 commit 50697ed
Show file tree
Hide file tree
Showing 126 changed files with 1,168 additions and 131 deletions.
19 changes: 17 additions & 2 deletions src/Examine.Core/BaseIndexProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public abstract class BaseIndexProvider : IIndex
/// <summary>
/// Constructor for creating an indexer at runtime
/// </summary>
/// <param name="loggerFactory"></param>
/// <param name="name"></param>
/// <param name="fieldDefinitions"></param>
/// <param name="validator"></param>
/// <param name="indexOptions"></param>
protected BaseIndexProvider(ILoggerFactory loggerFactory, string name,
IOptionsMonitor<IndexOptions> indexOptions)
{
Expand All @@ -33,7 +33,15 @@ protected BaseIndexProvider(ILoggerFactory loggerFactory, string name,
_indexOptions = indexOptions.GetNamedOptions(name);
}

/// <summary>
/// Represents a type used to configure the logging system and create instances of
/// <see cref="ILogger"/> from the registered Microsoft.Extensions.Logging.ILoggerProviders.
/// </summary>
protected ILoggerFactory LoggerFactory { get; }

/// <summary>
/// The index name
/// </summary>
public virtual string Name { get; }

/// <summary>
Expand Down Expand Up @@ -73,6 +81,9 @@ protected abstract void PerformDeleteFromIndex(IEnumerable<string> itemIds,

#region IIndex members

/// <summary>
/// The default searcher of the index
/// </summary>
public abstract ISearcher Searcher { get; }

/// <inheritdoc />
Expand Down Expand Up @@ -125,6 +136,10 @@ public void DeleteFromIndex(IEnumerable<string> itemIds)

#region Protected Event callers

/// <summary>
/// Run when a index operation completes
/// </summary>
/// <param name="e"></param>
protected void OnIndexOperationComplete(IndexOperationEventArgs e) => IndexOperationComplete?.Invoke(this, e);

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/Examine.Core/BaseSearchProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ namespace Examine
///</summary>
public abstract class BaseSearchProvider : ISearcher
{
/// <inheritdoc/>
protected BaseSearchProvider(string name)
{
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
Name = name;
}

/// <inheritdoc/>
public string Name { get; }

/// <summary>
/// Searches the index
/// </summary>
/// <param name="searchText"></param>
/// <param name="maxResults"></param>
/// <param name="options"></param>
/// <returns></returns>
public abstract ISearchResults Search(string searchText, QueryOptions options = null);

Expand Down
15 changes: 10 additions & 5 deletions src/Examine.Core/DisposableObjectSlim.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace Examine
{
Expand All @@ -10,11 +10,13 @@ public abstract class DisposableObjectSlim : IDisposable
{
private readonly object _locko = new object();

// gets a value indicating whether this instance is disposed.
// for internal tests only (not thread safe)
/// <summary>
/// Gets a value indicating whether this instance is disposed.
/// for internal tests only (not thread safe)
/// </summary>
protected bool Disposed { get; private set; }

// implements IDisposable
/// <inheritdoc/>
public void Dispose()
{
Dispose(true);
Expand All @@ -32,6 +34,9 @@ private void Dispose(bool disposing)
DisposeResources();
}

/// <summary>
/// Used to dispose resources
/// </summary>
protected abstract void DisposeResources();
}
}
}
17 changes: 14 additions & 3 deletions src/Examine.Core/EmptySearchResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,45 @@

namespace Examine
{
/// <summary>
/// Represents <see cref="ISearchResults"/> with no elements
/// </summary>
public sealed class EmptySearchResults : ISearchResults
{
private EmptySearchResults()
{
}

/// <summary>
/// Gets the static instance
/// </summary>
public static ISearchResults Instance { get; } = new EmptySearchResults();

/// <inheritdoc/>
public IEnumerator<ISearchResult> GetEnumerator()
{
return Enumerable.Empty<ISearchResult>().GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator()
{
return Enumerable.Empty<ISearchResult>().GetEnumerator();
}

/// <inheritdoc/>
public long TotalItemCount => 0;

public IEnumerable<ISearchResult> Skip(int skip)
/// <inheritdoc/>
public IEnumerable<ISearchResult> Skip(int skip)
{
return Enumerable.Empty<ISearchResult>();
}

/// <inheritdoc/>
public IEnumerable<ISearchResult> SkipTake(int skip, int? take = null)
{
return Enumerable.Empty<ISearchResult>();
}
}
}
}
1 change: 1 addition & 0 deletions src/Examine.Core/Examine.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Description>Examine is an abstraction for indexing and search operations with implementations such as Lucene.Net</Description>
<PackageTags>examine search index</PackageTags>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions src/Examine.Core/ExamineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ namespace Examine
/// </summary>
public static class ExamineExtensions
{
/// <summary>
/// Gets named options from an <see cref="IOptionsMonitor{TOptions}"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="optionsMonitor"></param>
/// <param name="name"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public static T GetNamedOptions<T>(this IOptionsMonitor<T> optionsMonitor, string name)
where T : class
{
Expand Down Expand Up @@ -36,6 +44,11 @@ public static IIndex GetIndex(this IExamineManager examineManager, string indexN
throw new InvalidOperationException("No index found with name " + indexName);
}

/// <summary>
/// Deletes a node from the index
/// </summary>
/// <param name="index"></param>
/// <param name="itemId"></param>
public static void DeleteFromIndex(this IIndex index, string itemId)
{
index.DeleteFromIndex(new[] {itemId});
Expand Down
6 changes: 6 additions & 0 deletions src/Examine.Core/ExamineFieldNames.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Examine
{
/// <summary>
/// Constant names for speciffic fields
/// </summary>
public static class ExamineFieldNames
{
/// <summary>
Expand All @@ -22,6 +25,9 @@ public static class ExamineFieldNames
/// </summary>
public const string ItemIdFieldName = "__NodeId";

/// <summary>
/// Used to store the item type for a document
/// </summary>
public const string ItemTypeFieldName = "__NodeTypeAlias";

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Examine.Core/ExamineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Examine
///</summary>
public class ExamineManager : IDisposable, IExamineManager
{
/// <inheritdoc/>
public ExamineManager(IEnumerable<IIndex> indexes, IEnumerable<ISearcher> searchers)
{
foreach(IIndex i in indexes)
Expand Down Expand Up @@ -68,6 +69,8 @@ private ISearcher AddSearcher(ISearcher searcher)
public void Dispose() => Dispose(true);

private bool _disposed = false;

/// <inheritdoc/>
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
Expand Down
5 changes: 5 additions & 0 deletions src/Examine.Core/FieldDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ public FieldDefinition(string name, string type)
/// </summary>
public string Type { get; }

/// <inheritdoc/>
public bool Equals(FieldDefinition other) => string.Equals(Name, other.Name) && string.Equals(Type, other.Type);

/// <inheritdoc/>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is FieldDefinition definition && Equals(definition);
}

/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
Expand All @@ -46,8 +49,10 @@ public override int GetHashCode()
}
}

/// <inheritdoc/>
public static bool operator ==(FieldDefinition left, FieldDefinition right) => left.Equals(right);

/// <inheritdoc/>
public static bool operator !=(FieldDefinition left, FieldDefinition right) => !left.Equals(right);
}
}
23 changes: 23 additions & 0 deletions src/Examine.Core/FieldDefinitionCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@

namespace Examine
{
/// <inheritdoc/>
public class FieldDefinitionCollection : ReadOnlyFieldDefinitionCollection
{
/// <inheritdoc/>
public FieldDefinitionCollection(params FieldDefinition[] definitions) : base(definitions)
{
}

/// <inheritdoc/>
public FieldDefinitionCollection()
{
}

/// <summary>
/// Adds a key/value pair to the System.Collections.Concurrent.ConcurrentDictionary`2
/// by using the specified function if the key does not already exist, or returns
/// the existing value if the key exists.
/// </summary>
/// <param name="fieldName"></param>
/// <param name="add"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException">fieldName or add is null</exception>
/// <exception cref="OverflowException">The dictionary already contains the maximum number of elements (<see cref="int.MaxValue"/>)</exception>
public FieldDefinition GetOrAdd(string fieldName, Func<string, FieldDefinition> add) => Definitions.GetOrAdd(fieldName, add);

/// <summary>
Expand All @@ -20,6 +33,16 @@ public FieldDefinitionCollection()
/// <param name="definition"></param>
public void AddOrUpdate(FieldDefinition definition) => Definitions.AddOrUpdate(definition.Name, definition, (s, factory) => definition);

/// <summary>
/// Attempts to add the specified key and value to the System.Collections.Concurrent.ConcurrentDictionary`2.
/// </summary>
/// <param name="definition"></param>
/// <returns>
/// True if the key/value pair was added to the System.Collections.Concurrent.ConcurrentDictionary`2
/// successfully; false if the key already exists.
/// </returns>
/// <exception cref="ArgumentNullException">definition.Name is null</exception>
/// <exception cref="OverflowException">The dictionary already contains the maximum number of elements (<see cref="int.MaxValue"/>)</exception>
public bool TryAdd(FieldDefinition definition) => Definitions.TryAdd(definition.Name, definition);
}
}
41 changes: 41 additions & 0 deletions src/Examine.Core/FieldDefinitionTypes.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,60 @@
using System;

namespace Examine
{
/// <summary>
/// Contains the names of field definition types
/// </summary>
public static class FieldDefinitionTypes
{
/// <summary>
/// Will be indexed as an integer
/// </summary>
public const string Integer = "int";

/// <summary>
/// Will be indexed as a float
/// </summary>
public const string Float = "float";

/// <summary>
/// Will be indexed as a double
/// </summary>
public const string Double = "double";

/// <summary>
/// Will be indexed as a long
/// </summary>
public const string Long = "long";

/// <summary>
/// Will be indexed DateTime represented as a long
/// </summary>
public const string DateTime = "datetime";

/// <summary>
/// Will be indexed DateTime but with precision only to the year represented as a long
/// </summary>
public const string DateYear = "date.year";

/// <summary>
/// Will be indexed DateTime but with precision only to the month represented as a long
/// </summary>
public const string DateMonth = "date.month";

/// <summary>
/// Will be indexed DateTime but with precision only to the day represented as a long
/// </summary>
public const string DateDay = "date.day";

/// <summary>
/// Will be indexed DateTime but with precision only to the hour represented as a long
/// </summary>
public const string DateHour = "date.hour";

/// <summary>
/// Will be indexed DateTime but with precision only to the minute represented as a long
/// </summary>
public const string DateMinute = "date.minute";

/// <summary>
Expand Down
10 changes: 8 additions & 2 deletions src/Examine.Core/IExamineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Examine
{
/// <summary>
/// Exposes searchers and indexers
/// </summary>
public interface IExamineManager
{
/// <summary>
Expand All @@ -17,10 +20,13 @@ public interface IExamineManager
/// Gets a list of all manually configured search providers
/// </summary>
/// <remarks>
/// This returns only those searchers explicitly registered with <see cref="AddSearcher"/> or config based searchers
/// This returns only those searchers explicitly registered with AddExamineSearcher or config based searchers
/// </remarks>
IEnumerable<ISearcher> RegisteredSearchers { get; }

/// <summary>
/// Disposes the <see cref="IExamineManager"/>
/// </summary>
void Dispose();

/// <summary>
Expand All @@ -32,7 +38,7 @@ public interface IExamineManager
bool TryGetIndex(string indexName, out IIndex index);

/// <summary>
/// Returns a searcher that was registered with <see cref="AddSearcher"/> or via config
/// Returns a searcher that was registered with AddExamineSearcher or via config
/// </summary>
/// <param name="searcherName"></param>
/// <param name="searcher"></param>
Expand Down
Loading

0 comments on commit 50697ed

Please sign in to comment.