Skip to content

Commit

Permalink
Filter occurance support
Browse files Browse the repository at this point in the history
  • Loading branch information
nzdev committed Dec 7, 2023
1 parent 84edbd0 commit e9bbc8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
39 changes: 21 additions & 18 deletions src/Examine.Lucene/Search/LuceneFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Examine.Lucene.Search
{
/// <summary>
/// Lucene Filter
/// </summary>
public class LuceneFilter: IFilter, INestedFilter
{
private readonly LuceneSearchFilteringOperation _search;
Expand All @@ -23,57 +26,57 @@ public LuceneFilter(LuceneSearchFilteringOperation search, Occur occurrence)
}

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

/// <inheritdoc/>
public IBooleanFilterOperation TermFilter(FilterTerm term) => _search.TermFilter(term);
public IBooleanFilterOperation TermFilter(FilterTerm term) => _search.TermFilterInternal(term,_occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation TermsFilter(IEnumerable<FilterTerm> terms) => _search.TermsFilter(terms);
public IBooleanFilterOperation TermsFilter(IEnumerable<FilterTerm> terms) => _search.TermsFilterInternal(terms, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation TermPrefixFilter(FilterTerm term) => _search.TermPrefixFilter(term);
public IBooleanFilterOperation TermPrefixFilter(FilterTerm term) => _search.TermPrefixFilterInternal(term, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation FieldValueExistsFilter(string field) => _search.FieldValueExistsFilter(field);
public IBooleanFilterOperation FieldValueExistsFilter(string field) => _search.FieldValueExistsFilterInternal(field, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation FieldValueNotExistsFilter(string field) => _search.FieldValueNotExistsFilter(field);
public IBooleanFilterOperation FieldValueNotExistsFilter(string field) => _search.FieldValueNotExistsFilterInternal(field, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation QueryFilter(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp = BooleanOperation.And) => _search.QueryFilter(inner, defaultOp);
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);
INestedBooleanFilterOperation INestedFilter.NestedChainFilters(Action<IFilterChainStart> chain) => _search.NestedChainFiltersInternal(chain, _occurrence);

/// <inheritdoc/>
public INestedBooleanFilterOperation NestedTermFilter(FilterTerm term) => _search.NestedTermFilterInternal(term);
public INestedBooleanFilterOperation NestedTermFilter(FilterTerm term) => _search.NestedTermFilterInternal(term, _occurrence);

/// <inheritdoc/>
public INestedBooleanFilterOperation NestedTermsFilter(IEnumerable<FilterTerm> terms) => _search.NestedTermsFilterInternal(terms);
public INestedBooleanFilterOperation NestedTermsFilter(IEnumerable<FilterTerm> terms) => _search.NestedTermsFilterInternal(terms, _occurrence);

/// <inheritdoc/>
public INestedBooleanFilterOperation NestedTermPrefix(FilterTerm term) => _search.NestedTermPrefixFilterInternal(term);
public INestedBooleanFilterOperation NestedTermPrefix(FilterTerm term) => _search.NestedTermPrefixFilterInternal(term, _occurrence);

/// <inheritdoc/>
public INestedBooleanFilterOperation NestedFieldValueExists(string field) => _search.NestedFieldValueExistsFilterInternal(field);
public INestedBooleanFilterOperation NestedFieldValueExists(string field) => _search.NestedFieldValueExistsFilterInternal(field, _occurrence);

/// <inheritdoc/>
public INestedBooleanFilterOperation NestedFieldValueNotExists(string field) => _search.NestedFieldValueNotExistsFilterInternal(field);
public INestedBooleanFilterOperation NestedFieldValueNotExists(string field) => _search.NestedFieldValueNotExistsFilterInternal(field, _occurrence);

/// <inheritdoc/>
public INestedBooleanFilterOperation NestedQueryFilter(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp = BooleanOperation.And) => _search.NestedQueryFilterInternal(inner, defaultOp);
public INestedBooleanFilterOperation NestedQueryFilter(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp = BooleanOperation.And) => _search.NestedQueryFilterInternal(inner, defaultOp, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation IntRangeFilter(string field, int? min, int? max, bool minInclusive, bool maxInclusive) => _search.IntRangeFilter(field, min, max, minInclusive, maxInclusive);
public IBooleanFilterOperation IntRangeFilter(string field, int? min, int? max, bool minInclusive, bool maxInclusive) => _search.IntRangeFilterInternal(field, min, max, minInclusive, maxInclusive, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation LongRangeFilter(string field, long? min, long? max, bool minInclusive, bool maxInclusive) => _search.LongRangeFilter(field, min, max, minInclusive, maxInclusive);
public IBooleanFilterOperation LongRangeFilter(string field, long? min, long? max, bool minInclusive, bool maxInclusive) => _search.LongRangeFilterInternal(field, min, max, minInclusive, maxInclusive, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation FloatRangeFilter(string field, float? min, float? max, bool minInclusive, bool maxInclusive) => _search.FloatRangeFilter(field, min, max, minInclusive, maxInclusive);
public IBooleanFilterOperation FloatRangeFilter(string field, float? min, float? max, bool minInclusive, bool maxInclusive) => _search.FloatRangeFilterInternal(field, min, max, minInclusive, maxInclusive, _occurrence);

/// <inheritdoc/>
public IBooleanFilterOperation DoubleRangeFilter(string field, double? min, double? max, bool minInclusive, bool maxInclusive) => _search.DoubleRangeFilter(field, min, max, minInclusive, maxInclusive);
public IBooleanFilterOperation DoubleRangeFilter(string field, double? min, double? max, bool minInclusive, bool maxInclusive) => _search.DoubleRangeFilterInternal(field, min, max, minInclusive, maxInclusive, _occurrence);
}
}
4 changes: 2 additions & 2 deletions src/Examine.Lucene/Search/LuceneSearchFiltering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ internal IBooleanFilterOperation TermFilterInternal(FilterTerm term, Occur occur
}

/// <inheritdoc/>
public override IBooleanFilterOperation TermsFilter(IEnumerable<FilterTerm> terms) => TermsInternal(terms);
public override IBooleanFilterOperation TermsFilter(IEnumerable<FilterTerm> terms) => TermsFilterInternal(terms);

/// <inheritdoc/>
internal IBooleanFilterOperation TermsInternal(IEnumerable<FilterTerm> terms, Occur occurance = Occur.MUST)
internal IBooleanFilterOperation TermsFilterInternal(IEnumerable<FilterTerm> terms, Occur occurance = Occur.MUST)
{
if (terms is null)
{
Expand Down

0 comments on commit e9bbc8e

Please sign in to comment.