-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add wildcard and prefix interval rules #4060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9e6a00a
Add wildcard and prefix interval rules
russcam f3e482f
Update src/Nest/QueryDsl/FullText/Intervals/IntervalsPrefix.cs
russcam 50fd530
Update src/Nest/QueryDsl/FullText/Intervals/IntervalsWildcard.cs
russcam 6c733e6
Update src/Nest/QueryDsl/FullText/Intervals/IntervalsWildcard.cs
russcam 1cd68a6
Update src/Nest/QueryDsl/FullText/Intervals/IntervalsPrefix.cs
russcam f790884
Remove attributes from IntervalsPrefix
russcam 97d97e5
Merge branch 'feature/wildcard-intervals' of github.com:elastic/elast…
russcam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Nest | ||
{ | ||
/// <summary> | ||
/// Matches terms that start with a specified set of characters. This prefix can expand to match at most 128 terms. | ||
/// If the prefix matches more than 128 terms, Elasticsearch returns an error. | ||
/// You can use the index-prefixes option in the field mapping to avoid this limit. | ||
/// <para /> | ||
/// Available in Elasticsearch 7.3.0+ | ||
/// </summary> | ||
[ReadAs(typeof(IntervalsPrefix))] | ||
public interface IIntervalsPrefix : IIntervalsNoFilter | ||
{ | ||
/// <summary> | ||
/// Analyzer used to normalize the prefix. Defaults to the top-level field's analyzer. | ||
/// </summary> | ||
[DataMember(Name = "analyzer")] | ||
string Analyzer { get; set; } | ||
|
||
/// <summary> | ||
/// Beginning characters of terms you wish to find in the top-level field | ||
/// </summary> | ||
[DataMember(Name = "prefix")] | ||
string Prefix { get; set; } | ||
|
||
/// <summary> | ||
/// If specified, then match intervals from this field rather than the top-level field. | ||
/// The prefix is normalized using the search analyzer from this field, unless a separate analyzer is specified. | ||
/// </summary> | ||
[DataMember(Name = "use_field")] | ||
Field UseField { get; set; } | ||
} | ||
|
||
/// <inheritdoc cref="IIntervalsPrefix" /> | ||
public class IntervalsPrefix : IntervalsNoFilterBase, IIntervalsPrefix | ||
{ | ||
/// <inheritdoc /> | ||
public string Analyzer { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public string Prefix { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public Field UseField { get; set; } | ||
|
||
internal override void WrapInContainer(IIntervalsContainer container) => container.Prefix = this; | ||
} | ||
|
||
/// <inheritdoc cref="IIntervalsPrefix" /> | ||
public class IntervalsPrefixDescriptor : DescriptorBase<IntervalsPrefixDescriptor, IIntervalsPrefix>, IIntervalsPrefix | ||
{ | ||
string IIntervalsPrefix.Analyzer { get; set; } | ||
string IIntervalsPrefix.Prefix { get; set; } | ||
Field IIntervalsPrefix.UseField { get; set; } | ||
|
||
/// <inheritdoc cref="IIntervalsPrefix.Analyzer" /> | ||
public IntervalsPrefixDescriptor Analyzer(string analyzer) => Assign(analyzer, (a, v) => a.Analyzer = v); | ||
|
||
/// <inheritdoc cref="IIntervalsPrefix.Prefix" /> | ||
public IntervalsPrefixDescriptor Prefix(string prefix) => Assign(prefix, (a, v) => a.Prefix = v); | ||
|
||
/// <inheritdoc cref="IIntervalsPrefix.UseField" /> | ||
public IntervalsPrefixDescriptor UseField<T>(Expression<Func<T, object>> objectPath) => Assign(objectPath, (a, v) => a.UseField = v); | ||
|
||
/// <inheritdoc cref="IIntervalsPrefix.UseField" /> | ||
public IntervalsPrefixDescriptor UseField(Field useField) => Assign(useField, (a, v) => a.UseField = v); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Nest | ||
{ | ||
/// <summary> | ||
/// Matches terms using a wildcard pattern. This pattern can expand to match at most 128 terms. | ||
/// If the pattern matches more than 128 terms, Elasticsearch returns an error. | ||
/// <para /> | ||
/// Available in Elasticsearch 7.3.0+ | ||
/// </summary> | ||
[ReadAs(typeof(IntervalsWildcard))] | ||
public interface IIntervalsWildcard : IIntervalsNoFilter | ||
{ | ||
/// <summary> | ||
/// Analyzer used to normalize the prefix. Defaults to the top-level field's analyzer. | ||
/// </summary> | ||
[DataMember(Name = "analyzer")] | ||
string Analyzer { get; set; } | ||
|
||
/// <summary> | ||
/// Wildcard pattern used to find matching terms. Supports two wildcard operators: | ||
/// <para />?, which matches any single character | ||
/// <para />*, which can match zero or more characters, including an empty one | ||
/// <para />Warning: Avoid beginning patterns with * or ?. This can increase the iterations needed to find matching terms and slow search performance. | ||
/// </summary> | ||
[DataMember(Name = "pattern")] | ||
string Pattern { get; set; } | ||
|
||
/// <summary> | ||
/// If specified, then match intervals from this field rather than the top-level field. | ||
/// The prefix is normalized using the search analyzer from this field, unless a separate analyzer is specified. | ||
/// </summary> | ||
[DataMember(Name = "use_field")] | ||
Field UseField { get; set; } | ||
} | ||
|
||
/// <inheritdoc cref="IIntervalsWildcard" /> | ||
public class IntervalsWildcard : IntervalsNoFilterBase, IIntervalsWildcard | ||
{ | ||
/// <inheritdoc /> | ||
public string Analyzer { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public string Pattern { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public Field UseField { get; set; } | ||
|
||
internal override void WrapInContainer(IIntervalsContainer container) => container.Wildcard = this; | ||
} | ||
|
||
/// <inheritdoc cref="IIntervalsWildcard" /> | ||
public class IntervalsWildcardDescriptor : DescriptorBase<IntervalsWildcardDescriptor, IIntervalsWildcard>, IIntervalsWildcard | ||
{ | ||
string IIntervalsWildcard.Analyzer { get; set; } | ||
string IIntervalsWildcard.Pattern { get; set; } | ||
Field IIntervalsWildcard.UseField { get; set; } | ||
|
||
/// <inheritdoc cref="IIntervalsWildcard.Analyzer" /> | ||
public IntervalsWildcardDescriptor Analyzer(string analyzer) => Assign(analyzer, (a, v) => a.Analyzer = v); | ||
|
||
/// <inheritdoc cref="IIntervalsWildcard.Pattern" /> | ||
public IntervalsWildcardDescriptor Pattern(string pattern) => Assign(pattern, (a, v) => a.Pattern = v); | ||
|
||
/// <inheritdoc cref="IIntervalsWildcard.UseField" /> | ||
public IntervalsWildcardDescriptor UseField<T>(Expression<Func<T, object>> objectPath) => Assign(objectPath, (a, v) => a.UseField = v); | ||
|
||
/// <inheritdoc cref="IIntervalsWildcard.UseField" /> | ||
public IntervalsWildcardDescriptor UseField(Field useField) => Assign(useField, (a, v) => a.UseField = v); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.