Skip to content

Commit

Permalink
Remove IChainStart
Browse files Browse the repository at this point in the history
  • Loading branch information
nzdev committed Dec 7, 2023
1 parent e9bbc8e commit be8426c
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Examine.Core/Search/IFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IFilter
/// </summary>
/// <param name="chain"></param>
/// <returns></returns>
IBooleanFilterOperation ChainFilters(Action<IFilterChainStart> chain);
IBooleanFilterOperation ChainFilters(Action<IFilterChain> chain);

/// <summary>
/// Term must match
Expand Down
12 changes: 11 additions & 1 deletion src/Examine.Core/Search/IFilterChain.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
using System;
using System;

namespace Examine.Search
{
/// <summary>
/// Filter Chaining
/// </summary>
public interface IFilterChain
{
/// <summary>
/// Chain Filter AND
/// </summary>
/// <param name="nextFilter">First Filter in the Chain</param>
/// <returns></returns>
IFilterChain Chain(Func<INestedFilter, INestedBooleanFilterOperation> nextFilter);

/// <summary>
/// Chain Filter
/// </summary>
Expand Down
14 changes: 0 additions & 14 deletions src/Examine.Core/Search/IFilterChainStart.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Examine.Core/Search/INestedFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface INestedFilter
/// </summary>
/// <param name="chain"></param>
/// <returns></returns>
INestedBooleanFilterOperation NestedChainFilters(Action<IFilterChainStart> chain);
INestedBooleanFilterOperation NestedChainFilters(Action<IFilterChain> chain);

/// <summary>
/// Term must match
Expand Down
2 changes: 1 addition & 1 deletion src/Examine.Lucene/Search/FilterChainOp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Examine.Lucene.Search
/// <summary>
/// Filter Chain Operation
/// </summary>
public class FilterChainOp : FilterChainOpBase, IFilterChainStart, IFilterChain
public class FilterChainOp : FilterChainOpBase, IFilterChain
{
private readonly LuceneSearchFilteringOperation _luceneFilter;

Expand Down
2 changes: 1 addition & 1 deletion src/Examine.Lucene/Search/FilterChainOpBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Examine.Lucene.Search
/// <summary>
/// Filter Chain Operation
/// </summary>
public abstract class FilterChainOpBase : IFilterChainStart, IFilterChain
public abstract class FilterChainOpBase : IFilterChain
{
/// <summary>
/// Constructor
Expand Down
4 changes: 2 additions & 2 deletions src/Examine.Lucene/Search/LuceneFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public LuceneFilter(LuceneSearchFilteringOperation search, Occur occurrence)
}

/// <inheritdoc/>
public IBooleanFilterOperation ChainFilters(Action<IFilterChainStart> chain) => _search.ChainFiltersInternal(chain, _occurrence);
public IBooleanFilterOperation ChainFilters(Action<IFilterChain> chain) => _search.ChainFiltersInternal(chain, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation TermFilter(FilterTerm term) => _search.TermFilterInternal(term,_occurrence);
Expand All @@ -47,7 +47,7 @@ public LuceneFilter(LuceneSearchFilteringOperation search, Occur occurrence)
public IBooleanFilterOperation QueryFilter(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp = BooleanOperation.And) => _search.QueryFilterInternal(inner, defaultOp, _occurrence);

/// <inheritdoc/>
INestedBooleanFilterOperation INestedFilter.NestedChainFilters(Action<IFilterChainStart> chain) => _search.NestedChainFiltersInternal(chain, _occurrence);
INestedBooleanFilterOperation INestedFilter.NestedChainFilters(Action<IFilterChain> chain) => _search.NestedChainFiltersInternal(chain, _occurrence);

/// <inheritdoc/>
public INestedBooleanFilterOperation NestedTermFilter(FilterTerm term) => _search.NestedTermFilterInternal(term, _occurrence);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public LuceneFilteringBooleanOperation(LuceneSearchFilteringOperation luceneSear
#region IFilter

/// <inheritdoc/>
public override IBooleanFilterOperation ChainFilters(Action<IFilterChainStart> chain) => _search.ChainFilters(chain);
public override IBooleanFilterOperation ChainFilters(Action<IFilterChain> chain) => _search.ChainFilters(chain);

/// <inheritdoc/>
public override IBooleanFilterOperation TermFilter(FilterTerm term) => _search.TermFilter(term);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal Filter GetNestedFilterOp(
}

/// <inheritdoc/>
public abstract IBooleanFilterOperation ChainFilters(Action<IFilterChainStart> chain);
public abstract IBooleanFilterOperation ChainFilters(Action<IFilterChain> chain);

/// <inheritdoc/>
public abstract IBooleanFilterOperation TermFilter(FilterTerm term);
Expand Down
8 changes: 4 additions & 4 deletions src/Examine.Lucene/Search/LuceneSearchFiltering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public LuceneSearchFilteringOperation(LuceneSearchQuery luceneSearchQuery)
#region IFilter

/// <inheritdoc/>
public override IBooleanFilterOperation ChainFilters(Action<IFilterChainStart> chain)
public override IBooleanFilterOperation ChainFilters(Action<IFilterChain> chain)
{
return ChainFiltersInternal(chain);
}

/// <inheritdoc/>
internal IBooleanFilterOperation ChainFiltersInternal(Action<IFilterChainStart> chain, Occur occurance = Occur.MUST)
internal IBooleanFilterOperation ChainFiltersInternal(Action<IFilterChain> chain, Occur occurance = Occur.MUST)
{
if (chain is null)
{
Expand Down Expand Up @@ -292,7 +292,7 @@ internal IBooleanFilterOperation LongRangeFilterInternal(string field, long? min
#region INestedFilter

/// <inheritdoc/>
protected override INestedBooleanFilterOperation NestedChainFilters(Action<IFilterChainStart> chain) => NestedChainFiltersInternal(chain);
protected override INestedBooleanFilterOperation NestedChainFilters(Action<IFilterChain> chain) => NestedChainFiltersInternal(chain);

/// <inheritdoc/>
protected override INestedBooleanFilterOperation NestedTermFilter(FilterTerm term) => NestedTermFilterInternal(term);
Expand All @@ -313,7 +313,7 @@ internal IBooleanFilterOperation LongRangeFilterInternal(string field, long? min
protected override INestedBooleanFilterOperation NestedQueryFilter(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp) => NestedQueryFilterInternal(inner, defaultOp);

/// <inheritdoc/>
internal INestedBooleanFilterOperation NestedChainFiltersInternal(Action<IFilterChainStart> chain, Occur occurance = Occur.MUST)
internal INestedBooleanFilterOperation NestedChainFiltersInternal(Action<IFilterChain> chain, Occur occurance = Occur.MUST)
{
if (chain is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public LuceneFilteringBooleanOperationBase LuceneFilter(Filter filter, BooleanOp
protected abstract FilterChainOpBase CreateChainOp();

/// <inheritdoc/>
public abstract IBooleanFilterOperation ChainFilters(Action<IFilterChainStart> chain);
public abstract IBooleanFilterOperation ChainFilters(Action<IFilterChain> chain);

/// <inheritdoc/>
public abstract IBooleanFilterOperation TermFilter(FilterTerm term);
Expand All @@ -96,7 +96,7 @@ public LuceneFilteringBooleanOperationBase LuceneFilter(Filter filter, BooleanOp
public abstract IBooleanFilterOperation QueryFilter(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp = BooleanOperation.And);

/// <inheritdoc/>
protected abstract INestedBooleanFilterOperation NestedChainFilters(Action<IFilterChainStart> chain);
protected abstract INestedBooleanFilterOperation NestedChainFilters(Action<IFilterChain> chain);

/// <inheritdoc/>
protected abstract INestedBooleanFilterOperation NestedTermFilter(FilterTerm term);
Expand All @@ -117,7 +117,7 @@ public LuceneFilteringBooleanOperationBase LuceneFilter(Filter filter, BooleanOp
protected abstract INestedBooleanFilterOperation NestedQueryFilter(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp);

/// <inheritdoc/>
INestedBooleanFilterOperation INestedFilter.NestedChainFilters(Action<IFilterChainStart> chain) => NestedChainFilters(chain);
INestedBooleanFilterOperation INestedFilter.NestedChainFilters(Action<IFilterChain> chain) => NestedChainFilters(chain);

/// <inheritdoc/>
INestedBooleanFilterOperation INestedFilter.NestedTermFilter(FilterTerm term) => NestedTermFilter(term);
Expand Down
5 changes: 3 additions & 2 deletions src/Examine.Test/Examine.Lucene/Search/FluentApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5410,11 +5410,12 @@ Action<FieldDefinitionCollection, Analyzer, Directory, Directory, TestIndex, ISe
filter =>
{
filter.ChainFilters(chain =>
chain.Chain(chainedFilter => chainedFilter.NestedFieldValueExists("nodeTypeAlias"))
chain.Chain(ChainOperation.OR, chainedFilter => chainedFilter.NestedFieldValueExists("nodeTypeAlias"))
.Chain(ChainOperation.AND, chainedFilter => chainedFilter.NestedTermPrefix(new FilterTerm("nodeTypeAlias", "CWS_H")))
.Chain(ChainOperation.OR, chainedFilter => chainedFilter.NestedTermFilter(new FilterTerm("nodeName", "my name")))
.Chain(ChainOperation.ANDNOT, chainedFilter => chainedFilter.NestedTermFilter(new FilterTerm("nodeName", "someone elses name")))
.Chain(ChainOperation.XOR, chainedFilter => chainedFilter.NestedTermPrefix(new FilterTerm("nodeName", "my")))
);

});
var boolOp = criteria.All();

Expand Down

0 comments on commit be8426c

Please sign in to comment.