From 4a903e59f3bdb40cdf5aefcdc5255acfb706a7f5 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Sat, 3 Nov 2018 20:16:46 +0100 Subject: [PATCH 01/15] update editorconfig and shared resharper settings --- .editorconfig | 11 ++++ src/Elasticsearch.sln.DotSettings | 84 +++++++------------------------ 2 files changed, 29 insertions(+), 66 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2c0f81a480b..cd2391b636d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -111,6 +111,17 @@ csharp_space_between_method_call_parameter_list_parentheses = false:error csharp_preserve_single_line_statements = false:error csharp_preserve_single_line_blocks = true:error +# Resharper +resharper_csharp_braces_for_lock=required_for_complex +resharper_csharp_braces_for_using=required_for_complex +resharper_csharp_braces_for_while=required_for_complex +resharper_csharp_braces_for_foreach=required_for_complex +resharper_csharp_braces_for_for=required_for_complex +resharper_csharp_braces_for_fixed=required_for_complex +resharper_csharp_braces_for_ifelse=required_for_complex + +resharper_csharp_accessor_owner_body=expression_body + # Override source included files [{SimpleJson|SynchronizedCollection}.cs] csharp_style_var_for_built_in_types = false:none diff --git a/src/Elasticsearch.sln.DotSettings b/src/Elasticsearch.sln.DotSettings index c5e478c115b..c0aa08ce146 100644 --- a/src/Elasticsearch.sln.DotSettings +++ b/src/Elasticsearch.sln.DotSettings @@ -1,17 +1,23 @@  True 56A87048-9065-459B-826D-3DF68B409845/d:Views + + *.Doc.cs + True HINT - <?xml version="1.0" encoding="utf-16"?><Profile name="SilentCodeCleanUp"><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><HtmlReformatCode>True</HtmlReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>IMPLICIT_WHEN_INITIALIZER_HAS_TYPE</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSReorderTypeMembers>True</CSReorderTypeMembers><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><JsFormatDocComments>True</JsFormatDocComments><XMLReformatCode>True</XMLReformatCode><CssReformatCode>True</CssReformatCode><CssAlphabetizeProperties>True</CssAlphabetizeProperties><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><IDEA_SETTINGS>&lt;profile version="1.0"&gt; + <?xml version="1.0" encoding="utf-16"?><Profile name="SilentCodeCleanUp"><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><HtmlReformatCode>True</HtmlReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>IMPLICIT_WHEN_INITIALIZER_HAS_TYPE</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSReorderTypeMembers>True</CSReorderTypeMembers><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><JsFormatDocComments>True</JsFormatDocComments><XMLReformatCode>True</XMLReformatCode><CssReformatCode>True</CssReformatCode><CssAlphabetizeProperties>True</CssAlphabetizeProperties><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><CSArrangeQualifiers>True</CSArrangeQualifiers><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="True" ArrangeVarStyle="True" /><IDEA_SETTINGS>&lt;profile version="1.0"&gt; &lt;option name="myName" value="SilentCodeCleanUp" /&gt; -&lt;/profile&gt;</IDEA_SETTINGS><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="False" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="False" ArrangeArgumentsStyle="False" ArrangeCodeBodyStyle="True" ArrangeVarStyle="True" /><CSArrangeQualifiers>True</CSArrangeQualifiers></Profile> +&lt;/profile&gt;</IDEA_SETTINGS></Profile> SilentCodeCleanUp SilentCodeCleanUp False OPTIMAL_FILL - 1 + 0 + 1 + 0 1 - 1 + 0 + TOGETHER_SAME_LINE ALWAYS_ADD ALWAYS_ADD ALWAYS_ADD @@ -32,11 +38,15 @@ False False True + True True True - True + False + CHOP_IF_LONG 150 CHOP_IF_LONG + DoNotTouch + DoNotTouch <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> <TypePattern DisplayName="COM interfaces or structs" RemoveRegions="All" Priority="100"> @@ -225,12 +235,7 @@ <Name Is="Enter Pattern Here" /> </Entry.SortBy> </Entry> - <Entry DisplayName="All other members"> - <Entry.SortBy> - <Access /> - <Name Is="Enter Pattern Here" /> - </Entry.SortBy> - </Entry> + <Entry DisplayName="All other members" /> <Entry DisplayName="Nested Types"> <Entry.Match> <Kind Is="Type" /> @@ -462,68 +467,15 @@ True False KM - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - LIVE_MONITOR - LIVE_MONITOR - DO_NOTHING - LIVE_MONITOR - LIVE_MONITOR - LIVE_MONITOR - LIVE_MONITOR - LIVE_MONITOR - LIVE_MONITOR - LIVE_MONITOR - LIVE_MONITOR - DO_NOTHING - LIVE_MONITOR True True True True True + False True HotTrack Hack (?<=\W|^)(?<TAG>HACK)(\W|$)(.*) Warning - True \ No newline at end of file + True From 7db1921c84ab5fa0cbfd85981ab34083849af27f Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Sat, 3 Nov 2018 21:20:45 +0100 Subject: [PATCH 02/15] Code Cleanup: Nest --- src/Nest/Aggregations/AggregateDictionary.cs | 103 +-- .../AggregateDictionaryConverter.cs | 5 +- .../Aggregations/AggregateJsonConverter.cs | 206 ++--- src/Nest/Aggregations/Aggregation.cs | 41 +- src/Nest/Aggregations/AggregationContainer.cs | 577 ++++++------ .../Aggregations/AggregationJsonConverter.cs | 10 +- .../AdjacencyMatrixAggregation.cs | 3 +- src/Nest/Aggregations/Bucket/Bucket.cs | 5 +- .../Aggregations/Bucket/BucketAggregate.cs | 22 +- .../Aggregations/Bucket/BucketAggregation.cs | 16 +- .../Bucket/Children/ChildrenAggregation.cs | 9 +- .../Bucket/Composite/CompositeAggregation.cs | 41 +- .../Composite/CompositeAggregationSource.cs | 108 +-- .../Bucket/Composite/CompositeBucket.cs | 18 +- ...DateHistogramCompositeAggregationSource.cs | 44 +- .../HistogramCompositeAggregationSource.cs | 33 +- .../TermsCompositeAggregationSource.cs | 16 +- .../DateHistogram/DateHistogramAggregation.cs | 86 +- .../DateHistogram/DateHistogramBucket.cs | 7 +- .../Bucket/DateHistogram/DateInterval.cs | 20 +- .../Bucket/DateRange/DateRangeAggregation.cs | 14 +- .../Bucket/DateRange/DateRangeExpression.cs | 17 +- .../Bucket/Filter/FilterAggregation.cs | 9 +- .../Filter/FilterAggregationJsonConverter.cs | 5 +- .../Bucket/Filters/FiltersAggregate.cs | 11 +- .../Bucket/Filters/FiltersAggregation.cs | 30 +- .../Bucket/Filters/NamedFiltersContainer.cs | 15 +- .../GeoDistance/GeoDistanceAggregation.cs | 35 +- .../GeoHashGrid/GeoHashGridAggregation.cs | 22 +- .../Bucket/Global/GlobalAggregation.cs | 5 +- .../Bucket/Histogram/ExtendedBounds.cs | 8 +- .../Bucket/Histogram/HistogramAggregation.cs | 47 +- .../Bucket/Histogram/HistogramOrder.cs | 8 +- .../Aggregations/Bucket/IpRange/IpRange.cs | 12 +- .../Bucket/IpRange/IpRangeAggregation.cs | 10 +- src/Nest/Aggregations/Bucket/KeyedBucket.cs | 10 +- .../Bucket/Missing/MissingAggregation.cs | 6 +- .../Bucket/Nested/NestedAggregation.cs | 6 +- .../Bucket/Range/RangeAggregation.cs | 17 +- .../Aggregations/Bucket/Range/RangeBucket.cs | 5 +- .../ReverseNested/ReverseNestedAggregation.cs | 8 +- .../Bucket/Sampler/SamplerAggregation.cs | 17 +- .../SamplerAggregationExecutionHint.cs | 6 +- .../Heuristics/ChiSquareHeuristic.cs | 8 +- .../Heuristics/MutualInformationHeuristic.cs | 10 +- .../Heuristics/PercentageScoreHeuristic.cs | 7 +- .../Heuristics/ScriptedHeuristic.cs | 6 +- .../SignificantTermsAggregate.cs | 9 +- .../SignificantTermsAggregation.cs | 175 ++-- .../SignificantTermsBucket.cs | 3 +- .../SignificantTermsIncludeExclude.cs | 8 +- .../SignificantTextAggregation.cs | 239 ++--- .../Bucket/Terms/TermsAggregate.cs | 7 +- .../Bucket/Terms/TermsAggregation.cs | 86 +- .../Terms/TermsAggregationCollectMode.cs | 5 +- .../Terms/TermsAggregationExecutionHint.cs | 7 +- .../Aggregations/Bucket/Terms/TermsExclude.cs | 28 +- .../Bucket/Terms/TermsExcludeJsonConverter.cs | 2 +- .../Aggregations/Bucket/Terms/TermsInclude.cs | 53 +- .../Bucket/Terms/TermsIncludeJsonConverter.cs | 2 +- .../Aggregations/Bucket/Terms/TermsOrder.cs | 9 +- .../Aggregations/Matrix/MatrixAggregate.cs | 6 +- .../Aggregations/Matrix/MatrixAggregation.cs | 13 +- .../MatrixStats/MatrixStatsAggregate.cs | 34 +- .../MatrixStats/MatrixStatsAggregation.cs | 7 +- .../Matrix/MatrixStats/MatrixStatsMode.cs | 15 +- .../Metric/Average/AverageAggregation.cs | 4 +- .../Cardinality/CardinalityAggregation.cs | 7 +- .../ExtendedStats/ExtendedStatsAggregate.cs | 12 +- .../Metric/GeoBounds/GeoBoundsAggregate.cs | 7 +- .../Metric/GeoBounds/GeoBoundsAggregation.cs | 4 +- .../GeoCentroid/GeoCentroidAggregate.cs | 5 +- .../GeoCentroid/GeoCentroidAggregation.cs | 11 +- .../Aggregations/Metric/Max/MaxAggregation.cs | 4 +- .../Aggregations/Metric/MetricAggregate.cs | 5 +- .../Aggregations/Metric/MetricAggregation.cs | 18 +- .../Aggregations/Metric/Min/MinAggregation.cs | 4 +- .../PercentileRanksAggregation.cs | 13 +- ...PercentileRanksAggregationJsonConverter.cs | 5 +- .../Percentiles/PercentilesAggregation.cs | 25 +- .../PercentilesAggregationJsonConverter.cs | 2 +- .../Percentiles/PercentilesMetricAggregate.cs | 3 +- .../ScriptedMetric/ScriptedMetricAggregate.cs | 15 +- .../ScriptedMetricAggregation.cs | 48 +- .../Metric/Stats/StatsAggregate.cs | 6 +- .../Aggregations/Metric/Sum/SumAggregation.cs | 4 +- .../Metric/TopHits/TopHitsAggregate.cs | 17 +- .../Metric/TopHits/TopHitsAggregation.cs | 65 +- .../ValueCount/ValueCountAggregation.cs | 7 +- .../WeightedAverageAggregation.cs | 52 +- .../WeightedAverage/WeightedAverageValue.cs | 39 +- .../AverageBucket/AverageBucketAggregation.cs | 6 +- .../BucketScript/BucketScriptAggregation.cs | 8 +- .../BucketSelectorAggregation.cs | 8 +- .../BucketSort/BucketSortAggregation.cs | 43 +- src/Nest/Aggregations/Pipeline/BucketsPath.cs | 18 +- .../CumulativeSum/CumulativeSumAggregation.cs | 6 +- .../Derivative/DerivativeAggregation.cs | 2 +- .../ExtendedStatsBucketAggregation.cs | 10 +- src/Nest/Aggregations/Pipeline/GapPolicy.cs | 1 + .../MaxBucket/MaxBucketAggregation.cs | 6 +- .../MinBucket/MinBucketAggregation.cs | 6 +- .../MovingAverage/Models/EwmaModel.cs | 5 +- .../MovingAverage/Models/HoltLinearModel.cs | 5 +- .../MovingAverage/Models/HoltWintersModel.cs | 14 +- .../Models/IMovingAverageModel.cs | 12 +- .../MovingAverage/Models/LinearModel.cs | 4 +- .../MovingAverage/MovingAverageAggregation.cs | 28 +- .../MovingAverageAggregationJsonConverter.cs | 7 +- .../MovingFunctionAggregation.cs | 17 +- .../PercentilesBucketAggregation.cs | 15 +- .../Pipeline/PipelineAggregationBase.cs | 14 +- .../SerialDifferencingAggregation.cs | 9 +- .../StatsBucket/StatsBucketAggregation.cs | 7 +- .../SumBucket/SumBucketAggregation.cs | 6 +- .../Visitor/AggregationVisitor.cs | 251 ++---- .../Visitor/AggregationVisitorScope.cs | 8 +- .../Aggregations/Visitor/AggregationWalker.cs | 120 ++- src/Nest/Analysis/Analysis.cs | 14 +- src/Nest/Analysis/Analyzers/AnalyzerBase.cs | 15 +- .../Analyzers/AnalyzerJsonConverter.cs | 13 +- src/Nest/Analysis/Analyzers/Analyzers.cs | 23 +- src/Nest/Analysis/Analyzers/CustomAnalyzer.cs | 48 +- .../Analysis/Analyzers/FingerprintAnalyzer.cs | 35 +- .../Analysis/Analyzers/KeywordAnalyzer.cs | 7 +- .../Analysis/Analyzers/LanguageAnalyzer.cs | 58 +- src/Nest/Analysis/Analyzers/NoriAnalyzer.cs | 47 +- .../Analysis/Analyzers/PatternAnalyzer.cs | 26 +- src/Nest/Analysis/Analyzers/SimpleAnalyzer.cs | 9 +- .../Analysis/Analyzers/SnowballAnalyzer.cs | 21 +- .../Analysis/Analyzers/StandardAnalyzer.cs | 35 +- src/Nest/Analysis/Analyzers/StopAnalyzer.cs | 14 +- .../Analysis/Analyzers/WhitespaceAnalyzer.cs | 9 +- .../Analysis/CharFilters/CharFilterBase.cs | 19 +- .../CharFilters/CharFilterJsonConverter.cs | 16 +- src/Nest/Analysis/CharFilters/CharFilters.cs | 14 +- .../CharFilters/HtmlStripCharFilter.cs | 10 +- .../Analysis/CharFilters/MappingCharFilter.cs | 20 +- .../CharFilters/PatternReplaceCharFilter.cs | 20 +- src/Nest/Analysis/Languages/Language.cs | 62 +- .../Analysis/Languages/SnowballLanguage.cs | 69 +- .../Analysis/Normalizers/CustomNormalizer.cs | 24 +- .../Analysis/Normalizers/NormalizerBase.cs | 15 +- .../Normalizers/NormalizerJsonConverter.cs | 12 +- src/Nest/Analysis/Normalizers/Normalizers.cs | 7 +- .../Icu/Collation/IcuCollationAlternate.cs | 6 +- .../Icu/Collation/IcuCollationCaseFirst.cs | 6 +- .../Collation/IcuCollationDecomposition.cs | 4 +- .../Icu/Collation/IcuCollationStrength.cs | 14 +- .../Plugins/Icu/IcuCollationTokenFilter.cs | 173 ++-- .../Plugins/Icu/IcuFoldingTokenFilter.cs | 12 +- .../Plugins/Icu/IcuNormalizationCharFilter.cs | 35 +- .../Icu/IcuNormalizationTokenFilter.cs | 12 +- src/Nest/Analysis/Plugins/Icu/IcuTokenizer.cs | 14 +- .../Plugins/Icu/IcuTransformTokenFilter.cs | 14 +- .../Icu/Normalization/IcuNormalizationMode.cs | 5 +- .../Icu/Normalization/IcuNormalizationType.cs | 8 +- .../Icu/Transform/IcuNormalizationType.cs | 5 +- .../Plugins/Kuromoji/KuromojiAnalyzer.cs | 13 +- .../KuromojiIterationMarkCharFilter.cs | 29 +- .../KuromojiPartOfSpeechTokenFilter.cs | 12 +- .../KuromojiReadingFormTokenFilter.cs | 14 +- .../Kuromoji/KuromojiStemmerTokenFilter.cs | 12 +- .../Kuromoji/KuromojiTokenizationMode.cs | 3 +- .../Plugins/Kuromoji/KuromojiTokenizer.cs | 78 +- .../Plugins/Phonetic/PhoneticEncoder.cs | 11 + .../Plugins/Phonetic/PhoneticLanguage.cs | 2 +- .../Plugins/Phonetic/PhoneticNameType.cs | 2 +- .../Plugins/Phonetic/PhoneticRuleType.cs | 2 +- .../Plugins/Phonetic/PhoneticTokenFilter.cs | 66 +- src/Nest/Analysis/StopWords.cs | 14 +- .../TokenFilters/AsciiFoldingTokenFilter.cs | 8 +- .../TokenFilters/CommonGramsTokenFilter.cs | 33 +- .../CompoundWordTokenFilterBase.cs | 89 +- .../DictionaryDecompounderTokenFilter.cs | 10 +- .../HyphenationDecompounderTokenFilter.cs | 13 +- .../DelimitedPayloadEncoding.cs | 4 +- .../DelimitedPayloadTokenFilter.cs | 16 +- .../TokenFilters/EdgeNGram/EdgeNGramSide.cs | 3 +- .../EdgeNGram/EdgeNGramTokenFilter.cs | 43 +- .../TokenFilters/ElisionTokenFilter.cs | 17 +- .../TokenFilters/FingerprintTokenFilter.cs | 36 +- .../TokenFilters/HunspellTokenFilter.cs | 54 +- .../Analysis/TokenFilters/KStemTokenFilter.cs | 15 +- .../TokenFilters/KeepTypesTokenFilter.cs | 35 +- .../TokenFilters/KeepWordsTokenFilter.cs | 40 +- .../TokenFilters/KeywordMarkerTokenFilter.cs | 43 +- .../TokenFilters/LengthTokenFilter.cs | 38 +- .../LimitTokenCountTokenFilter.cs | 41 +- .../TokenFilters/LowercaseTokenFilter.cs | 19 +- .../TokenFilters/MultiplexerTokenFilter.cs | 20 +- .../Analysis/TokenFilters/NgramTokenFilter.cs | 37 +- .../NoriPartOfSpeechTokenFilter.cs | 7 +- .../TokenFilters/PatternCaptureTokenFilter.cs | 22 +- .../TokenFilters/PatternReplaceTokenFilter.cs | 22 +- .../TokenFilters/PorterStemTokenFilter.cs | 11 +- .../RemoveDuplicatesTokenFilter.cs | 11 +- .../TokenFilters/ReverseTokenFilter.cs | 11 +- .../Shingle/ShingleTokenFilter.cs | 73 +- .../TokenFilters/SnowballTokenFilter.cs | 15 +- .../TokenFilters/StandardTokenFilter.cs | 10 +- .../StemmerOverrideTokenFilter.cs | 26 +- .../TokenFilters/StemmerTokenFilter.cs | 12 +- .../TokenFilters/Stop/StopTokenFilter.cs | 63 +- .../TokenFilters/Synonym/SynonymFormat.cs | 3 +- .../Synonym/SynonymGraphTokenFilter.cs | 83 +- .../Synonym/SynonymTokenFilter.cs | 83 +- .../Analysis/TokenFilters/TokenFilterBase.cs | 25 +- .../TokenFilters/TokenFilterJsonConverter.cs | 16 +- .../Analysis/TokenFilters/TokenFilters.cs | 85 +- .../Analysis/TokenFilters/TrimTokenFilter.cs | 9 +- .../TokenFilters/TruncateTokenFilter.cs | 18 +- .../TokenFilters/UniqueTokenFilter.cs | 13 +- .../TokenFilters/UppercaseTokenFilter.cs | 9 +- .../WordDelimiter/WordDelimiterTokenFilter.cs | 172 ++-- .../WordDelimiterGraphTokenFilter.cs | 176 ++-- .../Analysis/Tokenizers/CharGroupTokenizer.cs | 24 +- .../Analysis/Tokenizers/KeywordTokenizer.cs | 20 +- .../Analysis/Tokenizers/LetterTokenizer.cs | 23 +- .../Analysis/Tokenizers/LowercaseTokenizer.cs | 16 +- .../Tokenizers/NGram/EdgeNGramTokenizer.cs | 49 +- .../Tokenizers/NGram/NGramTokenizer.cs | 48 +- .../Analysis/Tokenizers/NGram/TokenChar.cs | 6 +- src/Nest/Analysis/Tokenizers/NoriTokenizer.cs | 37 +- .../Tokenizers/PathHierarchyTokenizer.cs | 64 +- .../Analysis/Tokenizers/PatternTokenizer.cs | 41 +- .../Analysis/Tokenizers/StandardTokenizer.cs | 24 +- src/Nest/Analysis/Tokenizers/TokenizerBase.cs | 14 +- .../Tokenizers/TokenizerJsonConverter.cs | 16 +- src/Nest/Analysis/Tokenizers/Tokenizers.cs | 31 +- .../Tokenizers/UaxEmailUrlTokenizer.cs | 22 +- .../Tokenizers/WhitespaceTokenizer.cs | 18 +- src/Nest/Cat/CatAliases/CatAliasesRecord.cs | 8 +- .../CatAliases/ElasticClient-CatAliases.cs | 50 +- .../Cat/CatAllocation/CatAllocationRecord.cs | 14 +- .../ElasticClient-CatAllocation.cs | 39 +- src/Nest/Cat/CatCount/CatCountRecord.cs | 8 +- .../Cat/CatCount/ElasticClient-CatCount.cs | 49 +- .../Cat/CatFielddata/CatFielddataRecord.cs | 7 +- .../CatFielddataRecordJsonConverter.cs | 9 +- .../ElasticClient-CatFielddata.cs | 38 +- src/Nest/Cat/CatHealth/CatHealthRecord.cs | 14 +- .../Cat/CatHealth/ElasticClient-CatHealth.cs | 36 +- src/Nest/Cat/CatHelp/CatHelpRecord.cs | 1 - src/Nest/Cat/CatHelp/ElasticClient-CatHelp.cs | 74 +- src/Nest/Cat/CatIndices/CatIndicesRecord.cs | 8 +- .../CatIndices/ElasticClient-CatIndices.cs | 37 +- src/Nest/Cat/CatMaster/CatMasterRecord.cs | 2 +- .../Cat/CatMaster/ElasticClient-CatMaster.cs | 42 +- .../CatNodeAttributesRecord.cs | 23 +- .../CatNodeAttributesRequest.cs | 3 +- .../ElasticClient-CatNodeAttributes.cs | 41 +- src/Nest/Cat/CatNodes/CatNodesRecord.cs | 836 ++++++++++-------- .../Cat/CatNodes/ElasticClient-CatNodes.cs | 49 +- .../CatPendingTasks/CatPendingTasksRecord.cs | 7 +- .../ElasticClient-CatPendingTasks.cs | 36 +- src/Nest/Cat/CatPlugins/CatPluginsRecord.cs | 26 +- .../CatPlugins/ElasticClient-CatPlugins.cs | 40 +- src/Nest/Cat/CatRecovery/CatRecoveryRecord.cs | 72 +- .../CatRecovery/ElasticClient-CatRecovery.cs | 36 +- .../ElasticClient-CatRepositories.cs | 38 +- src/Nest/Cat/CatResponse.cs | 1 - src/Nest/Cat/CatSegments/CatSegmentsRecord.cs | 50 +- .../CatSegments/ElasticClient-CatSegments.cs | 38 +- src/Nest/Cat/CatShards/CatShardsRecord.cs | 140 +-- src/Nest/Cat/CatShards/CatShardsRequest.cs | 2 +- .../Cat/CatShards/ElasticClient-CatShards.cs | 46 +- .../Cat/CatSnapshots/CatSnapshotsRecord.cs | 33 +- .../ElasticClient-CatSnapshots.cs | 41 +- src/Nest/Cat/CatTasks/CatTasksRequest.cs | 8 +- .../Cat/CatTasks/ElasticClient-CatTasks.cs | 35 +- .../Cat/CatTemplates/CatTemplatesRecord.cs | 10 +- .../Cat/CatTemplates/CatTemplatesRequest.cs | 3 +- .../ElasticClient-CatTemplates.cs | 38 +- .../Cat/CatThreadPool/CatThreadPoolRecord.cs | 65 +- .../ElasticClient-CatThreadpool.cs | 36 +- src/Nest/Cat/ElasticClient-Cat.cs | 21 +- src/Nest/Cat/ICatRecord.cs | 4 +- .../ClusterAllocationExplainRequest.cs | 22 +- .../ClusterAllocationExplainResponse.cs | 264 +++--- .../ElasticClient-ClusterAllocationExplain.cs | 68 +- src/Nest/Cluster/ClusterHealth.cs | 4 +- .../ClusterHealth/ClusterHealthResponse.cs | 60 +- .../ElasticClient-ClusterHealth.cs | 49 +- .../Cluster/ClusterHealth/IndexHealthStats.cs | 29 +- .../Cluster/ClusterHealth/ShardHealthStats.cs | 17 +- .../ClusterPendingTasksResponse.cs | 6 +- .../ElasticClient-ClusterPendingTasks.cs | 58 +- .../ClusterRerouteExplanation.cs | 6 +- .../ClusterRerouteParameters.cs | 18 +- .../ClusterReroute/ClusterRerouteRequest.cs | 13 +- .../ClusterReroute/ClusterRerouteResponse.cs | 10 +- .../ClusterReroute/ClusterRerouteState.cs | 14 +- .../AllocateClusterRerouteCommandBase.cs | 43 +- .../Commands/CancelClusterRerouteCommand.cs | 26 +- .../ClusterRerouteCommandJsonConverter.cs | 9 +- .../Commands/IClusterRerouteCommand.cs | 2 +- .../Commands/MoveClusterRerouteCommand.cs | 14 +- .../ElasticClient-ClusterReroute.cs | 47 +- .../ClusterGetSettingsRequest.cs | 2 +- .../ElasticClient-ClusterGetSettings.cs | 58 +- .../ClusterPutSettingsRequest.cs | 1 - .../ElasticClient-ClusterPutSettings.cs | 58 +- src/Nest/Cluster/ClusterState/AllocationId.cs | 5 +- src/Nest/Cluster/ClusterState/BlockState.cs | 5 +- .../ClusterState/ClusterStateResponse.cs | 45 +- .../ElasticClient-ClusterState.cs | 45 +- .../ClusterState/MetadataIndexState.cs | 14 +- .../Cluster/ClusterState/MetadataState.cs | 10 +- src/Nest/Cluster/ClusterState/NodeState.cs | 8 +- .../Cluster/ClusterState/RoutingNodesState.cs | 8 +- src/Nest/Cluster/ClusterState/RoutingShard.cs | 17 +- .../Cluster/ClusterState/RoutingTableState.cs | 2 - .../ClusterStats/ClusterIndicesStats.cs | 26 +- .../Cluster/ClusterStats/ClusterNodesStats.cs | 95 +- .../ClusterStats/ClusterStatsResponse.cs | 20 +- .../ElasticClient-ClusterStats.cs | 45 +- .../ElasticClient-NodesHotThreads.cs | 54 +- .../NodesHotThreads/NodesHotThreadsRequest.cs | 5 +- .../NodesHotThreadsResponse.cs | 10 +- .../NodesInfo/ElasticClient-NodesInfo.cs | 40 +- src/Nest/Cluster/NodesInfo/NodeInfo.cs | 182 ++-- src/Nest/Cluster/NodesInfo/NodeRole.cs | 12 +- .../Cluster/NodesInfo/NodesInfoResponse.cs | 3 - src/Nest/Cluster/NodesResponseBase.cs | 6 +- .../NodesStats/AdaptiveSelectionStats.cs | 34 +- .../NodesStats/ElasticClient-NodesStats.cs | 42 +- src/Nest/Cluster/NodesStats/NodeStats.cs | 327 ++++--- .../Cluster/NodesStats/NodeStatsResponse.cs | 1 - .../NodesStats/Statistics/IngestStats.cs | 12 +- .../NodesStats/Statistics/NodeIngestStats.cs | 8 +- .../NodesUsage/ElasticClient-NodesUsage.cs | 42 +- .../NodesUsage/NodeUsageInformation.cs | 14 +- .../Cluster/NodesUsage/NodeUsageResponse.cs | 3 +- src/Nest/Cluster/Ping/ElasticClient-Ping.cs | 43 +- src/Nest/Cluster/Ping/PingResponse.cs | 8 +- .../RemoteInfo/ElasticClient-RemoteInfo.cs | 42 +- .../Cluster/RemoteInfo/RemoteInfoResponse.cs | 21 +- .../ElasticClient-RootNodeInfo.cs | 42 +- .../RootNodeInfo/RootVersionInfoResponse.cs | 5 +- .../CancelTasks/CancelTasksResponse.cs | 19 +- .../CancelTasks/ElasticClient-CancelTasks.cs | 42 +- .../GetTask/ElasticClient-GetTask.cs | 22 +- .../TaskManagement/GetTask/GetTaskRequest.cs | 6 +- .../TaskManagement/GetTask/GetTaskResponse.cs | 5 - .../TaskManagement/GetTask/TaskInfo.cs | 46 +- .../ListTasks/ElasticClient-ListTasks.cs | 36 +- .../ListTasks/ListTasksResponse.cs | 97 +- .../ConnectionSettings/ClrPropertyMapping.cs | 14 +- .../ConnectionSettings/ClrTypeDefaults.cs | 60 +- .../ConnectionSettingsBase.cs | 168 ++-- .../ConnectionSettingsValuesExtensions.cs | 6 +- .../IConnectionSettingsValues.cs | 20 +- .../ConnectionSettings/MemberInfoResolver.cs | 12 +- .../IsADictionary/IIsADictionary.cs | 4 +- .../IsADictionary/IsADictionaryBase.cs | 76 +- .../IsADictionaryDescriptorBase.cs | 4 +- .../IIsAReadOnlyDictionary.cs | 4 +- .../IsADictionaryBase.cs | 28 +- .../PerFieldAnalyzer/PerFieldAnalyzer.cs | 9 +- .../Extensions/ExceptionExtensions.cs | 3 - .../Extensions/ExpressionExtensions.cs | 52 +- .../Extensions/Extensions.cs | 88 +- .../Extensions/JsonExtensions.cs | 7 +- .../Extensions/StringExtensions.cs | 6 +- .../Extensions/SuffixExtensions.cs | 7 +- .../Extensions/TypeExtensions.cs | 58 +- .../CommonAbstractions/Fields/FieldValues.cs | 55 +- .../Fields/FieldValuesJsonConverter.cs | 19 +- .../Fluent/DescriptorBase.cs | 11 +- src/Nest/CommonAbstractions/Fluent/Fluent.cs | 3 +- .../Fluent/FluentDictionary.cs | 6 +- .../Fluent/Promise/DescriptorPromiseBase.cs | 19 +- .../CommonAbstractions/Fluent/SelectorBase.cs | 9 +- src/Nest/CommonAbstractions/ForAttribute.cs | 13 +- .../Infer/ActionIds/ActionIds.cs | 43 +- .../Infer/CategoryId/CategoryId.cs | 15 +- .../Infer/DocumentPath/DocumentPath.cs | 39 +- .../CommonAbstractions/Infer/Field/Field.cs | 89 +- .../Infer/Field/FieldExpressionVisitor.cs | 59 +- .../Infer/Field/FieldExtensions.cs | 7 +- .../Infer/Field/FieldJsonConverter.cs | 3 +- .../Infer/Field/FieldResolver.cs | 34 +- .../CommonAbstractions/Infer/Fields/Fields.cs | 52 +- .../Infer/Fields/FieldsDescriptor.cs | 4 + .../Infer/Fields/FieldsJsonConverter.cs | 14 +- src/Nest/CommonAbstractions/Infer/Id/Id.cs | 76 +- .../Infer/Id/IdExtensions.cs | 14 +- .../CommonAbstractions/Infer/Id/IdResolver.cs | 30 +- .../Infer/IndexName/IndexName.cs | 84 +- .../Infer/IndexName/IndexNameExtensions.cs | 4 +- .../Infer/IndexName/IndexNameJsonConverter.cs | 2 +- .../Infer/IndexName/IndexNameResolver.cs | 16 +- .../Infer/Indices/Indices.cs | 120 +-- .../Infer/Indices/IndicesExtensions.cs | 1 + .../Infer/Indices/IndicesJsonConverter.cs | 2 +- .../IndicesMultiSyntaxJsonConverter.cs | 6 +- src/Nest/CommonAbstractions/Infer/Inferrer.cs | 80 +- .../Infer/JoinFieldRouting/Routing.cs | 106 +-- .../Infer/JoinFieldRouting/RoutingResolver.cs | 20 +- .../Infer/Metrics/IndexMetrics.cs | 13 +- .../Infer/Metrics/Metrics.cs | 35 +- .../CommonAbstractions/Infer/Name/Name.cs | 23 +- .../CommonAbstractions/Infer/Name/Names.cs | 26 +- .../Infer/NodeId/NodeIds.cs | 23 +- .../Infer/PropertyName/PropertyName.cs | 58 +- .../PropertyName/PropertyNameExtensions.cs | 6 +- .../PropertyName/PropertyNameJsonConverter.cs | 3 +- .../Infer/RelationName/RelationName.cs | 50 +- .../RelationName/RelationNameExtensions.cs | 5 +- .../RelationName/RelationNameJsonConverter.cs | 9 +- .../RelationName/RelationNameResolver.cs | 8 +- .../CommonAbstractions/Infer/TaskId/TaskId.cs | 30 +- .../Infer/TypeName/TypeName.cs | 59 +- .../Infer/TypeName/TypeNameExtensions.cs | 5 +- .../Infer/TypeName/TypeNameJsonConverter.cs | 10 +- .../Infer/TypeName/TypeNameResolver.cs | 8 +- .../CommonAbstractions/Infer/Types/Types.cs | 134 +-- .../Infer/Types/TypesJsonConverter.cs | 7 +- .../Types/TypesMultiSyntaxJsonConverter.cs | 5 +- .../LazyDocument/LazyDocument.cs | 15 +- .../LazyDocument/LazyDocumentJsonConverter.cs | 2 - .../IHighLevelToLowLevelDispatcher.cs | 6 +- .../LowLevelDispatch/LowLevelDispatch.cs | 45 +- .../CommonAbstractions/RawJson/RawJson.cs | 7 +- .../Reactive/BlockingSubscribeExtensions.cs | 7 +- .../CoordinatedRequestObserverBase.cs | 25 +- .../Reactive/GetEnumerator.cs | 76 +- .../Reactive/PartitionHelper.cs | 6 +- .../Reactive/ProducerConsumerBackPressure.cs | 23 +- .../CommonAbstractions/Request/RequestBase.cs | 45 +- .../CommonAbstractions/Request/RouteValues.cs | 67 +- .../Response/DictionaryResponseBase.cs | 8 +- .../Response/ElasticsearchVersionInfo.cs | 5 +- .../Response/ResolvableDictionaryProxy.cs | 48 +- .../Response/ResponseBase.cs | 112 ++- .../Attributes/IgnoreAttribute.cs | 2 +- .../Attributes/PropertyNameAttribute.cs | 3 +- .../Attributes/StringTimeSpanAttribute.cs | 2 +- .../ContractJsonConverterAttribute.cs | 20 +- .../ElasticContractResolver.cs | 180 ++-- .../CompositeJsonConverter.cs | 33 +- .../EnumMemberValueCasingJsonConverter.cs | 8 +- .../ErrorCauseJsonConverter.cs | 10 +- .../ErrorJsonConverter.cs | 2 + .../GenericJsonConverters/FromJson.cs | 4 +- .../GenericProxyRequestConverterBase.cs | 12 +- .../IndicesBoostJsonConverter.cs | 3 +- .../JsonConverterBase.cs | 8 +- .../KeyValueJsonConverter.cs | 27 +- .../ReadAsTypeJsonConverter.cs | 7 +- .../ReadOnlyCollectionJsonConverter.cs | 15 +- .../ReadSingleOrEnumerableJsonConverter.cs | 10 +- .../ReserializeJsonConverter.cs | 27 +- .../TimeSpanToStringConverter.cs | 8 +- .../VerbatimDictionaryKeysConverter.cs | 50 +- .../InternalSerializer.cs | 99 ++- .../SerializationBehavior/JTokenExtensions.cs | 18 +- .../JsonReaderExtensions.cs | 14 +- .../SerializationBehavior/PropertyMapping.cs | 27 +- .../SerializationBehavior/SourceConverter.cs | 6 +- .../SourceValueWriteConverter.cs | 6 +- src/Nest/CommonAbstractions/Static/Infer.cs | 23 +- src/Nest/CommonAbstractions/Union/Union.cs | 33 +- .../Union/UnionJsonConverter.cs | 14 +- .../AlternativeEnumMemberAttribute.cs | 2 +- .../CommonOptions/DateFormat/DateFormat.cs | 314 +++++-- src/Nest/CommonOptions/DateMath/DateMath.cs | 25 +- .../DateMath/DateMathExpression.cs | 9 +- .../DateMath/DateMathOperation.cs | 2 +- .../CommonOptions/DateMath/DateMathTime.cs | 171 ++-- .../DateMath/DateMathTimeUnit.cs | 6 + src/Nest/CommonOptions/Failures/BulkError.cs | 8 +- src/Nest/CommonOptions/Fuzziness/Fuzziness.cs | 8 +- .../Fuzziness/FuzzinessJsonConverter.cs | 11 +- .../CommonOptions/Fuzziness/IFuzziness.cs | 9 +- src/Nest/CommonOptions/Geo/Distance.cs | 40 +- .../Geo/DistanceJsonConverter.cs | 6 +- src/Nest/CommonOptions/Geo/DistanceUnit.cs | 8 + src/Nest/CommonOptions/Geo/GeoDistanceType.cs | 1 + .../CommonOptions/Geo/GeoShapeRelation.cs | 3 + src/Nest/CommonOptions/Hit/ShardStatistics.cs | 11 +- .../MinimumShouldMatch/MinimumShouldMatch.cs | 13 +- .../CommonOptions/Range/AggregationRange.cs | 21 +- src/Nest/CommonOptions/Range/Ranges.cs | 77 +- .../CommonOptions/Scripting/IndexedScript.cs | 14 +- .../CommonOptions/Scripting/InlineScript.cs | 26 +- .../CommonOptions/Scripting/ScriptBase.cs | 54 +- .../CommonOptions/Scripting/ScriptFields.cs | 12 +- .../Scripting/ScriptJsonConverter.cs | 3 +- .../Sorting/SortJsonConverter.cs | 9 +- .../CommonOptions/Stats/FieldDataStats.cs | 2 +- src/Nest/CommonOptions/Stats/FlushStats.cs | 8 +- src/Nest/CommonOptions/Stats/GetStats.cs | 4 +- src/Nest/CommonOptions/Stats/IndexingStats.cs | 24 +- src/Nest/CommonOptions/Stats/MergesStats.cs | 7 +- src/Nest/CommonOptions/Stats/PluginStats.cs | 18 +- .../CommonOptions/Stats/QueryCacheStats.cs | 32 +- src/Nest/CommonOptions/Stats/RecoveryStats.cs | 1 - src/Nest/CommonOptions/Stats/RefreshStats.cs | 3 +- .../CommonOptions/Stats/RequestCacheStats.cs | 5 +- src/Nest/CommonOptions/Stats/SearchStats.cs | 6 +- src/Nest/CommonOptions/Stats/SegmentsStats.cs | 22 +- src/Nest/CommonOptions/Stats/StoreStats.cs | 2 - src/Nest/CommonOptions/Stats/TranslogStats.cs | 24 +- src/Nest/CommonOptions/Stats/WarmerStats.cs | 2 +- src/Nest/CommonOptions/TimeUnit/Time.cs | 161 ++-- .../TimeUnit/TimeJsonConverter.cs | 1 + src/Nest/CommonOptions/TimeUnit/TimeUnit.cs | 6 + .../CrossPlatform/SynchronizedCollection.cs | 269 +++--- src/Nest/CrossPlatform/TypeExtensions.cs | 29 +- .../Multiple/Bulk/BulkOperation/BulkCreate.cs | 25 +- .../Multiple/Bulk/BulkOperation/BulkDelete.cs | 21 +- .../Multiple/Bulk/BulkOperation/BulkIndex.cs | 33 +- .../Bulk/BulkOperation/BulkOperationBase.cs | 75 +- .../Multiple/Bulk/BulkOperation/BulkUpdate.cs | 134 +-- .../Bulk/BulkOperation/BulkUpdateBody.cs | 17 +- .../Bulk/BulkOperation/IBulkOperation.cs | 28 +- .../Document/Multiple/Bulk/BulkRequest.cs | 36 +- .../Multiple/Bulk/BulkRequestJsonConverter.cs | 17 +- .../Document/Multiple/Bulk/BulkResponse.cs | 32 +- .../BulkCreateResponseItem.cs | 2 +- .../BulkResponseItem/BulkIndexResponseItem.cs | 14 +- .../BulkResponseItem/BulkResponseItemBase.cs | 115 +-- .../BulkResponseItemJsonConverter.cs | 5 +- .../BulkUpdateResponseItem.cs | 2 +- .../Multiple/Bulk/ElasticClient-Bulk.cs | 36 +- .../Multiple/Bulk/ElasticClient-DeleteMany.cs | 13 +- .../Multiple/Bulk/ElasticClient-IndexMany.cs | 13 +- .../Multiple/BulkAll/BulkAllObservable.cs | 132 +-- .../Multiple/BulkAll/BulkAllObserver.cs | 19 +- .../Multiple/BulkAll/BulkAllRequest.cs | 231 ++--- .../Multiple/BulkAll/BulkAllResponse.cs | 11 +- .../Multiple/BulkAll/ElasticClient-BulkAll.cs | 10 +- .../Multiple/BulkIndexByScrollFailure.cs | 20 +- .../DeleteByQuery/DeleteByQueryRequest.cs | 10 +- .../DeleteByQuery/DeleteByQueryResponse.cs | 77 +- .../ElasticClient-DeleteByQuery.cs | 55 +- .../MultiGet/ElasticClient-GetMany.cs | 53 +- .../MultiGet/ElasticClient-MultiGet.cs | 47 +- .../MultiGet/ElasticClient-SourceMany.cs | 42 +- .../MultiGet/Request/IMultiGetOperation.cs | 20 +- .../MultiGet/Request/MultiGetOperation.cs | 72 +- .../MultiGet/Request/MultiGetRequest.cs | 36 +- .../Request/MultiGetRequestJsonConverter.cs | 16 +- .../Multiple/MultiGet/Response/MultiGetHit.cs | 45 +- .../Response/MultiGetHitJsonConverter.cs | 66 +- .../MultiGet/Response/MultiGetResponse.cs | 79 +- .../ElasticClient-MultiTermVectors.cs | 56 +- .../MultiTermVectorOperation.cs | 208 +++-- .../MultiTermVectorsRequest.cs | 45 +- .../Multiple/Reindex/ElasticClient-Reindex.cs | 91 +- .../Multiple/Reindex/ReindexObservable.cs | 133 +-- .../Multiple/Reindex/ReindexObserver.cs | 16 +- .../Multiple/Reindex/ReindexRequest.cs | 144 +-- .../ElasticClient-ReindexOnServer.cs | 39 +- .../ReindexOnServer/ReindexDestination.cs | 41 +- .../ReindexOnServer/ReindexOnServerRequest.cs | 59 +- .../ReindexOnServerResponse.cs | 77 +- .../ReindexOnServer/ReindexRouting.cs | 4 +- .../ReindexRoutingJsonConverter.cs | 4 +- .../Multiple/ReindexOnServer/ReindexSource.cs | 100 +-- .../Multiple/ReindexOnServer/RemoteSource.cs | 20 +- .../ElasticClient-ReindexRethrottle.cs | 50 +- .../Multiple/ReindexRethrottle/ReindexNode.cs | 79 +- .../ReindexRethrottleRequest.cs | 2 +- src/Nest/Document/Multiple/Retries.cs | 2 +- .../ScrollAll/ElasticClient-ScrollAll.cs | 26 +- .../Multiple/ScrollAll/ScrollAllObservable.cs | 91 +- .../Multiple/ScrollAll/ScrollAllObserver.cs | 6 +- .../Multiple/ScrollAll/ScrollAllRequest.cs | 108 +-- .../Multiple/ScrollAll/ScrollAllResponse.cs | 17 +- .../ElasticClient-UpdateByQuery.cs | 51 +- .../UpdateByQuery/UpdateByQueryRequest.cs | 2 - .../UpdateByQuery/UpdateByQueryResponse.cs | 57 +- src/Nest/Document/Result.cs | 14 +- .../Document/Single/Create/CreateRequest.cs | 16 +- .../Document/Single/Create/CreateResponse.cs | 33 +- .../Single/Create/ElasticClient-Create.cs | 67 +- .../Document/Single/Delete/DeleteResponse.cs | 44 +- .../Single/Delete/ElasticClient-Delete.cs | 34 +- .../Single/Exists/DocumentExistsRequest.cs | 4 +- .../Exists/ElasticClient-DocumentExists.cs | 49 +- .../Document/Single/Get/ElasticClient-Get.cs | 37 +- src/Nest/Document/Single/Get/GetRequest.cs | 5 +- src/Nest/Document/Single/Get/GetResponse.cs | 44 +- .../Single/Index/ElasticClient-Index.cs | 66 +- .../Document/Single/Index/IndexRequest.cs | 25 +- .../Document/Single/Index/IndexResponse.cs | 33 +- .../Single/Source/ElasticClient-Source.cs | 53 +- .../Document/Single/Source/SourceRequest.cs | 17 +- .../ElasticClient-SourceExists.cs | 46 +- .../SourceExists/SourceExistsRequest.cs | 4 +- .../TermVectors/ElasticClient-TermVectors.cs | 44 +- .../Single/TermVectors/FieldStatistics.cs | 22 +- .../Single/TermVectors/TermVectorFilter.cs | 63 +- .../Single/TermVectors/TermVectors.cs | 32 +- .../Single/TermVectors/TermVectorsRequest.cs | 42 +- .../Single/TermVectors/TermVectorsResponse.cs | 28 +- .../Single/Update/ElasticClient-Update.cs | 110 ++- .../Document/Single/Update/UpdateRequest.cs | 76 +- .../Document/Single/Update/UpdateResponse.cs | 30 +- src/Nest/ElasticClient.cs | 49 +- src/Nest/IElasticClient.cs | 25 +- .../IndexModules/IndexSettings/IndexState.cs | 11 +- .../Merge/MergePolicySettings.cs | 77 +- .../Merge/MergeSchedulerSettings.cs | 35 +- .../IndexSettings/Merge/MergeSettings.cs | 13 +- .../Queries/IQueriesCacheSettings.cs | 2 +- .../IndexSettings/Queries/IQueriesSettings.cs | 2 +- .../Settings/AutoExpandReplicas.cs | 36 +- .../Settings/DynamicIndexSettings.cs | 158 ++-- .../Settings/FixedIndexSettings.cs | 2 +- .../IndexSettings/Settings/IndexSettings.cs | 54 +- .../Settings/IndexSettingsConverter.cs | 41 +- .../Settings/RecoveryInitialShards.cs | 5 +- .../Settings/UpdatableIndexSettings.cs | 86 +- .../IndexSettings/SlowLog/ISlowLog.cs | 12 +- .../IndexSettings/SlowLog/ISlowLogIndexing.cs | 25 +- .../IndexSettings/SlowLog/ISlowLogSearch.cs | 16 +- .../SlowLog/ISlowLogSearchFetch.cs | 18 +- .../SlowLog/ISlowLogSearchQuery.cs | 25 +- .../IndexSettings/SlowLog/LogLevel.cs | 4 + .../IndexSettings/Sorting/ISortingSettings.cs | 39 +- .../Store/FileSystemStorageImplementation.cs | 22 +- .../Translog/TranslogDurability.cs | 3 +- .../Translog/TranslogFlushSettings.cs | 26 +- .../Translog/TranslogSettings.cs | 30 +- .../IndexModules/Similarity/BM25Similarity.cs | 35 +- .../Similarity/ClassicSimilarity.cs | 6 +- .../Similarity/CustomSimilarity.cs | 20 +- .../Similarity/DFI/DFIIndependenceMeasure.cs | 2 +- .../Similarity/DFI/DFISimilarity.cs | 14 +- .../Similarity/DFR/DFRAfterEffect.cs | 3 +- .../Similarity/DFR/DFRBasicModel.cs | 13 +- .../Similarity/DFR/DFRSimilarity.cs | 65 +- .../Similarity/IB/IBDistribution.cs | 3 +- .../IndexModules/Similarity/IB/IBLambda.cs | 2 +- .../Similarity/IB/IBSimilarity.cs | 31 +- .../Similarity/LMDirichletSimilarity.cs | 6 +- .../Similarity/LMJelinekMercerSimilarity.cs | 6 +- .../IndexModules/Similarity/Normalization.cs | 9 +- .../Similarity/ScriptedSimilarity.cs | 6 +- .../IndexModules/Similarity/Similarities.cs | 14 +- .../Similarity/SimilarityJsonConverter.cs | 9 +- src/Nest/Indices/AliasManagement/Alias.cs | 13 +- .../AliasManagement/Alias/Actions/AliasAdd.cs | 14 +- .../Alias/Actions/AliasAddOperation.cs | 16 +- .../Alias/Actions/AliasRemove.cs | 13 +- .../Alias/Actions/AliasRemoveIndex.cs | 7 +- .../Alias/Actions/AliasRemoveOperation.cs | 7 +- .../AliasManagement/Alias/BulkAliasRequest.cs | 9 +- .../Alias/BulkAliasResponse.cs | 8 +- .../Alias/ElasticClient-Alias.cs | 56 +- .../AliasManagement/AliasDefinition.cs | 11 +- .../AliasExists/AliasExistsRequest.cs | 2 +- .../AliasExists/ElasticClient-AliasExists.cs | 49 +- src/Nest/Indices/AliasManagement/Aliases.cs | 14 +- .../DeleteAlias/DeleteAliasResponse.cs | 8 +- .../DeleteAlias/ElasticClient-DeleteAlias.cs | 39 +- .../GetAlias/ElasticClient-GetAlias.cs | 33 +- ...ElasticClient-GetAliasesPointingToIndex.cs | 17 +- ...ElasticClient-GetIndicesPointingToAlias.cs | 11 +- .../GetAlias/GetAliasRequest.cs | 16 +- .../GetAlias/GetAliasResponse.cs | 2 +- .../PutAlias/ElasticClient-PutAlias.cs | 32 +- .../PutAlias/PutAliasRequest.cs | 28 +- .../Indices/Analyze/AnalyzeCharFilters.cs | 18 +- src/Nest/Indices/Analyze/AnalyzeRequest.cs | 57 +- src/Nest/Indices/Analyze/AnalyzeResponse.cs | 49 +- src/Nest/Indices/Analyze/AnalyzeToken.cs | 21 +- .../Indices/Analyze/AnalyzeTokenFilters.cs | 66 +- .../Analyze/AnalyzeTokenizersDescriptor.cs | 51 +- .../Indices/Analyze/ElasticClient-Analyze.cs | 40 +- .../CreateIndex/CreateIndexRequest.cs | 46 +- .../CreateIndex/CreateIndexResponse.cs | 6 - .../CreateIndex/ElasticClient-CreateIndex.cs | 38 +- .../DeleteIndex/DeleteIndexResponse.cs | 8 +- .../DeleteIndex/ElasticClient-DeleteIndex.cs | 36 +- .../GetIndex/ElasticClient-GetIndex.cs | 40 +- .../GetIndex/GetIndexRequest.cs | 12 +- .../ElasticClient-IndexExists.cs | 42 +- .../IndicesExists/IndexExistsResponse.cs | 5 +- .../CloseIndex/CloseIndexResponse.cs | 8 +- .../CloseIndex/ElasticClient-CloseIndex.cs | 38 +- .../OpenIndex/ElasticClient-OpenIndex.cs | 31 +- .../OpenIndex/OpenIndexResponse.cs | 8 +- .../ElasticClient-RolloverIndex.cs | 27 +- .../RolloverIndex/RolloverConditions.cs | 15 +- .../RolloverIndex/RolloverIndexRequest.cs | 19 +- .../RolloverIndex/RolloverIndexResponse.cs | 27 +- .../ShrinkIndex/ElasticClient-ShrinkIndex.cs | 26 +- .../ShrinkIndex/ShrinkIndexRequest.cs | 21 +- .../ShrinkIndex/ShrinkIndexResponse.cs | 5 - .../SplitIndex/ElasticClient-SplitIndex.cs | 25 +- .../SplitIndex/SplitIndexRequest.cs | 34 +- .../SplitIndex/SplitIndexResponse.cs | 5 - .../TypesExists/ElasticClient-TypeExists.cs | 39 +- .../ElasticClient-GetIndexSettings.cs | 56 +- .../DeleteIndexTemplateResponse.cs | 8 +- .../ElasticClient-DeleteIndexTemplate.cs | 54 +- .../ElasticClient-GetIndexTemplate.cs | 62 +- .../GetIndexTemplate/TemplateMapping.cs | 21 +- .../ElasticClient-IndexTemplateExists.cs | 59 +- .../ElasticClient-PutIndexTemplate.cs | 56 +- .../PutIndexTemplateRequest.cs | 31 +- .../PutIndexTemplateResponse.cs | 8 +- .../ElasticClient-UpdateIndexSettings.cs | 53 +- .../UpdateIndexSettingsRequest.cs | 7 +- .../UpdateIndexSettingsResponse.cs | 8 +- .../ElasticClient-GetFieldMapping.cs | 50 +- .../FieldMappingJsonConverter.cs | 5 +- .../GetFieldMapping/GetFieldMappingRequest.cs | 2 +- .../GetFieldMappingResponse.cs | 29 +- .../GetMapping/ElasticClient-GetMapping.cs | 41 +- .../GetMapping/GetMappingRequest.cs | 2 +- .../GetMapping/GetMappingResponse.cs | 20 +- .../PutMapping/ElasticClient-Map.cs | 40 +- .../PutMapping/PutMappingRequest.cs | 149 ++-- .../PutMapping/PutMappingResponse.cs | 9 +- .../ElasticClient-RecoveryStatus.cs | 48 +- .../IndicesRecovery/RecoveryBytes.cs | 16 +- .../IndicesRecovery/RecoveryFileDetails.cs | 9 +- .../IndicesRecovery/RecoveryFiles.cs | 19 +- .../IndicesRecovery/RecoveryIndexStatus.cs | 7 +- .../IndicesRecovery/RecoveryOrigin.cs | 9 +- .../IndicesRecovery/RecoveryStartStatus.cs | 2 +- .../IndicesRecovery/RecoveryStatusResponse.cs | 1 - .../IndicesRecovery/RecoveryTranslogStatus.cs | 8 +- .../IndicesRecovery/ShardRecovery.cs | 32 +- .../IndicesSegments/ElasticClient-Segments.cs | 33 +- .../Monitoring/IndicesSegments/Segment.cs | 38 +- .../IndicesSegments/SegmentsResponse.cs | 9 +- .../IndicesSegments/ShardSegmentRouting.cs | 8 +- .../IndicesSegments/ShardsSegment.cs | 11 +- .../ElasticClient-IndicesShardStores.cs | 48 +- .../IndicesShardStoresRequest.cs | 10 +- .../IndicesShardStoresResponse.cs | 35 +- .../ShardStoreJsonConverter.cs | 10 +- .../ElasticClient-IndicesStats.cs | 36 +- .../Monitoring/IndicesStats/IndexStats.cs | 48 +- .../Monitoring/IndicesStats/IndicesStats.cs | 20 +- .../IndicesStats/IndicesStatsRequest.cs | 11 +- .../IndicesStats/IndicesStatsResponse.cs | 12 +- .../Monitoring/IndicesStats/ShardCommit.cs | 10 +- .../Monitoring/IndicesStats/ShardFieldData.cs | 5 +- .../IndicesStats/ShardFileSizeInfo.cs | 5 +- .../Monitoring/IndicesStats/ShardFlush.cs | 1 + .../Monitoring/IndicesStats/ShardGet.cs | 20 +- .../Monitoring/IndicesStats/ShardIndexing.cs | 42 +- .../Monitoring/IndicesStats/ShardMerges.cs | 17 +- .../Monitoring/IndicesStats/ShardPath.cs | 6 +- .../IndicesStats/ShardQueryCache.cs | 26 +- .../Monitoring/IndicesStats/ShardRefresh.cs | 6 +- .../IndicesStats/ShardRequestCache.cs | 7 +- .../Monitoring/IndicesStats/ShardRouting.cs | 10 +- .../IndicesStats/ShardRoutingState.cs | 2 +- .../Monitoring/IndicesStats/ShardSearch.cs | 48 +- .../Monitoring/IndicesStats/ShardSegments.cs | 44 +- .../IndicesStats/ShardSequenceNumber.cs | 10 +- .../Monitoring/IndicesStats/ShardStats.cs | 64 +- .../IndicesStats/ShardStatsRecovery.cs | 2 + .../IndicesStats/ShardTransactionLog.cs | 3 + .../Monitoring/IndicesStats/ShardWarmer.cs | 2 + .../ClearCache/ClearCacheRequest.cs | 2 +- .../ClearCache/ClearCacheResponse.cs | 8 +- .../ClearCache/ElasticClient-ClearCache.cs | 38 +- .../Flush/ElasticClient-Flush.cs | 39 +- .../StatusManagement/Flush/FlushResponse.cs | 10 +- .../ForceMerge/ElasticClient-ForceMerge.cs | 40 +- .../ForceMerge/ForceMergeResponse.cs | 8 +- .../Refresh/ElasticClient-Refresh.cs | 41 +- .../Refresh/RefreshResponse.cs | 8 +- .../SyncedFlush/ElasticClient-SyncedFlush.cs | 42 +- .../SyncedFlush/SyncedFlushRequest.cs | 2 +- .../SyncedFlush/SyncedFlushResponse.cs | 8 +- .../Upgrade/ElasticClient-Upgrade.cs | 30 +- .../ElasticClient-UpgradeStatus.cs | 44 +- .../Upgrade/UpgradeStatus/UpgradeStatus.cs | 6 +- .../UpgradeStatus/UpgradeStatusResponse.cs | 9 +- .../UpgradeStatusResponseJsonConverter.cs | 12 +- .../DeletePipeline/DeletePipelineResponse.cs | 8 +- .../ElasticClient-DeletePipeline.cs | 56 +- .../GetPipeline/ElasticClient-GetPipeline.cs | 45 +- .../Ingest/GetPipeline/GetPipelineResponse.cs | 7 +- src/Nest/Ingest/Pipeline.cs | 25 +- src/Nest/Ingest/PipelineJsonConverter.cs | 13 +- src/Nest/Ingest/Processor.cs | 16 +- .../ElasticClient-GrokProcessorPatterns.cs | 61 +- .../GrokProcessorPatternsResponse.cs | 3 +- src/Nest/Ingest/ProcessorJsonConverter.cs | 9 +- src/Nest/Ingest/Processors/AppendProcessor.cs | 8 +- src/Nest/Ingest/Processors/BytesProcessor.cs | 40 +- .../Ingest/Processors/ConvertProcessor.cs | 20 +- .../Processors/DateIndexNameProcessor.cs | 98 +- src/Nest/Ingest/Processors/DateProcessor.cs | 34 +- .../Ingest/Processors/DotExpanderProcessor.cs | 4 +- src/Nest/Ingest/Processors/FailProcessor.cs | 8 +- .../Ingest/Processors/ForeachProcessor.cs | 8 +- src/Nest/Ingest/Processors/GrokProcessor.cs | 26 +- src/Nest/Ingest/Processors/GsubProcessor.cs | 11 +- src/Nest/Ingest/Processors/JoinProcessor.cs | 11 +- src/Nest/Ingest/Processors/JsonProcessor.cs | 46 +- .../Ingest/Processors/KeyValueProcessor.cs | 101 ++- .../Ingest/Processors/LowercaseProcessor.cs | 6 +- .../Processors/Plugins/AttachmentProcessor.cs | 83 +- .../Processors/Plugins/GeoIpProcessor.cs | 39 +- .../Plugins/UserAgent/UserAgentProperty.cs | 20 +- .../Processors/Plugins/UserAgentProcessor.cs | 65 +- src/Nest/Ingest/Processors/RemoveProcessor.cs | 10 +- src/Nest/Ingest/Processors/RenameProcessor.cs | 7 +- src/Nest/Ingest/Processors/ScriptProcessor.cs | 63 +- src/Nest/Ingest/Processors/SetProcessor.cs | 5 +- src/Nest/Ingest/Processors/SortProcessor.cs | 7 +- src/Nest/Ingest/Processors/SplitProcessor.cs | 11 +- src/Nest/Ingest/Processors/TrimProcessor.cs | 10 +- .../Ingest/Processors/UppercaseProcessor.cs | 11 +- .../Ingest/Processors/UrlDecodeProcessor.cs | 44 +- src/Nest/Ingest/ProcessorsDescriptor.cs | 72 +- .../PutPipeline/ElasticClient-PutPipeline.cs | 36 +- .../Ingest/PutPipeline/PutPipelineRequest.cs | 15 +- .../Ingest/PutPipeline/PutPipelineResponse.cs | 8 +- .../ElasticClient-SimulatePipeline.cs | 49 +- .../SimulatePipelineDocument.cs | 37 +- .../SimulatePipelineRequest.cs | 14 +- .../SimulatePipelineResponse.cs | 27 +- .../ElasticsearchCorePropertyAttributeBase.cs | 22 +- ...ticsearchDocValuesPropertyAttributeBase.cs | 13 +- .../ElasticsearchPropertyAttributeBase.cs | 22 +- .../ElasticsearchTypeAttribute.cs | 3 +- src/Nest/Mapping/DynamicMapping.cs | 3 +- .../DynamicTemplate/DynamicTemplate.cs | 78 +- .../DynamicTemplateContainer.cs | 11 +- .../DynamicTemplatesJsonConverter.cs | 4 +- .../Mapping/DynamicTemplate/SingleMapping.cs | 186 ++-- src/Nest/Mapping/FieldIndexOption.cs | 2 + src/Nest/Mapping/Mappings.cs | 17 +- src/Nest/Mapping/MetaFields/All/AllField.cs | 57 +- .../MetaFields/FieldNames/FieldNamesField.cs | 2 +- .../MetaFields/Routing/RoutingField.cs | 2 +- .../Mapping/MetaFields/Source/SourceField.cs | 26 +- src/Nest/Mapping/PropertyMapping.cs | 6 +- src/Nest/Mapping/SimilarityOption.cs | 1 + src/Nest/Mapping/TermVectorOption.cs | 7 +- src/Nest/Mapping/TypeMapping.cs | 146 +-- .../Types/Complex/Nested/NestedAttribute.cs | 20 +- .../Types/Complex/Nested/NestedProperty.cs | 6 +- .../Types/Complex/Object/ObjectAttribute.cs | 16 +- .../Types/Complex/Object/ObjectProperty.cs | 17 +- .../Types/Core/Binary/BinaryProperty.cs | 4 +- .../Types/Core/Boolean/BooleanAttribute.cs | 29 +- .../Types/Core/Boolean/BooleanProperty.cs | 26 +- .../Mapping/Types/Core/Date/DateAttribute.cs | 47 +- .../Mapping/Types/Core/Date/DateProperty.cs | 93 +- src/Nest/Mapping/Types/Core/Join/Children.cs | 13 +- .../Types/Core/Join/ChildrenJsonConverter.cs | 4 +- .../Mapping/Types/Core/Join/JoinAttribute.cs | 20 +- src/Nest/Mapping/Types/Core/Join/JoinField.cs | 66 +- .../Types/Core/Join/JoinFieldJsonConverter.cs | 10 +- .../Mapping/Types/Core/Join/JoinProperty.cs | 4 - src/Nest/Mapping/Types/Core/Join/Relations.cs | 18 +- .../Types/Core/Keyword/KeywordAttribute.cs | 72 +- .../Types/Core/Keyword/KeywordProperty.cs | 59 +- .../Types/Core/Number/NumberAttribute.cs | 59 +- .../Types/Core/Number/NumberProperty.cs | 37 +- .../Mapping/Types/Core/Number/NumberType.cs | 8 +- .../Core/Percolator/PercolatorProperty.cs | 11 +- .../Range/DateRange/DateRangeAttribute.cs | 16 +- .../Core/Range/DateRange/DateRangeProperty.cs | 13 +- .../Range/DoubleRange/DoubleRangeAttribute.cs | 5 +- .../Range/DoubleRange/DoubleRangeProperty.cs | 6 +- .../Range/FloatRange/FloatRangeAttribute.cs | 5 +- .../Range/FloatRange/FloatRangeProperty.cs | 6 +- .../IntegerRange/IntegerRangeAttribute.cs | 5 +- .../IntegerRange/IntegerRangeProperty.cs | 6 +- .../Core/Range/Ip/IpAddressRangeProperty.cs | 2 - .../Types/Core/Range/Ip/IpRangeAttribute.cs | 5 +- .../Range/LongRange/LongRangeAttribute.cs | 5 +- .../Core/Range/LongRange/LongRangeProperty.cs | 2 - .../Core/Range/RangePropertyAttributeBase.cs | 31 +- .../Types/Core/Range/RangePropertyBase.cs | 36 +- .../Mapping/Types/Core/Range/RangeType.cs | 7 +- .../Mapping/Types/Core/Text/IndexOptions.cs | 9 +- .../Mapping/Types/Core/Text/TextAttribute.cs | 101 ++- .../Types/Core/Text/TextIndexPrefixes.cs | 10 +- .../Mapping/Types/Core/Text/TextProperty.cs | 64 +- src/Nest/Mapping/Types/CorePropertyBase.cs | 34 +- .../Types/CorePropertyDescriptorBase.cs | 27 +- .../Mapping/Types/DocValuesPropertyBase.cs | 6 +- .../Types/DocValuesPropertyDescriptorBase.cs | 21 +- src/Nest/Mapping/Types/FieldType.cs | 28 + .../Types/Geo/GeoPoint/GeoPointAttribute.cs | 23 +- .../Types/Geo/GeoPoint/GeoPointProperty.cs | 9 +- .../Types/Geo/GeoShape/GeoOrientation.cs | 1 + .../Types/Geo/GeoShape/GeoShapeAttribute.cs | 93 +- .../Types/Geo/GeoShape/GeoShapeProperty.cs | 164 ++-- .../Mapping/Types/Geo/GeoShape/GeoTree.cs | 1 + src/Nest/Mapping/Types/Properties-Scalar.cs | 329 +++++-- src/Nest/Mapping/Types/Properties.cs | 118 ++- .../Mapping/Types/PropertiesJsonConverter.cs | 7 +- src/Nest/Mapping/Types/PropertyBase.cs | 42 +- .../Mapping/Types/PropertyDescriptorBase.cs | 28 +- .../Specialized/Attachment/Attachment.cs | 71 +- .../Completion/CompletionAttribute.cs | 47 +- .../Completion/CompletionProperty.cs | 42 +- .../FieldAlias/FieldAliasProperty.cs | 5 +- .../Specialized/Generic/GenericProperty.cs | 88 +- .../Types/Specialized/Ip/IpAttribute.cs | 26 +- .../Types/Specialized/Ip/IpProperty.cs | 12 +- .../Murmur3Hash/Murmur3HashProperty.cs | 5 +- .../TokenCount/TokenCountAttribute.cs | 39 +- .../TokenCount/TokenCountProperty.cs | 17 +- src/Nest/Mapping/Visitor/IMappingVisitor.cs | 27 +- src/Nest/Mapping/Visitor/IPropertyVisitor.cs | 22 + src/Nest/Mapping/Visitor/MappingWalker.cs | 110 ++- .../Mapping/Visitor/NoopPropertyVisitor.cs | 92 +- src/Nest/Mapping/Visitor/PropertyWalker.cs | 11 +- .../Modules/Cluster/AllocationAttribute.cs | 12 +- .../AllocationAwarenessSettings.cs | 19 +- .../AllocationFilteringSettings.cs | 40 +- .../Modules/Cluster/ClusterModuleSettings.cs | 78 +- .../DiskbasedShardAllocationSettings.cs | 74 +- .../ShardAllocation/AllocationEnable.cs | 3 +- .../Cluster/ShardAllocation/AllowRebalance.cs | 3 +- .../ShardAllocation/RebalanceEnable.cs | 3 +- .../ShardAllocationSettings.cs | 29 +- .../ShardBalancingHeuristicsSettings.cs | 47 +- .../ShardRebalancingSettings.cs | 31 +- src/Nest/Modules/Gateway/GatewaySettings.cs | 19 +- .../CircuitBreaker/CircuitBreakerSettings.cs | 41 +- .../Indices/Fielddata/FielddataBase.cs | 6 +- .../Indices/Fielddata/FielddataFilter.cs | 6 +- .../Fielddata/FielddataFrequencyFilter.cs | 10 +- .../Indices/Fielddata/FielddataLoading.cs | 1 + .../Indices/Fielddata/FielddataSettings.cs | 14 +- .../Fielddata/GeoPoint/GeoPointFielddata.cs | 9 +- .../GeoPoint/GeoPointFielddataFormat.cs | 3 + .../Numeric/NumericFielddataFormat.cs | 1 + .../Fielddata/String/StringFielddataFormat.cs | 1 + .../IndexingBuffer/IndexingBufferSettings.cs | 27 +- .../Modules/Indices/IndicesModuleSettings.cs | 43 +- .../Recovery/IndicesRecoverySettings.cs | 72 +- .../DeleteScript/DeleteScriptRequest.cs | 2 +- .../DeleteScript/DeleteScriptResponse.cs | 8 +- .../ElasticClient-DeleteScript.cs | 48 +- .../ElasticClient-ExecutePainlessScript.cs | 57 +- .../ExecutePainlessScriptRequest.cs | 32 +- .../PainlessContextSetup.cs | 22 +- .../GetScript/ElasticClient-GetScript.cs | 39 +- .../Scripting/GetScript/GetScriptRequest.cs | 2 +- src/Nest/Modules/Scripting/IStoredScript.cs | 23 +- .../PutScript/ElasticClient-PutScript.cs | 32 +- .../Scripting/PutScript/PutScriptResponse.cs | 8 +- .../Repositories/AzureRepository.cs | 28 +- .../CreateRepositoryJsonConverter.cs | 5 +- .../CreateRepositoryRequest.cs | 7 +- .../CreateRepositoryResponse.cs | 8 +- .../ElasticClient-CreateRepository.cs | 57 +- .../DeleteRepositoryResponse.cs | 8 +- .../ElasticClient-DeleteRepository.cs | 65 +- .../Repositories/FileSystemRepository.cs | 36 +- .../ElasticClient-GetRepository.cs | 48 +- .../GetRepository/GetRepositoryResponse.cs | 15 +- .../GetRepositoryResponseJsonConverter.cs | 18 +- .../Repositories/HdfsRepository.cs | 59 +- .../Repositories/ISnapshotRepository.cs | 2 +- .../Repositories/ReadOnlyUrlRepository.cs | 27 +- .../Repositories/S3Repository.cs | 141 +-- .../ElasticClient-VerifyRepository.cs | 60 +- .../VerifyRepositoryResponse.cs | 1 - .../Restore/ElasticClient-Restore.cs | 39 +- .../ElasticClient-RestoreObservable.cs | 20 +- .../RestoreObservable/RestoreObservable.cs | 72 +- .../RestoreObservable/RestoreObserver.cs | 8 +- .../Restore/RestoreRequest.cs | 121 +-- .../Restore/SnapshotRestore.cs | 8 +- .../DeleteSnapshot/DeleteSnapshotResponse.cs | 8 +- .../ElasticClient-DeleteSnapshot.cs | 57 +- .../GetSapshot/ElasticClient-GetSnapshot.cs | 46 +- .../Snapshot/GetSapshot/GetSnapshotRequest.cs | 8 +- .../GetSapshot/GetSnapshotResponse.cs | 2 - .../SnapshotAndRestore/Snapshot/Snapshot.cs | 41 +- .../Snapshot/ElasticClient-Snapshot.cs | 42 +- .../Snapshot/Snapshot/SnapshotRequest.cs | 18 +- .../Snapshot/Snapshot/SnapshotResponse.cs | 9 +- .../ElasticClient-SnapshotObservable.cs | 21 +- .../SnapshotObservable/SnapshotObservable.cs | 67 +- .../SnapshotObservable/SnapshotObserver.cs | 8 +- .../Snapshot/SnapshotShardFailure.cs | 10 +- .../ElasticClient-SnapshotStatus.cs | 48 +- .../SnapshotStatus/SnapshotStatusResponse.cs | 68 +- src/Nest/Properties/ClsCompliancy.cs | 2 +- .../Abstractions/Container/IQueryContainer.cs | 173 ++-- .../Container/QueryContainer-Assignments.cs | 398 +++++++-- .../Container/QueryContainer-Dsl.cs | 49 +- .../Container/QueryContainerDescriptor.cs | 35 +- .../Container/QueryContainerJsonConverter.cs | 6 +- .../Abstractions/FieldLookup/FieldLookup.cs | 36 +- .../FieldName/FieldNameQueryDescriptorBase.cs | 4 +- .../FieldName/FieldNameQueryJsonConverter.cs | 7 +- .../Query/BoolQueryAndExtensions.cs | 44 +- .../Abstractions/Query/BoolQueryExtensions.cs | 32 +- .../Query/BoolQueryOrExtensions.cs | 13 +- .../QueryDsl/Abstractions/Query/QueryBase.cs | 50 +- .../Abstractions/Query/QueryDescriptorBase.cs | 25 +- src/Nest/QueryDsl/Compound/Bool/BoolQuery.cs | 155 ++-- .../Compound/Boosting/BoostingQuery.cs | 23 +- .../ConstantScore/ConstantScoreQuery.cs | 9 +- .../QueryDsl/Compound/Dismax/DismaxQuery.cs | 26 +- .../FunctionScore/FunctionScoreQuery.cs | 38 +- .../Functions/Decay/DecayFunctionBase.cs | 42 +- .../Decay/ExponentialDecayFunctionBase.cs | 8 +- .../Functions/Decay/GaussDecayFunctionBase.cs | 7 +- .../Decay/LinearDecayFunctionBase.cs | 8 +- .../Functions/Decay/MultiValueMode.cs | 7 +- .../FieldValue/FieldValueFactorFunction.cs | 27 +- .../FieldValue/FieldValueFactorModifier.cs | 11 +- .../Functions/FunctionBoostMode.cs | 7 +- .../Functions/FunctionScoreMode.cs | 7 +- .../FunctionScore/Functions/IScoreFunction.cs | 8 +- .../Functions/Random/RandomScoreFunction.cs | 20 +- .../Functions/ScoreFunctionJsonConverter.cs | 52 +- .../FunctionScore/Functions/ScoreFunctions.cs | 33 +- .../ScriptScore/ScriptScoreFunction.cs | 4 +- .../Functions/Weight/WeightFunction.cs | 10 +- .../FullText/CommonTerms/CommonTermsQuery.cs | 51 +- .../QueryDsl/FullText/Match/MatchQuery.cs | 135 +-- .../FullText/MatchPhrase/MatchPhraseQuery.cs | 12 +- .../MatchPhrasePrefixQuery.cs | 21 +- .../FullText/MultiMatch/MultiMatchQuery.cs | 262 +++--- .../FullText/MultiMatch/TextQueryType.cs | 22 +- .../FullText/MultiMatch/ZeroTermsQuery.cs | 3 +- .../FullText/QueryString/QueryStringQuery.cs | 320 ++++--- .../SimpleQueryStringFlags.cs | 16 +- .../SimpleQueryStringQuery.cs | 189 ++-- .../QueryDsl/Geo/BoundingBox/BoundingBox.cs | 16 +- .../Geo/BoundingBox/GeoBoundingBoxQuery.cs | 12 +- .../QueryDsl/Geo/BoundingBox/GeoExecution.cs | 1 + .../QueryDsl/Geo/Distance/GeoDistanceQuery.cs | 20 +- .../Geo/GeoCoordinateJsonConverter.cs | 2 + src/Nest/QueryDsl/Geo/GeoLocation.cs | 84 +- src/Nest/QueryDsl/Geo/GeoValidationMethod.cs | 4 +- src/Nest/QueryDsl/Geo/LatLon.cs | 2 +- .../QueryDsl/Geo/Polygon/GeoPolygonQuery.cs | 11 +- .../Geo/Shape/Circle/CircleGeoShape.cs | 5 +- .../Geo/Shape/Circle/GeoShapeCircleQuery.cs | 5 +- .../Geo/Shape/Envelope/EnvelopeGeoShape.cs | 2 +- .../Shape/Envelope/GeoShapeEnvelopeQuery.cs | 9 +- src/Nest/QueryDsl/Geo/Shape/GeoShapeBase.cs | 51 +- .../Geo/Shape/GeoShapeQueryJsonConverter.cs | 16 +- .../GeoShapeGeometryCollectionQuery.cs | 4 +- .../GeometryCollection/GeometryCollection.cs | 30 +- src/Nest/QueryDsl/Geo/Shape/IGeoShapeQuery.cs | 24 +- .../IndexedShape/GeoIndexedShapeQuery.cs | 6 +- .../LineString/GeoShapeLineStringQuery.cs | 9 +- .../Shape/LineString/LineStringGeoShape.cs | 7 +- .../GeoShapeMultiLineStringQuery.cs | 12 +- .../MultiLineStringGeoShape.cs | 5 +- .../MultiPoint/GeoShapeMultiPointQuery.cs | 9 +- .../Shape/MultiPoint/MultiPointGeoShape.cs | 7 +- .../MultiPolygon/GeoShapeMultiPolygonQuery.cs | 15 +- .../MultiPolygon/MultiPolygonGeoShape.cs | 7 +- .../Geo/Shape/Point/GeoShapePointQuery.cs | 6 +- .../QueryDsl/Geo/Shape/Point/PointGeoShape.cs | 7 +- .../Geo/Shape/Polygon/GeoShapePolygonQuery.cs | 9 +- .../Geo/Shape/Polygon/PolygonGeoShape.cs | 7 +- src/Nest/QueryDsl/Geo/WKT/GeoWKTException.cs | 10 +- src/Nest/QueryDsl/Geo/WKT/GeoWKTReader.cs | 89 +- src/Nest/QueryDsl/Geo/WKT/GeoWKTWriter.cs | 9 +- .../Joining/HasChild/ChildScoreMode.cs | 4 + .../Joining/HasChild/HasChildQuery.cs | 56 +- .../Joining/HasParent/HasParentQuery.cs | 54 +- .../QueryDsl/Joining/Nested/NestedQuery.cs | 37 +- .../Joining/Nested/NestedScoreMode.cs | 4 + .../Joining/ParentId/ParentIdQuery.cs | 38 +- src/Nest/QueryDsl/MatchAllQuery.cs | 4 +- src/Nest/QueryDsl/MatchNoneQuery.cs | 8 +- .../MultiTermQueryRewrite/RewriteMultiTerm.cs | 63 +- .../NestSpecific/ConditionlessQuery.cs | 20 +- src/Nest/QueryDsl/NestSpecific/RawQuery.cs | 27 +- src/Nest/QueryDsl/Operator.cs | 1 + src/Nest/QueryDsl/Query.cs | 22 +- .../Span/Containing/SpanContainingQuery.cs | 23 +- .../FieldMasking/SpanFieldMaskingQuery.cs | 13 +- .../QueryDsl/Span/First/SpanFirstQuery.cs | 15 +- src/Nest/QueryDsl/Span/Gap/SpanGapQuery.cs | 13 +- src/Nest/QueryDsl/Span/ISpanSubQuery.cs | 4 +- .../Span/MultiTerm/SpanMultiTermQuery.cs | 7 +- src/Nest/QueryDsl/Span/Near/SpanNearQuery.cs | 22 +- src/Nest/QueryDsl/Span/Not/SpanNotQuery.cs | 38 +- src/Nest/QueryDsl/Span/Or/SpanOrQuery.cs | 8 +- src/Nest/QueryDsl/Span/SpanQuery.cs | 78 +- src/Nest/QueryDsl/Span/Term/SpanTermQuery.cs | 10 +- .../QueryDsl/Span/Within/SpanWithinQuery.cs | 23 +- .../Specialized/MoreLikeThis/Like/Like.cs | 15 +- .../MoreLikeThis/Like/LikeDocument.cs | 84 +- .../MoreLikeThis/MoreLikeThisQuery.cs | 116 +-- .../Specialized/Percolate/PercolateQuery.cs | 143 +-- .../Specialized/Script/ScriptQuery.cs | 52 +- .../Script/ScriptQueryConverter.cs | 3 +- .../QueryDsl/TermLevel/Exists/ExistsQuery.cs | 7 +- .../QueryDsl/TermLevel/Fuzzy/FuzzyQueries.cs | 27 +- .../TermLevel/Fuzzy/FuzzyQueryBase.cs | 36 +- .../Fuzzy/FuzzyQueryJsonConverter.cs | 12 +- src/Nest/QueryDsl/TermLevel/Ids/IdsQuery.cs | 17 +- .../QueryDsl/TermLevel/Prefix/PrefixQuery.cs | 16 +- .../TermLevel/Range/DateRangeQuery .cs | 60 +- .../TermLevel/Range/LongRangeQuery.cs | 35 +- .../TermLevel/Range/NumericRangeQuery.cs | 39 +- .../QueryDsl/TermLevel/Range/RangeQuery.cs | 2 +- .../Range/RangeQueryJsonConverter.cs | 6 +- .../QueryDsl/TermLevel/Range/RangeRelation.cs | 6 +- .../TermLevel/Range/TermRangeQuery.cs | 107 ++- .../QueryDsl/TermLevel/Regexp/RegexpQuery.cs | 17 +- src/Nest/QueryDsl/TermLevel/Term/TermQuery.cs | 14 +- .../QueryDsl/TermLevel/Terms/TermsQuery.cs | 41 +- .../Terms/TermsQueryJsonConverter.cs | 3 +- .../TermLevel/TermsSet/TermsSetQuery.cs | 47 +- src/Nest/QueryDsl/TermLevel/Type/TypeQuery.cs | 5 +- .../TermLevel/Wildcard/WildcardQuery.cs | 16 +- src/Nest/QueryDsl/VariableFields.cs | 29 +- .../QueryDsl/Visitor/DslPrettyPrintVisitor.cs | 85 +- src/Nest/QueryDsl/Visitor/QueryVisitor.cs | 67 +- src/Nest/QueryDsl/Visitor/QueryWalker.cs | 4 + src/Nest/QueryDsl/Visitor/VisitorScope.cs | 1 - src/Nest/Search/Count/CountRequest.cs | 31 +- src/Nest/Search/Count/ElasticClient-Count.cs | 45 +- src/Nest/Search/CovariantSearch.cs | 1 - .../Search/Explain/ElasticClient-Explain.cs | 56 +- src/Nest/Search/Explain/ExplainGet.cs | 10 +- src/Nest/Search/Explain/ExplainRequest.cs | 19 +- src/Nest/Search/Explain/ExplainResponse.cs | 11 +- src/Nest/Search/Explain/Explanation.cs | 5 +- src/Nest/Search/Explain/ExplanationDetail.cs | 6 +- .../ElasticClient-FieldCapabilities.cs | 61 +- .../FieldCapabilitiesRequest.cs | 5 +- .../FieldCapabilitiesResponse.cs | 87 +- .../MultiSearch/ElasticClient-MultiSearch.cs | 68 +- .../MultiSearch/IMultiSearchResponse.cs | 11 +- .../MultiSearch/MultiSearchJsonConverter.cs | 14 +- .../Search/MultiSearch/MultiSearchRequest.cs | 18 +- .../Search/MultiSearch/MultiSearchResponse.cs | 51 +- .../MultiSearchResponseJsonConverter.cs | 82 +- .../ElasticClient-MultiSearchTemplate.cs | 72 +- .../MultiSearchTemplateJsonConverter.cs | 25 +- .../MultiSearchTemplateRequest.cs | 24 +- .../Scroll/ClearScroll/ClearScrollRequest.cs | 16 +- .../ClearScroll/ElasticClient-ClearScroll.cs | 43 +- .../Scroll/Scroll/ElasticClient-Scroll.cs | 57 +- .../Search/Scroll/Scroll/ScrollRequest.cs | 17 +- src/Nest/Search/Scroll/Scroll/SlicedScroll.cs | 12 +- .../Search/Search/Collapsing/FieldCollapse.cs | 20 +- .../Search/Search/ElasticClient-Search.cs | 90 +- .../Search/Highlighting/BoundaryScanner.cs | 2 + .../Search/Search/Highlighting/Highlight.cs | 216 ++--- .../HighlightDocumentDictionary.cs | 6 +- .../Search/Highlighting/HighlightField.cs | 342 +++---- .../Search/Highlighting/HighlightHit.cs | 1 + .../Search/Highlighting/HighlighterEncoder.cs | 1 + .../Highlighting/HighlighterFragmenter.cs | 1 + .../Search/Highlighting/HighlighterOrder.cs | 2 +- src/Nest/Search/Search/Hits/Hit.cs | 99 ++- src/Nest/Search/Search/Hits/HitsMetaData.cs | 10 +- .../Search/Search/Hits/InnerHitsMetaData.cs | 13 +- .../Search/Search/Hits/InnerHitsResult.cs | 4 +- src/Nest/Search/Search/Hits/NestedIdentity.cs | 8 +- src/Nest/Search/Search/InnerHits/InnerHits.cs | 92 +- .../Search/Profile/AggregationBreakdown.cs | 19 +- .../Search/Profile/AggregationProfile.cs | 13 +- src/Nest/Search/Search/Profile/Collector.cs | 10 +- src/Nest/Search/Search/Profile/Profile.cs | 1 - .../Search/Search/Profile/QueryBreakdown.cs | 20 +- .../Search/Search/Profile/QueryProfile.cs | 24 +- .../Search/Search/Profile/SearchProfile.cs | 10 +- .../Search/Search/Profile/ShardProfile.cs | 8 +- src/Nest/Search/Search/Rescoring/Rescore.cs | 14 +- .../Search/Search/Rescoring/RescoreQuery.cs | 7 +- src/Nest/Search/Search/Rescoring/ScoreMode.cs | 20 +- src/Nest/Search/Search/SearchRequest.cs | 281 +++--- src/Nest/Search/Search/SearchResponse.cs | 169 ++-- src/Nest/Search/Search/Sort/NestedSort.cs | 10 +- src/Nest/Search/Search/Sort/SortBase.cs | 75 +- src/Nest/Search/Search/Sort/SortDescriptor.cs | 25 +- src/Nest/Search/Search/Sort/SortField.cs | 9 +- .../Search/Search/Sort/SortGeoDistance.cs | 47 +- src/Nest/Search/Search/Sort/SortMode.cs | 4 + src/Nest/Search/Search/Sort/SortOrder.cs | 3 +- src/Nest/Search/Search/Sort/SortScript.cs | 16 +- .../Search/Search/Sort/SortSpecialField.cs | 3 +- .../Search/SourceFiltering/SourceFilter.cs | 19 +- .../SourceFilterJsonConverter.cs | 9 +- .../ElasticClient-SearchShards.cs | 44 +- .../SearchShards/SearchShardsRequest.cs | 2 + .../SearchShards/SearchShardsResponse.cs | 25 +- .../ElasticClient-SearchTemplate.cs | 71 +- .../ElasticClient-RenderSearchTemplate.cs | 48 +- .../RenderSearchTemplateRequest.cs | 33 +- .../SearchTemplate/SearchTemplateRequest.cs | 65 +- src/Nest/Search/Suggesters/BaseSuggest.cs | 13 +- .../CompletionSuggester/CompletionField.cs | 6 +- .../CompletionSuggester.cs | 38 +- .../CompletionSuggester/FuzzySuggest.cs | 18 +- .../CategorySuggestContext.cs | 6 +- .../Suggesters/ContextSuggester/Context.cs | 23 +- .../ContextSuggester/GeoSuggestContext.cs | 17 +- .../ContextSuggester/ISuggestContext.cs | 13 +- .../SuggestContextJsonConverter.cs | 28 +- .../ContextSuggester/SuggestContextQuery.cs | 26 +- .../SuggestContextsDescriptor.cs | 4 +- .../PhraseSuggester/DirectGenerator.cs | 59 +- .../PhraseSuggester/PhraseSuggestCollate.cs | 22 +- .../PhraseSuggestCollateQuery.cs | 22 +- .../PhraseSuggester/PhraseSuggestHighlight.cs | 12 +- .../PhraseSuggester/PhraseSuggester.cs | 76 +- .../SmoothingModel/LaplaceSmoothingModel.cs | 3 +- .../LinearInterpolationSmoothingModel.cs | 16 +- .../SmoothingModel/SmoothingModelBase.cs | 2 +- .../SmoothingModel/SmoothingModelContainer.cs | 15 +- .../StupidBackoffSmoothingModel.cs | 6 +- src/Nest/Search/Suggesters/Suggest.cs | 7 +- src/Nest/Search/Suggesters/SuggestBucket.cs | 23 +- .../Search/Suggesters/SuggestContainer.cs | 32 +- .../Search/Suggesters/SuggestDictionary.cs | 5 +- src/Nest/Search/Suggesters/SuggestOption.cs | 68 +- .../TermSuggester/StringDistance.cs | 21 +- .../Suggesters/TermSuggester/SuggestSort.cs | 10 +- .../Suggesters/TermSuggester/TermSuggester.cs | 80 +- .../Validate/ElasticClient-ValidateQuery.cs | 49 +- .../Search/Validate/ValidateQueryRequest.cs | 3 +- .../Search/Validate/ValidateQueryResponse.cs | 17 +- .../Search/Validate/ValidationExplanation.cs | 12 +- .../Explore/ElasticClient-GraphExplore.cs | 44 +- .../Graph/Explore/GraphExploreRequest.cs | 20 +- .../Graph/Explore/GraphExploreResponse.cs | 22 +- .../Explore/Request/GraphExploreControls.cs | 24 +- .../Explore/Request/GraphVertexDefinition.cs | 43 +- .../Explore/Request/GraphVertexInclude.cs | 14 +- src/Nest/XPack/Graph/Explore/Request/Hop.cs | 13 +- .../Graph/Explore/Response/GraphConnection.cs | 1 - .../Graph/Explore/Response/GraphVertex.cs | 1 - .../Info/XPackInfo/ElasticClient-XPackInfo.cs | 38 +- .../XPack/Info/XPackInfo/XPackInfoRequest.cs | 6 +- .../XPack/Info/XPackInfo/XPackInfoResponse.cs | 48 +- .../XPackUsage/ElasticClient-XPackUsage.cs | 41 +- .../Info/XPackUsage/XPackUsageRequest.cs | 6 +- .../Info/XPackUsage/XPackUsageResponse.cs | 80 +- .../DeleteLicense/DeleteLicenseRequest.cs | 19 +- .../DeleteLicense/DeleteLicenseResponse.cs | 5 +- .../ElasticClient-DeleteLicense.cs | 48 +- .../GetLicense/ElasticClient-GetLicense.cs | 41 +- .../License/GetLicense/GetLicenseRequest.cs | 19 +- .../License/GetLicense/GetLicenseResponse.cs | 68 +- .../XPack/License/GetLicense/LicenseStatus.cs | 9 +- .../XPack/License/GetLicense/LicenseType.cs | 23 +- .../ElasticClient-GetTrialLicenseStatus.cs | 52 +- .../GetTrialLicenseStatusRequest.cs | 19 +- .../PostLicense/ElasticClient-PostLicense.cs | 44 +- .../PostLicense/LicenseAcknowledgement.cs | 5 +- .../License/PostLicense/PostLicenseRequest.cs | 5 +- .../PostLicense/PostLicenseResponse.cs | 21 +- .../ElasticClient-StartTrialLicense.cs | 45 +- .../StartTrialLicenseRequest.cs | 19 +- .../StartTrialLicenseResponse.cs | 9 +- .../CloseJob/CloseJobRequest.cs | 6 +- .../CloseJob/ElasticClient-CloseJob.cs | 34 +- .../Datafeed/ChunkingConfig.cs | 2 +- .../Datafeed/DatafeedConfig.cs | 16 +- .../MachineLearning/Datafeed/DatafeedState.cs | 5 +- .../MachineLearning/Datafeed/DatafeedStats.cs | 12 +- .../MachineLearning/Datafeed/DiscoveryNode.cs | 26 +- .../DeleteDatafeed/DeleteDatafeedRequest.cs | 6 +- .../DeleteDatafeed/DeleteDatafeedResponse.cs | 4 +- .../ElasticClient-DeleteDatafeed.cs | 44 +- .../DeleteExpiredDataRequest.cs | 6 +- .../ElasticClient-DeleteExpiredData.cs | 51 +- .../DeleteJob/DeleteJobRequest.cs | 6 +- .../DeleteJob/DeleteJobResponse.cs | 4 +- .../DeleteJob/ElasticClient-DeleteJob.cs | 34 +- .../DeleteModelSnapshotRequest.cs | 6 +- .../DeleteModelSnapshotResponse.cs | 4 +- .../ElasticClient-DeleteModelSnapshot.cs | 60 +- .../FlushJob/ElasticClient-FlushJob.cs | 34 +- .../FlushJob/FlushJobRequest.cs | 7 +- .../ForecastJob/ElasticClient-ForecastJob.cs | 34 +- .../ForecastJob/ForecastJobRequest.cs | 3 +- .../ForecastJob/ForecastJobResponse.cs | 3 +- .../ElasticClient-GetAnomalyRecords.cs | 53 +- .../GetAnomalyRecordsRequest.cs | 20 +- .../GetBuckets/ElasticClient-GetBuckets.cs | 37 +- .../GetBuckets/GetBucketsRequest.cs | 8 + .../GetBuckets/GetBucketsResponse.cs | 9 +- .../ElasticClient-GetCategories.cs | 44 +- .../GetCategories/GetCategoriesResponse.cs | 9 +- .../ElasticClient-GetDatafeedStats.cs | 51 +- .../GetDatafeedStatsRequest.cs | 6 +- .../GetDatafeedStatsResponse.cs | 1 - .../ElasticClient-GetDatafeeds.cs | 40 +- .../GetDatafeeds/GetDatafeedsRequest.cs | 6 +- .../ElasticClient-GetInfluencers.cs | 44 +- .../GetInfluencers/GetInfluencersRequest.cs | 4 +- .../GetJobStats/ElasticClient-GetJobStats.cs | 40 +- .../GetJobStats/GetJobStatsRequest.cs | 6 +- .../GetJobs/ElasticClient-GetJobs.cs | 34 +- .../MachineLearning/GetJobs/GetJobsRequest.cs | 6 +- .../ElasticClient-GetModelSnapshots.cs | 53 +- .../GetModelSnapshotsResponse.cs | 2 +- .../ElasticClient-GetOverallBuckets.cs | 45 +- .../GetOverallBucketsRequest.cs | 10 +- .../Job/Config/AnalysisConfig.cs | 16 +- .../Job/Config/AnalysisLimits.cs | 1 + .../Job/Config/DataDescription.cs | 2 + .../XPack/MachineLearning/Job/Config/Job.cs | 92 +- .../MachineLearning/Job/Config/JobState.cs | 4 + .../MachineLearning/Job/Config/JobStats.cs | 24 +- .../Job/Config/MemoryStatus.cs | 2 +- .../Job/Config/ModelPlotConfig.cs | 4 +- .../Job/Detectors/CountDetector.cs | 93 +- .../MachineLearning/Job/Detectors/Detector.cs | 26 +- .../Job/Detectors/GeographicDetector.cs | 29 +- .../Job/Detectors/InfoContentDetector.cs | 32 +- .../Job/Detectors/MetricDetector.cs | 44 +- .../Job/Detectors/RareDetector.cs | 21 +- .../Job/Detectors/SumDetector.cs | 57 +- .../Job/Detectors/TimeDetector.cs | 19 +- .../MachineLearning/Job/Process/DataCounts.cs | 117 ++- .../Job/Process/ModelSizeStats.cs | 60 +- .../Job/Process/ModelSnapshot.cs | 60 +- .../Job/Results/AnomalyCause.cs | 50 +- .../Job/Results/AnomalyRecord.cs | 166 ++-- .../MachineLearning/Job/Results/Bucket.cs | 58 +- .../Job/Results/BucketInfluencer.cs | 46 +- .../Job/Results/CategoryDefinition.cs | 33 +- .../Job/Results/OverallBucket.cs | 26 +- .../Job/Results/PartitionScore.cs | 23 +- .../OpenJob/ElasticClient-OpenJob.cs | 34 +- .../PostJobData/ElasticClient-PostJobData.cs | 40 +- .../PostJobData/PostJobDataRequest.cs | 6 +- .../PostJobData/PostJobDataResponse.cs | 110 +-- .../ElasticClient-PreviewDatafeed.cs | 58 +- .../PreviewDatafeed/PreviewDatafeedRequest.cs | 6 +- .../PutDatafeed/ElasticClient-PutDatafeed.cs | 43 +- .../PutDatafeed/PutDatafeedRequest.cs | 15 +- .../PutDatafeed/PutDatafeedResponse.cs | 34 +- .../PutJob/ElasticClient-PutJob.cs | 34 +- .../MachineLearning/PutJob/PutJobRequest.cs | 11 +- .../MachineLearning/PutJob/PutJobResponse.cs | 102 +-- .../ElasticClient-RevertModelSnapshot.cs | 60 +- .../ElasticClient-StartDatafeed.cs | 47 +- .../StartDatafeed/StartDatafeedRequest.cs | 22 +- .../ElasticClient-StopDatafeed.cs | 43 +- .../StopDatafeed/StopDatafeedRequest.cs | 18 +- .../ElasticClient-UpdateDatafeed.cs | 51 +- .../UpdateDataFeed/UpdateDatafeedRequest.cs | 4 +- .../UpdateDataFeed/UpdateDatafeedResponse.cs | 18 +- .../UpdateJob/ElasticClient-UpdateJob.cs | 34 +- .../UpdateJob/UpdateJobRequest.cs | 14 +- .../UpdateJob/UpdateJobResponse.cs | 8 +- .../ElasticClient-UpdateModelSnapshot.cs | 60 +- .../ElasticClient-ValidateDetector.cs | 54 +- .../ValidateDetectorResponse.cs | 8 +- .../ValidateJob/ElasticClient-ValidateJob.cs | 40 +- .../ValidateJob/ValidateJobRequest.cs | 15 +- .../ValidateJob/ValidateJobResponse.cs | 4 +- .../DeprecationInfoResponse.cs | 27 +- .../ElasticClient-DeprecationInfo.cs | 38 +- .../ElasticClient-MigrationAssistance.cs | 47 +- .../MigrationAssistanceResponse.cs | 6 +- .../ElasticClient-MigrationUpgrade.cs | 50 +- .../MigrationUpgradeResponse.cs | 72 +- .../CreateRollupJob/CreateRollupJobRequest.cs | 58 +- .../CreateRollupJobResponse.cs | 4 +- .../ElasticClient-CreateRollupJob.cs | 31 +- .../DeleteRollupJob/DeleteRollupJobRequest.cs | 12 +- .../DeleteRollupJobResponse.cs | 4 +- .../ElasticClient-DeleteRollupJob.cs | 27 +- .../ElasticClient-GetRollupCapabilities.cs | 56 +- .../GetRollupCapabilitiesRequest.cs | 12 +- .../GetRollupCapabilitiesResponse.cs | 29 +- .../ElasticClient-GetRollupJob.cs | 44 +- .../GetRollupJob/GetRollupJobRequest.cs | 12 +- .../GetRollupJob/GetRollupJobResponse.cs | 1 - .../RollUp/GetRollupJob/IndexingJobState.cs | 12 +- .../GetRollupJob/RollupJobConfiguration.cs | 33 +- .../GetRollupJob/RollupJobInformation.cs | 6 +- .../RollUp/GetRollupJob/RollupJobStats.cs | 8 +- .../RollUp/GetRollupJob/RollupJobStatus.cs | 6 +- .../DateHistogramRollupGrouping.cs | 32 +- .../HistogramRollupGrouping.cs | 8 +- .../RollupConfiguration/IRollupGroupings.cs | 21 +- .../RollupConfiguration/RollupFieldMetric.cs | 9 +- .../TermsRollupGrouping.cs | 6 +- .../ElasticClient-RollupSearch.cs | 54 +- .../RollupSearch/RollupSearchRequest.cs | 20 +- .../RollupSearch/RollupSearchResponse.cs | 12 +- .../ElasticClient-StartRollupJob.cs | 36 +- .../StartRollupJob/StartRollupJobRequest.cs | 12 +- .../ElasticClient-StopRollupJob.cs | 33 +- .../StopRollupJob/StopRollupJobRequest.cs | 17 +- .../Authenticate/AuthenticateRequest.cs | 18 +- .../Authenticate/AuthenticateResponse.cs | 26 +- .../ElasticClient-Authenticate.cs | 44 +- .../ClearCachedRealmsRequest.cs | 6 +- .../ClearCachedRealmsResponse.cs | 6 +- .../ElasticClient-ClearCachedRealms.cs | 60 +- .../ClearCachedRolesRequest.cs | 18 +- .../ClearCachedRolesResponse.cs | 6 +- .../ElasticClient-ClearCachedRoles.cs | 56 +- .../Role/DeleteRole/DeleteRoleRequest.cs | 18 +- .../Role/DeleteRole/DeleteRoleResponse.cs | 5 +- .../DeleteRole/ElasticClient-DeleteRole.cs | 41 +- src/Nest/XPack/Security/Role/FieldSecurity.cs | 18 +- .../Role/GetRole/ElasticClient-GetRole.cs | 38 +- .../Security/Role/GetRole/GetRoleRequest.cs | 18 +- .../Security/Role/GetRole/GetRoleResponse.cs | 4 +- src/Nest/XPack/Security/Role/GetRole/Role.cs | 6 +- .../Role/PutRole/ElasticClient-PutRole.cs | 38 +- .../Role/PutRole/IApplicationPrivileges.cs | 13 +- .../Role/PutRole/IndicesPrivileges.cs | 21 +- .../Security/Role/PutRole/PutRoleRequest.cs | 78 +- .../Security/Role/PutRole/PutRoleResponse.cs | 5 +- .../DeleteRoleMappingRequest.cs | 19 +- .../DeleteRoleMappingResponse.cs | 6 +- .../ElasticClient-DeleteRoleMapping.cs | 60 +- .../ElasticClient-GetRoleMapping.cs | 48 +- .../GetRoleMapping/GetRoleMappingRequest.cs | 19 +- .../GetRoleMapping/GetRoleMappingResponse.cs | 11 +- .../ElasticClient-PutRoleMapping.cs | 48 +- .../PutRoleMapping/PutRoleMappingRequest.cs | 43 +- .../PutRoleMapping/PutRoleMappingResponse.cs | 9 +- .../Rules/Field/DistinguishedNameRule.cs | 5 +- .../RoleMapping/Rules/Field/FieldRuleBase.cs | 33 +- .../Rules/Field/FieldRuleBaseJsonConverter.cs | 15 +- .../RoleMapping/Rules/Field/GroupsRule.cs | 11 +- .../RoleMapping/Rules/Field/MetadataRule.cs | 6 +- .../RoleMapping/Rules/Field/RealmRule.cs | 9 +- .../RoleMapping/Rules/Field/UsernameRule.cs | 5 +- .../Rules/Role/AllRoleMappingRule.cs | 14 +- .../Rules/Role/AnyRoleMappingRule.cs | 14 +- .../Rules/Role/ExceptRoleMappingRole.cs | 8 +- .../Rules/Role/FieldRoleMappingRule.cs | 7 +- .../Rules/Role/RoleMappingRuleBase.cs | 20 +- .../Role/RoleMappingRuleBaseJsonConverter.cs | 14 +- .../Rules/Role/RoleMappingRuleDescriptor.cs | 1 - .../Rules/Role/RoleMappingRulesDescriptor.cs | 10 +- src/Nest/XPack/Security/SecurityNode.cs | 2 +- .../ChangePassword/ChangePasswordRequest.cs | 7 +- .../ElasticClient-ChangePassword.cs | 51 +- .../User/DeleteUser/DeleteUserRequest.cs | 18 +- .../User/DeleteUser/DeleteUserResponse.cs | 5 +- .../DeleteUser/ElasticClient-DeleteUser.cs | 41 +- .../User/DisableUser/DisableUserRequest.cs | 8 +- .../DisableUser/ElasticClient-DisableUser.cs | 44 +- .../EnableUser/ElasticClient-EnableUser.cs | 41 +- .../User/EnableUser/EnableUserRequest.cs | 8 +- .../User/GetUser/ElasticClient-GetUser.cs | 38 +- .../Security/User/GetUser/GetUserRequest.cs | 18 +- .../Security/User/GetUser/GetUserResponse.cs | 20 +- .../ElasticClient-GetUserAccessToken.cs | 64 +- .../GetUserAccessTokenRequest.cs | 45 +- .../GetUserAccessTokenResponse.cs | 14 +- ...ElasticClient-InvalidateUserAccessToken.cs | 64 +- .../InvalidateUserAccessTokenRequest.cs | 19 +- .../InvalidateUserAccessTokenResponse.cs | 5 +- .../User/PutUser/ElasticClient-PutUser.cs | 38 +- .../Security/User/PutUser/PutUserRequest.cs | 34 +- .../Security/User/PutUser/PutUserResponse.cs | 5 +- .../ClearSqlCursor/ClearSqlCursorRequest.cs | 9 +- .../ClearSqlCursor/ClearSqlCursorResponse.cs | 4 +- .../ElasticClient-ClearSqlCursor.cs | 48 +- src/Nest/XPack/Sql/ISqlRequest.cs | 22 +- .../Sql/QuerySql/ElasticClient-QuerySql.cs | 36 +- .../XPack/Sql/QuerySql/QuerySqlRequest.cs | 53 +- .../XPack/Sql/QuerySql/QuerySqlResponse.cs | 22 +- src/Nest/XPack/Sql/QuerySql/SqlColumn.cs | 3 +- src/Nest/XPack/Sql/QuerySql/SqlValue.cs | 1 - .../ElasticClient-TranslateSql.cs | 49 +- .../Sql/TranslateSql/TranslateSqlRequest.cs | 36 +- .../AcknowledgeWatchRequest.cs | 6 +- .../AcknowledgeWatchResponse.cs | 38 +- .../ElasticClient-AcknowledgeWatch.cs | 52 +- src/Nest/XPack/Watcher/Action/ActionBase.cs | 37 +- src/Nest/XPack/Watcher/Action/ActionType.cs | 4 +- src/Nest/XPack/Watcher/Action/Actions.cs | 16 +- .../Watcher/Action/ActionsDescriptorBase.cs | 17 +- .../Watcher/Action/Email/DataAttachment.cs | 1 + .../XPack/Watcher/Action/Email/EmailAction.cs | 67 +- .../Watcher/Action/Email/EmailAttachments.cs | 17 +- .../XPack/Watcher/Action/Email/EmailBody.cs | 11 +- .../Watcher/Action/Email/EmailPriority.cs | 6 +- .../Watcher/Action/HipChat/HipChatAction.cs | 12 +- .../Watcher/Action/HipChat/HipChatMessage.cs | 20 +- .../XPack/Watcher/Action/Index/IndexAction.cs | 23 +- .../Watcher/Action/Logging/LoggingAction.cs | 18 +- .../Action/PagerDuty/PagerDutyAction.cs | 35 +- .../Action/PagerDuty/PagerDutyContext.cs | 24 +- .../Action/PagerDuty/PagerDutyEvent.cs | 36 +- .../XPack/Watcher/Action/Slack/SlackAction.cs | 15 +- .../Watcher/Action/Slack/SlackAttachment.cs | 97 +- .../Action/Slack/SlackAttachmentField.cs | 14 +- .../Action/Slack/SlackDynamicAttachment.cs | 11 +- .../Watcher/Action/Slack/SlackMessage.cs | 31 +- .../Watcher/Action/Webhook/WebhookAction.cs | 50 +- .../ActivateWatch/ActivateWatchRequest.cs | 6 +- .../ActivateWatch/ActivateWatchResponse.cs | 6 +- .../ElasticClient-ActivateWatch.cs | 44 +- .../Watcher/Condition/AlwaysCondition.cs | 2 +- .../Condition/ArrayCompareConditionBase.cs | 50 +- .../Watcher/Condition/CompareConditionBase.cs | 44 +- .../XPack/Watcher/Condition/ConditionBase.cs | 2 +- .../Watcher/Condition/ConditionContainer.cs | 50 +- .../XPack/Watcher/Condition/ConditionType.cs | 14 +- .../Condition/IndexedScriptCondition.cs | 14 +- .../Condition/InlineScriptCondition.cs | 26 +- .../XPack/Watcher/Condition/NeverCondition.cs | 2 +- .../Watcher/Condition/ScriptConditionBase.cs | 10 +- .../DeactivateWatch/DeactivateWatchRequest.cs | 6 +- .../ElasticClient-DeactivateWatch.cs | 44 +- .../Watcher/DeleteWatch/DeleteWatchRequest.cs | 6 +- .../DeleteWatch/DeleteWatchResponse.cs | 8 +- .../DeleteWatch/ElasticClient-DeleteWatch.cs | 40 +- .../ElasticClient-ExecuteWatch.cs | 40 +- .../ExecuteWatch/ExecuteWatchRequest.cs | 63 +- .../ExecuteWatch/ExecuteWatchResponse.cs | 107 +-- .../Watcher/Execution/ActionExecutionMode.cs | 4 +- .../Execution/Email/EmailActionResult.cs | 6 +- .../Watcher/Execution/Email/EmailResult.cs | 32 +- .../HipChat/HipChatActionMessageResult.cs | 10 +- .../Execution/HipChat/HipChatActionResult.cs | 2 +- .../Execution/HttpInputRequestResult.cs | 2 +- .../Execution/HttpInputResponseResult.cs | 8 +- .../Index/IndexActionResultIndexResponse.cs | 18 +- .../Execution/Logging/LoggingActionResult.cs | 2 +- .../PagerDuty/PagerDutyActionResult.cs | 2 +- .../Watcher/Execution/SimulatedActions.cs | 11 +- .../Slack/SlackActionMessageResult.cs | 10 +- src/Nest/XPack/Watcher/Execution/Status.cs | 2 +- .../GetWatch/ElasticClient-GetWatch.cs | 34 +- .../XPack/Watcher/GetWatch/GetWatchRequest.cs | 6 +- src/Nest/XPack/Watcher/Input/ChainInput.cs | 14 +- .../XPack/Watcher/Input/ConnectionScheme.cs | 3 +- src/Nest/XPack/Watcher/Input/HttpInput.cs | 2 +- .../Watcher/Input/HttpInputAuthentication.cs | 19 +- .../XPack/Watcher/Input/HttpInputRequest.cs | 128 +-- src/Nest/XPack/Watcher/Input/HttpMethod.cs | 4 + .../XPack/Watcher/Input/IndicesOptions.cs | 11 +- src/Nest/XPack/Watcher/Input/InputBase.cs | 2 +- .../XPack/Watcher/Input/InputContainer.cs | 18 +- src/Nest/XPack/Watcher/Input/InputType.cs | 2 + .../Watcher/Input/ResponseContentType.cs | 4 +- src/Nest/XPack/Watcher/Input/SearchInput.cs | 12 +- .../XPack/Watcher/Input/SearchInputRequest.cs | 38 +- src/Nest/XPack/Watcher/Input/SimpleInput.cs | 51 +- .../PutWatch/ElasticClient-PutWatch.cs | 34 +- .../XPack/Watcher/PutWatch/PutWatchRequest.cs | 72 +- .../Watcher/PutWatch/PutWatchResponse.cs | 9 +- .../ElasticClient-RestartWatcher.cs | 44 +- .../RestartWatcher/RestartWatcherRequest.cs | 6 +- .../RestartWatcher/RestartWatcherResponse.cs | 4 +- .../XPack/Watcher/Schedule/CronExpression.cs | 37 +- .../XPack/Watcher/Schedule/DailySchedule.cs | 6 +- src/Nest/XPack/Watcher/Schedule/Day.cs | 8 +- .../XPack/Watcher/Schedule/HourlySchedule.cs | 4 +- src/Nest/XPack/Watcher/Schedule/Interval.cs | 107 ++- src/Nest/XPack/Watcher/Schedule/Month.cs | 13 +- .../XPack/Watcher/Schedule/MonthlySchedule.cs | 33 +- .../XPack/Watcher/Schedule/ScheduleBase.cs | 2 +- .../Watcher/Schedule/ScheduleContainer.cs | 38 +- .../Watcher/Schedule/ScheduleTriggerEvent.cs | 11 +- .../XPack/Watcher/Schedule/TimeOfMonth.cs | 18 +- src/Nest/XPack/Watcher/Schedule/TimeOfWeek.cs | 18 +- src/Nest/XPack/Watcher/Schedule/TimeOfYear.cs | 13 +- .../XPack/Watcher/Schedule/WeeklySchedule.cs | 36 +- .../XPack/Watcher/Schedule/YearlySchedule.cs | 28 +- .../ElasticClient-StartWatcher.cs | 40 +- .../StartWatcher/StartWatcherRequest.cs | 6 +- .../StartWatcher/StartWatcherResponse.cs | 4 +- .../StopWatcher/ElasticClient-StopWatcher.cs | 40 +- .../Watcher/StopWatcher/StopWatcherRequest.cs | 6 +- .../StopWatcher/StopWatcherResponse.cs | 4 +- .../XPack/Watcher/Transform/ChainTransform.cs | 21 +- .../Transform/IndexedScriptTransform.cs | 12 +- .../Transform/InlineScriptTransform.cs | 23 +- .../Watcher/Transform/ScriptTransformBase.cs | 24 +- .../Watcher/Transform/SearchTransform.cs | 4 +- .../XPack/Watcher/Transform/TransformBase.cs | 2 +- .../Watcher/Transform/TransformContainer.cs | 15 +- src/Nest/XPack/Watcher/Trigger/TriggerBase.cs | 2 +- .../XPack/Watcher/Trigger/TriggerContainer.cs | 6 +- .../XPack/Watcher/Trigger/TriggerEventBase.cs | 2 +- .../Watcher/Trigger/TriggerEventContainer.cs | 2 +- src/Nest/XPack/Watcher/Watch.cs | 26 +- .../ElasticClient-WatcherStats.cs | 40 +- .../WatcherStats/WatcherStatsRequest.cs | 6 +- .../WatcherStats/WatcherStatsResponse.cs | 42 +- src/Nest/_Generated/Requests.patched.cs | 8 +- 1595 files changed, 25816 insertions(+), 22917 deletions(-) diff --git a/src/Nest/Aggregations/AggregateDictionary.cs b/src/Nest/Aggregations/AggregateDictionary.cs index 94fcf5ab8c6..fa46421ce6f 100644 --- a/src/Nest/Aggregations/AggregateDictionary.cs +++ b/src/Nest/Aggregations/AggregateDictionary.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Newtonsoft.Json.Linq; namespace Nest { @@ -12,10 +11,12 @@ namespace Nest [ContractJsonConverter(typeof(AggregateDictionaryConverter))] public class AggregateDictionary : IsAReadOnlyDictionaryBase { - public static AggregateDictionary Default { get; } = new AggregateDictionary(EmptyReadOnly.Dictionary); + internal static readonly char[] TypedKeysSeparator = { '#' }; public AggregateDictionary(IReadOnlyDictionary backingDictionary) : base(backingDictionary) { } + public static AggregateDictionary Default { get; } = new AggregateDictionary(EmptyReadOnly.Dictionary); + protected override string Sanitize(string key) { //typed_keys = true on results in aggregation keys being returned as "#" @@ -23,103 +24,102 @@ protected override string Sanitize(string key) return tokens.Length > 1 ? tokens[1] : tokens[0]; } - internal static readonly char[] TypedKeysSeparator = {'#'}; internal static string[] TypedKeyTokens(string key) { var tokens = key.Split(TypedKeysSeparator, 2, StringSplitOptions.RemoveEmptyEntries); return tokens; } - public ValueAggregate Min(string key) => this.TryGet(key); + public ValueAggregate Min(string key) => TryGet(key); - public ValueAggregate Max(string key) => this.TryGet(key); + public ValueAggregate Max(string key) => TryGet(key); - public ValueAggregate Sum(string key) => this.TryGet(key); + public ValueAggregate Sum(string key) => TryGet(key); - public ValueAggregate Cardinality(string key) => this.TryGet(key); + public ValueAggregate Cardinality(string key) => TryGet(key); - public ValueAggregate Average(string key) => this.TryGet(key); + public ValueAggregate Average(string key) => TryGet(key); - public ValueAggregate ValueCount(string key) => this.TryGet(key); + public ValueAggregate ValueCount(string key) => TryGet(key); - public ValueAggregate AverageBucket(string key) => this.TryGet(key); + public ValueAggregate AverageBucket(string key) => TryGet(key); - public ValueAggregate Derivative(string key) => this.TryGet(key); + public ValueAggregate Derivative(string key) => TryGet(key); - public ValueAggregate SumBucket(string key) => this.TryGet(key); + public ValueAggregate SumBucket(string key) => TryGet(key); - public ValueAggregate MovingAverage(string key) => this.TryGet(key); + public ValueAggregate MovingAverage(string key) => TryGet(key); - public ValueAggregate CumulativeSum(string key) => this.TryGet(key); + public ValueAggregate CumulativeSum(string key) => TryGet(key); - public ValueAggregate BucketScript(string key) => this.TryGet(key); + public ValueAggregate BucketScript(string key) => TryGet(key); - public ValueAggregate SerialDifferencing(string key) => this.TryGet(key); + public ValueAggregate SerialDifferencing(string key) => TryGet(key); - public ValueAggregate WeightedAverage(string key) => this.TryGet(key); + public ValueAggregate WeightedAverage(string key) => TryGet(key); - public KeyedValueAggregate MaxBucket(string key) => this.TryGet(key); + public KeyedValueAggregate MaxBucket(string key) => TryGet(key); - public KeyedValueAggregate MinBucket(string key) => this.TryGet(key); + public KeyedValueAggregate MinBucket(string key) => TryGet(key); public ScriptedMetricAggregate ScriptedMetric(string key) { - var valueMetric = this.TryGet(key); + var valueMetric = TryGet(key); return valueMetric != null ? new ScriptedMetricAggregate(valueMetric.Value) { Meta = valueMetric.Meta } - : this.TryGet(key); + : TryGet(key); } - public StatsAggregate Stats(string key) => this.TryGet(key); + public StatsAggregate Stats(string key) => TryGet(key); - public StatsAggregate StatsBucket(string key) => this.TryGet(key); + public StatsAggregate StatsBucket(string key) => TryGet(key); - public ExtendedStatsAggregate ExtendedStats(string key) => this.TryGet(key); + public ExtendedStatsAggregate ExtendedStats(string key) => TryGet(key); - public ExtendedStatsAggregate ExtendedStatsBucket(string key) => this.TryGet(key); + public ExtendedStatsAggregate ExtendedStatsBucket(string key) => TryGet(key); - public GeoBoundsAggregate GeoBounds(string key) => this.TryGet(key); + public GeoBoundsAggregate GeoBounds(string key) => TryGet(key); - public PercentilesAggregate Percentiles(string key) => this.TryGet(key); + public PercentilesAggregate Percentiles(string key) => TryGet(key); - public PercentilesAggregate PercentilesBucket(string key) => this.TryGet(key); + public PercentilesAggregate PercentilesBucket(string key) => TryGet(key); - public PercentilesAggregate PercentileRanks(string key) => this.TryGet(key); + public PercentilesAggregate PercentileRanks(string key) => TryGet(key); - public TopHitsAggregate TopHits(string key) => this.TryGet(key); + public TopHitsAggregate TopHits(string key) => TryGet(key); public FiltersAggregate Filters(string key) { - var named = this.TryGet(key); + var named = TryGet(key); if (named != null) return named; - var anonymous = this.TryGet(key); + var anonymous = TryGet(key); return anonymous != null ? new FiltersAggregate { Buckets = anonymous.Items.OfType().ToList(), Meta = anonymous.Meta } : null; } - public SingleBucketAggregate Global(string key) => this.TryGet(key); + public SingleBucketAggregate Global(string key) => TryGet(key); - public SingleBucketAggregate Filter(string key) => this.TryGet(key); + public SingleBucketAggregate Filter(string key) => TryGet(key); - public SingleBucketAggregate Missing(string key) => this.TryGet(key); + public SingleBucketAggregate Missing(string key) => TryGet(key); - public SingleBucketAggregate Nested(string key) => this.TryGet(key); + public SingleBucketAggregate Nested(string key) => TryGet(key); - public SingleBucketAggregate ReverseNested(string key) => this.TryGet(key); + public SingleBucketAggregate ReverseNested(string key) => TryGet(key); - public SingleBucketAggregate Children(string key) => this.TryGet(key); + public SingleBucketAggregate Children(string key) => TryGet(key); - public SingleBucketAggregate Sampler(string key) => this.TryGet(key); + public SingleBucketAggregate Sampler(string key) => TryGet(key); - public GeoCentroidAggregate GeoCentroid(string key) => this.TryGet(key); + public GeoCentroidAggregate GeoCentroid(string key) => TryGet(key); public SignificantTermsAggregate SignificantTerms(string key) { - var bucket = this.TryGet(key); + var bucket = TryGet(key); return bucket == null ? null : new SignificantTermsAggregate @@ -133,7 +133,7 @@ public SignificantTermsAggregate SignificantTerms(string key) public SignificantTermsAggregate SignificantText(string key) { - var bucket = this.TryGet(key); + var bucket = TryGet(key); return bucket == null ? null : new SignificantTermsAggregate @@ -147,7 +147,7 @@ public SignificantTermsAggregate SignificantText(string key) public TermsAggregate Terms(string key) { - var bucket = this.TryGet(key); + var bucket = TryGet(key); return bucket == null ? null : new TermsAggregate @@ -179,8 +179,9 @@ public TermsAggregate Terms(string key) public CompositeBucketAggregate Composite(string key) { - var bucket = this.TryGet(key); + var bucket = TryGet(key); if (bucket == null) return null; + return new CompositeBucketAggregate { Buckets = bucket.Items.OfType().ToList(), @@ -189,30 +190,33 @@ public CompositeBucketAggregate Composite(string key) }; } - public MatrixStatsAggregate MatrixStats(string key) => this.TryGet(key); + public MatrixStatsAggregate MatrixStats(string key) => TryGet(key); private TAggregate TryGet(string key) where TAggregate : class, IAggregate { IAggregate agg; - return this.BackingDictionary.TryGetValue(key, out agg) ? agg as TAggregate : null; + return BackingDictionary.TryGetValue(key, out agg) ? agg as TAggregate : null; } private MultiBucketAggregate GetMultiBucketAggregate(string key) where TBucket : IBucket { - var bucket = this.TryGet(key); + var bucket = TryGet(key); if (bucket == null) return null; + return new MultiBucketAggregate { Buckets = bucket.Items.OfType().ToList(), Meta = bucket.Meta, }; } + private MultiBucketAggregate> GetMultiKeyedBucketAggregate(string key) { - var bucket = this.TryGet(key); + var bucket = TryGet(key); if (bucket == null) return null; + return new MultiBucketAggregate> { Buckets = GetKeyedBuckets(bucket.Items).ToList(), @@ -226,7 +230,6 @@ private IEnumerable> GetKeyedBuckets(IEnumerable>(); foreach (var bucket in buckets) - { yield return new KeyedBucket(bucket.BackingDictionary) { Key = (TKey)Convert.ChangeType(bucket.Key, typeof(TKey)), @@ -234,8 +237,6 @@ private IEnumerable> GetKeyedBuckets(IEnumerable(JsonReader reader, JsonSerializer serializer, Dictionary dictionary, string name) + private static void ReadAggregate(JsonReader reader, JsonSerializer serializer, Dictionary dictionary, + string name + ) where TAggregate : IAggregate { reader.Read(); diff --git a/src/Nest/Aggregations/AggregateJsonConverter.cs b/src/Nest/Aggregations/AggregateJsonConverter.cs index d7b0f86c105..3585924fe4e 100644 --- a/src/Nest/Aggregations/AggregateJsonConverter.cs +++ b/src/Nest/Aggregations/AggregateJsonConverter.cs @@ -13,63 +13,6 @@ internal class AggregateJsonConverter : JsonConverter { private static readonly Regex _numeric = new Regex(@"^[\d.]+(\.[\d.]+)?$"); - public override bool CanWrite => false; - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) => this.ReadAggregate(reader, serializer); - - public override bool CanConvert(Type objectType) => objectType == typeof(IAggregate); - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => - throw new NotSupportedException(); - - private static class Parser - { - public const string Values = "values"; - public const string Value = "value"; - public const string Buckets = "buckets"; - public const string DocCountErrorUpperBound = "doc_count_error_upper_bound"; - public const string Count = "count"; - public const string DocCount = "doc_count"; - public const string BgCount = "bg_count"; - public const string Bounds = "bounds"; - public const string Hits = "hits"; - public const string Location = "location"; - public const string Fields = "fields"; - public const string AfterKey = "after_key"; - - public const string Key = "key"; - public const string From = "from"; - public const string To = "to"; - public const string KeyAsString = "key_as_string"; - - public const string Total = "total"; - public const string MaxScore = "max_score"; - - public const string TopLeft = "top_left"; - public const string BottomRight = "bottom_right"; - - public const string AsStringSuffix = "_as_string"; - - public const string Upper = "upper"; - public const string Lower = "lower"; - public const string StdDeviationBoundsAsString = "std_deviation_bounds_as_string"; - - public const string SumOtherDocCount = "sum_other_doc_count"; - - public const string ValueAsString = "value_as_string"; - public const string Keys = "keys"; - - public const string FromAsString = "from_as_string"; - public const string ToAsString = "to_as_string"; - - public const string Score = "score"; - public const string Meta = "meta"; - } - - public static string[] AllReservedAggregationNames { get; } - public static string UsingReservedAggNameFormat { get; } - static AggregateJsonConverter() { AllReservedAggregationNames = typeof(Parser) @@ -91,10 +34,25 @@ static AggregateJsonConverter() + allKeys; } + public static string[] AllReservedAggregationNames { get; } + + public override bool CanWrite => false; + public static string UsingReservedAggNameFormat { get; } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, + JsonSerializer serializer + ) => ReadAggregate(reader, serializer); + + public override bool CanConvert(Type objectType) => objectType == typeof(IAggregate); + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => + throw new NotSupportedException(); + private IAggregate ReadAggregate(JsonReader reader, JsonSerializer serializer) { if (reader.TokenType != JsonToken.StartObject) return null; + reader.Read(); if (reader.TokenType != JsonToken.PropertyName) @@ -102,9 +60,9 @@ private IAggregate ReadAggregate(JsonReader reader, JsonSerializer serializer) IAggregate aggregate = null; - var propertyName = (string) reader.Value; + var propertyName = (string)reader.Value; if (_numeric.IsMatch(propertyName)) - aggregate = GetPercentilesAggregate(reader, serializer, oldFormat: true); + aggregate = GetPercentilesAggregate(reader, serializer, true); var meta = propertyName == Parser.Meta ? GetMetadata(serializer, reader) @@ -116,7 +74,7 @@ private IAggregate ReadAggregate(JsonReader reader, JsonSerializer serializer) return aggregate; } - propertyName = (string) reader.Value; + propertyName = (string)reader.Value; switch (propertyName) { case Parser.Values: @@ -132,7 +90,7 @@ private IAggregate ReadAggregate(JsonReader reader, JsonSerializer serializer) var afterKeys = serializer.Deserialize>(reader); reader.Read(); var bucketAggregate = reader.Value.ToString() == Parser.Buckets - ? this.GetMultiBucketAggregate(reader, serializer) as BucketAggregate ?? new BucketAggregate() + ? GetMultiBucketAggregate(reader, serializer) as BucketAggregate ?? new BucketAggregate() : new BucketAggregate(); bucketAggregate.AfterKey = afterKeys; aggregate = bucketAggregate; @@ -170,13 +128,14 @@ private IBucket ReadBucket(JsonReader reader, JsonSerializer serializer) { if (reader.TokenType != JsonToken.StartObject) return null; + reader.Read(); if (reader.TokenType != JsonToken.PropertyName) return null; IBucket item; - var property = (string) reader.Value; + var property = (string)reader.Value; switch (property) { case Parser.Key: @@ -211,7 +170,7 @@ private Dictionary GetMetadata(JsonSerializer serializer, JsonRe private IAggregate GetMatrixStatsAggregate(JsonReader reader, JsonSerializer serializer, long? docCount = null) { reader.Read(); - var matrixStats = new MatrixStatsAggregate {DocCount = docCount}; + var matrixStats = new MatrixStatsAggregate { DocCount = docCount }; var array = JArray.Load(reader); matrixStats.Fields = array.ToObject>(); return matrixStats; @@ -230,7 +189,7 @@ private IAggregate GetTopHitsAggregate(JsonReader reader, JsonSerializer seriali reader.Read(); //using request/response serializer here because doc is wrapped in NEST's Hit var s = serializer.GetConnectionSettings().RequestResponseSerializer; - var lazyHits = hits.Select(h => new LazyDocument(h,s)).ToList(); + var lazyHits = hits.Select(h => new LazyDocument(h, s)).ToList(); return new TopHitsAggregate(lazyHits) { Total = total, @@ -241,12 +200,12 @@ private IAggregate GetTopHitsAggregate(JsonReader reader, JsonSerializer seriali private IAggregate GetGeoCentroidAggregate(JsonReader reader, JsonSerializer serializer) { reader.Read(); - var geoCentroid = new GeoCentroidAggregate {Location = serializer.Deserialize(reader)}; + var geoCentroid = new GeoCentroidAggregate { Location = serializer.Deserialize(reader) }; reader.Read(); - if (reader.TokenType == JsonToken.PropertyName && (string) reader.Value == Parser.Count) + if (reader.TokenType == JsonToken.PropertyName && (string)reader.Value == Parser.Count) { reader.Read(); - geoCentroid.Count = (long) reader.Value; + geoCentroid.Count = (long)reader.Value; reader.Read(); } return geoCentroid; @@ -258,6 +217,7 @@ private IAggregate GetGeoBoundsAggregate(JsonReader reader, JsonSerializer seria var o = JObject.Load(reader); if (o == null) return null; + var geoBoundsMetric = new GeoBoundsAggregate(); if (o.TryGetValue(Parser.TopLeft, out var topLeftToken) && topLeftToken != null) { @@ -284,7 +244,7 @@ private IAggregate GetPercentilesAggregate(JsonReader reader, JsonSerializer ser reader.Read(); while (reader.TokenType != JsonToken.EndObject) { - var propertyName = (string) reader.Value; + var propertyName = (string)reader.Value; if (propertyName.Contains(Parser.AsStringSuffix)) { reader.Read(); @@ -292,7 +252,7 @@ private IAggregate GetPercentilesAggregate(JsonReader reader, JsonSerializer ser } if (reader.TokenType != JsonToken.EndObject) { - var percentileValue = (string) reader.Value; + var percentileValue = (string)reader.Value; var percentile = double.Parse(percentileValue, CultureInfo.InvariantCulture); reader.Read(); var value = reader.Value as double?; @@ -320,14 +280,13 @@ private IAggregate GetSingleBucketAggregate(JsonReader reader, JsonSerializer se reader.Read(); bgCount = (reader.Value as long?).GetValueOrDefault(0); reader.Read(); - } if ((string)reader.Value == Parser.Fields) return GetMatrixStatsAggregate(reader, serializer, docCount); - if (reader.TokenType == JsonToken.PropertyName && (string) reader.Value == Parser.Buckets) + if (reader.TokenType == JsonToken.PropertyName && (string)reader.Value == Parser.Buckets) { - var b = this.GetMultiBucketAggregate(reader, serializer) as BucketAggregate; + var b = GetMultiBucketAggregate(reader, serializer) as BucketAggregate; return new BucketAggregate { BgCount = bgCount, @@ -336,7 +295,7 @@ private IAggregate GetSingleBucketAggregate(JsonReader reader, JsonSerializer se }; } - var nestedAggregations = this.GetSubAggregates(reader, serializer); + var nestedAggregations = GetSubAggregates(reader, serializer); var bucket = new SingleBucketAggregate(nestedAggregations) { DocCount = docCount @@ -350,10 +309,8 @@ private IAggregate GetStatsAggregate(JsonReader reader, JsonSerializer serialize reader.Read(); var count = (reader.Value as long?).GetValueOrDefault(0); reader.Read(); - if (reader.TokenType == JsonToken.EndObject) - { - return new GeoCentroidAggregate {Count = count}; - } + if (reader.TokenType == JsonToken.EndObject) return new GeoCentroidAggregate { Count = count }; + reader.Read(); var min = reader.Value as double?; reader.Read(); @@ -380,7 +337,7 @@ private IAggregate GetStatsAggregate(JsonReader reader, JsonSerializer serialize if (reader.TokenType == JsonToken.EndObject) return statsMetric; - var propertyName = (string) reader.Value; + var propertyName = (string)reader.Value; while (reader.TokenType != JsonToken.EndObject && propertyName.Contains(Parser.AsStringSuffix)) { reader.Read(); @@ -405,13 +362,13 @@ private IAggregate GetExtendedStatsAggregate(StatsAggregate statsMetric, JsonRea }; reader.Read(); - extendedStatsMetric.SumOfSquares = (reader.Value as double?); + extendedStatsMetric.SumOfSquares = reader.Value as double?; reader.Read(); reader.Read(); - extendedStatsMetric.Variance = (reader.Value as double?); + extendedStatsMetric.Variance = reader.Value as double?; reader.Read(); reader.Read(); - extendedStatsMetric.StdDeviation = (reader.Value as double?); + extendedStatsMetric.StdDeviation = reader.Value as double?; reader.Read(); string propertyName; @@ -422,7 +379,7 @@ private IAggregate GetExtendedStatsAggregate(StatsAggregate statsMetric, JsonRea reader.Read(); reader.Read(); - propertyName = (string) reader.Value; + propertyName = (string)reader.Value; if (propertyName == Parser.Upper) { reader.Read(); @@ -430,7 +387,7 @@ private IAggregate GetExtendedStatsAggregate(StatsAggregate statsMetric, JsonRea } reader.Read(); - propertyName = (string) reader.Value; + propertyName = (string)reader.Value; if (propertyName == Parser.Lower) { reader.Read(); @@ -441,7 +398,7 @@ private IAggregate GetExtendedStatsAggregate(StatsAggregate statsMetric, JsonRea reader.Read(); } - propertyName = (string) reader.Value; + propertyName = (string)reader.Value; while (reader.TokenType != JsonToken.EndObject && propertyName.Contains(Parser.AsStringSuffix)) { // std_deviation_bounds is an object, so we need to skip its properties @@ -467,9 +424,9 @@ private Dictionary GetSubAggregates(JsonReader reader, JsonS var currentDepth = reader.Depth; do { - var fieldName = (string) reader.Value; + var fieldName = (string)reader.Value; reader.Read(); - var agg = this.ReadAggregate(reader, serializer); + var agg = ReadAggregate(reader, serializer); nestedAggs.Add(fieldName, agg); reader.Read(); if (reader.Depth == currentDepth && reader.TokenType == JsonToken.EndObject || reader.Depth < currentDepth) @@ -481,14 +438,14 @@ private Dictionary GetSubAggregates(JsonReader reader, JsonS private IAggregate GetMultiBucketAggregate(JsonReader reader, JsonSerializer serializer) { var bucket = new BucketAggregate(); - var propertyName = (string) reader.Value; + var propertyName = (string)reader.Value; if (propertyName == Parser.DocCountErrorUpperBound) { reader.Read(); bucket.DocCountErrorUpperBound = reader.Value as long?; reader.Read(); } - propertyName = (string) reader.Value; + propertyName = (string)reader.Value; if (propertyName == Parser.SumOtherDocCount) { reader.Read(); @@ -506,7 +463,7 @@ private IAggregate GetMultiBucketAggregate(JsonReader reader, JsonSerializer ser { var name = reader.Value.ToString(); reader.Read(); - var innerAgg = this.ReadAggregate(reader, serializer); + var innerAgg = ReadAggregate(reader, serializer); aggs.Add(name, innerAgg); reader.Read(); } @@ -517,6 +474,7 @@ private IAggregate GetMultiBucketAggregate(JsonReader reader, JsonSerializer ser if (reader.TokenType != JsonToken.StartArray) return null; + reader.Read(); //move from start array to start object if (reader.TokenType == JsonToken.EndArray) { @@ -526,7 +484,7 @@ private IAggregate GetMultiBucketAggregate(JsonReader reader, JsonSerializer ser } do { - var item = this.ReadBucket(reader, serializer); + var item = ReadBucket(reader, serializer); items.Add(item); reader.Read(); } while (reader.TokenType != JsonToken.EndArray); @@ -554,7 +512,7 @@ private IAggregate GetValueAggregate(JsonReader reader, JsonSerializer serialize { if (reader.TokenType == JsonToken.PropertyName) { - var propertyName = (string) reader.Value; + var propertyName = (string)reader.Value; if (propertyName == Parser.ValueAsString) { @@ -564,7 +522,7 @@ private IAggregate GetValueAggregate(JsonReader reader, JsonSerializer serialize if (reader.TokenType == JsonToken.PropertyName) { - propertyName = (string) reader.Value; + propertyName = (string)reader.Value; if (propertyName == Parser.Keys) { var keyedValueMetric = new KeyedValueAggregate @@ -618,13 +576,13 @@ public IBucket GetRangeBucket(JsonReader reader, JsonSerializer serializer, stri case Parser.From: reader.Read(); if (reader.ValueType == typeof(double)) - fromDouble = (double) reader.Value; + fromDouble = (double)reader.Value; reader.Read(); break; case Parser.To: reader.Read(); if (reader.ValueType == typeof(double)) - toDouble = (double) reader.Value; + toDouble = (double)reader.Value; reader.Read(); break; case Parser.Key: @@ -650,7 +608,7 @@ public IBucket GetRangeBucket(JsonReader reader, JsonSerializer serializer, stri } } - var nestedAggregations = this.GetSubAggregates(reader, serializer); + var nestedAggregations = GetSubAggregates(reader, serializer); var bucket = new RangeBucket(nestedAggregations) { @@ -676,7 +634,7 @@ private IBucket GetDateHistogramBucket(JsonReader reader, JsonSerializer seriali var docCount = (reader.Value as long?).GetValueOrDefault(0); reader.Read(); - var nestedAggregations = this.GetSubAggregates(reader, serializer); + var nestedAggregations = GetSubAggregates(reader, serializer); var dateHistogram = new DateHistogramBucket(nestedAggregations) { @@ -697,7 +655,7 @@ private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer) var key = reader.Value; reader.Read(); - var propertyName = (string) reader.Value; + var propertyName = (string)reader.Value; if (propertyName == Parser.From || propertyName == Parser.To) return GetRangeBucket(reader, serializer, key as string); @@ -713,7 +671,7 @@ private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer) var docCount = reader.Value as long?; reader.Read(); - var nextProperty = (string) reader.Value; + var nextProperty = (string)reader.Value; if (nextProperty == Parser.Score) return GetSignificantTermsBucket(reader, serializer, key, keyAsString, docCount); @@ -724,7 +682,7 @@ private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer) docCountErrorUpperBound = reader.Value as long?; reader.Read(); } - var nestedAggregates = this.GetSubAggregates(reader, serializer); + var nestedAggregates = GetSubAggregates(reader, serializer); var bucket = new KeyedBucket(nestedAggregates) { Key = key, @@ -747,7 +705,7 @@ private IBucket GetCompositeBucket(JsonReader reader, JsonSerializer serializer) reader.Read(); } - var nestedAggregates = this.GetSubAggregates(reader, serializer); + var nestedAggregates = GetSubAggregates(reader, serializer); return new CompositeBucket(nestedAggregates, key) { DocCount = docCount }; } @@ -759,7 +717,7 @@ private IBucket GetSignificantTermsBucket(JsonReader reader, JsonSerializer seri reader.Read(); var bgCount = reader.Value as long?; reader.Read(); - var nestedAggregations = this.GetSubAggregates(reader, serializer); + var nestedAggregations = GetSubAggregates(reader, serializer); var significantTermItem = new SignificantTermsBucket(nestedAggregations) { Key = key as string, @@ -775,12 +733,56 @@ private IBucket GetFiltersBucket(JsonReader reader, JsonSerializer serializer) reader.Read(); var docCount = (reader.Value as long?).GetValueOrDefault(0); reader.Read(); - var nestedAggregations = this.GetSubAggregates(reader, serializer); + var nestedAggregations = GetSubAggregates(reader, serializer); var filtersBucketItem = new FiltersBucketItem(nestedAggregations) { DocCount = docCount }; return filtersBucketItem; } + + private static class Parser + { + public const string AfterKey = "after_key"; + + public const string AsStringSuffix = "_as_string"; + public const string BgCount = "bg_count"; + public const string BottomRight = "bottom_right"; + public const string Bounds = "bounds"; + public const string Buckets = "buckets"; + public const string Count = "count"; + public const string DocCount = "doc_count"; + public const string DocCountErrorUpperBound = "doc_count_error_upper_bound"; + public const string Fields = "fields"; + public const string From = "from"; + + public const string FromAsString = "from_as_string"; + public const string Hits = "hits"; + + public const string Key = "key"; + public const string KeyAsString = "key_as_string"; + public const string Keys = "keys"; + public const string Location = "location"; + public const string Lower = "lower"; + public const string MaxScore = "max_score"; + public const string Meta = "meta"; + + public const string Score = "score"; + public const string StdDeviationBoundsAsString = "std_deviation_bounds_as_string"; + + public const string SumOtherDocCount = "sum_other_doc_count"; + public const string To = "to"; + public const string ToAsString = "to_as_string"; + + public const string TopLeft = "top_left"; + + public const string Total = "total"; + + public const string Upper = "upper"; + public const string Value = "value"; + + public const string ValueAsString = "value_as_string"; + public const string Values = "values"; + } } } diff --git a/src/Nest/Aggregations/Aggregation.cs b/src/Nest/Aggregations/Aggregation.cs index a718e82731d..afa33ab84ac 100644 --- a/src/Nest/Aggregations/Aggregation.cs +++ b/src/Nest/Aggregations/Aggregation.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json; namespace Nest { @@ -10,33 +10,30 @@ namespace Nest [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public interface IAggregation { - /// - /// name of the aggregation - /// - string Name { get; set; } - /// /// metadata to associate with the individual aggregation at request time that /// will be returned in place at response time /// IDictionary Meta { get; set; } + + /// + /// name of the aggregation + /// + string Name { get; set; } } /// public abstract class AggregationBase : IAggregation { - /// - string IAggregation.Name { get; set; } + internal AggregationBase() { } + + protected AggregationBase(string name) => ((IAggregation)this).Name = name; /// public IDictionary Meta { get; set; } - internal AggregationBase() { } - - protected AggregationBase(string name) - { - ((IAggregation)this).Name = name; - } + /// + string IAggregation.Name { get; set; } internal abstract void WrapInContainer(AggregationContainer container); @@ -55,16 +52,16 @@ protected AggregationBase(string name) /// internal class AggregationCombinator : AggregationBase, IAggregation { - internal List Aggregations { get; } = new List(); - - internal override void WrapInContainer(AggregationContainer container) { } - public AggregationCombinator(string name, AggregationBase left, AggregationBase right) : base(name) { - this.AddAggregation(left); - this.AddAggregation(right); + AddAggregation(left); + AddAggregation(right); } + internal List Aggregations { get; } = new List(); + + internal override void WrapInContainer(AggregationContainer container) { } + private void AddAggregation(AggregationBase agg) { switch (agg) @@ -72,10 +69,10 @@ private void AddAggregation(AggregationBase agg) case null: return; case AggregationCombinator combinator when combinator.Aggregations.Any(): - this.Aggregations.AddRange(combinator.Aggregations); + Aggregations.AddRange(combinator.Aggregations); break; default: - this.Aggregations.Add(agg); + Aggregations.Add(agg); break; } } diff --git a/src/Nest/Aggregations/AggregationContainer.cs b/src/Nest/Aggregations/AggregationContainer.cs index beddf797152..fab58e88c56 100644 --- a/src/Nest/Aggregations/AggregationContainer.cs +++ b/src/Nest/Aggregations/AggregationContainer.cs @@ -14,11 +14,12 @@ namespace Nest [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public class AggregationDictionary : IsADictionaryBase { - public AggregationDictionary() {} + public AggregationDictionary() { } + public AggregationDictionary(IDictionary container) : base(container) { } + public AggregationDictionary(Dictionary container) - : base(container.ToDictionary(kv => kv.Key, kv => (IAggregationContainer)kv.Value)) - { } + : base(container.ToDictionary(kv => kv.Key, kv => (IAggregationContainer)kv.Value)) { } public static implicit operator AggregationDictionary(Dictionary container) => new AggregationDictionary(container); @@ -37,6 +38,7 @@ public static implicit operator AggregationDictionary(AggregationBase aggregator b = agg; if (b.Name.IsNullOrEmpty()) throw new ArgumentException($"{aggregator.GetType().Name} .Name is not set!"); + dict.Add(b.Name, agg); } return dict; @@ -45,16 +47,18 @@ public static implicit operator AggregationDictionary(AggregationBase aggregator b = aggregator; if (b.Name.IsNullOrEmpty()) throw new ArgumentException($"{aggregator.GetType().Name} .Name is not set!"); + return new AggregationDictionary { { b.Name, aggregator } }; } - public void Add(string key, AggregationContainer value) => this.BackingDictionary.Add(ValidateKey(key), value); + public void Add(string key, AggregationContainer value) => BackingDictionary.Add(ValidateKey(key), value); protected override string ValidateKey(string key) { if (AggregateJsonConverter.AllReservedAggregationNames.Contains(key)) throw new ArgumentException( string.Format(AggregateJsonConverter.UsingReservedAggNameFormat, key), nameof(key)); + return key; } } @@ -64,78 +68,135 @@ protected override string ValidateKey(string key) [JsonConverter(typeof(ReadAsTypeJsonConverter))] public interface IAggregationContainer { - [JsonProperty("meta")] - [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] - IDictionary Meta { get; set; } + [JsonProperty("adjacency_matrix")] + IAdjacencyMatrixAggregation AdjacencyMatrix { get; set; } + + [JsonProperty("aggs")] + AggregationDictionary Aggregations { get; set; } [JsonProperty("avg")] IAverageAggregation Average { get; set; } + [JsonProperty("avg_bucket")] + IAverageBucketAggregation AverageBucket { get; set; } + + [JsonProperty("bucket_script")] + IBucketScriptAggregation BucketScript { get; set; } + + [JsonProperty("bucket_selector")] + IBucketSelectorAggregation BucketSelector { get; set; } + + [JsonProperty("bucket_sort")] + IBucketSortAggregation BucketSort { get; set; } + + [JsonProperty("cardinality")] + ICardinalityAggregation Cardinality { get; set; } + + [JsonProperty("children")] + IChildrenAggregation Children { get; set; } + + [JsonProperty("composite")] + ICompositeAggregation Composite { get; set; } + + [JsonProperty("cumulative_sum")] + ICumulativeSumAggregation CumulativeSum { get; set; } + [JsonProperty("date_histogram")] IDateHistogramAggregation DateHistogram { get; set; } - [JsonProperty("percentiles")] - IPercentilesAggregation Percentiles { get; set; } - [JsonProperty("date_range")] IDateRangeAggregation DateRange { get; set; } + [JsonProperty("derivative")] + IDerivativeAggregation Derivative { get; set; } + [JsonProperty("extended_stats")] IExtendedStatsAggregation ExtendedStats { get; set; } + [JsonProperty("extended_stats_bucket")] + IExtendedStatsBucketAggregation ExtendedStatsBucket { get; set; } + [JsonProperty("filter")] IFilterAggregation Filter { get; set; } [JsonProperty("filters")] IFiltersAggregation Filters { get; set; } + [JsonProperty("geo_bounds")] + IGeoBoundsAggregation GeoBounds { get; set; } + + [JsonProperty("geo_centroid")] + IGeoCentroidAggregation GeoCentroid { get; set; } + [JsonProperty("geo_distance")] IGeoDistanceAggregation GeoDistance { get; set; } [JsonProperty("geohash_grid")] IGeoHashGridAggregation GeoHash { get; set; } - [JsonProperty("geo_bounds")] - IGeoBoundsAggregation GeoBounds { get; set; } + [JsonProperty("global")] + IGlobalAggregation Global { get; set; } [JsonProperty("histogram")] IHistogramAggregation Histogram { get; set; } - [JsonProperty("global")] - IGlobalAggregation Global { get; set; } - [JsonProperty("ip_range")] IIpRangeAggregation IpRange { get; set; } + [JsonProperty("matrix_stats")] + IMatrixStatsAggregation MatrixStats { get; set; } + [JsonProperty("max")] IMaxAggregation Max { get; set; } + [JsonProperty("max_bucket")] + IMaxBucketAggregation MaxBucket { get; set; } + + [JsonProperty("meta")] + [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] + IDictionary Meta { get; set; } + [JsonProperty("min")] IMinAggregation Min { get; set; } - [JsonProperty("cardinality")] - ICardinalityAggregation Cardinality { get; set; } + [JsonProperty("min_bucket")] + IMinBucketAggregation MinBucket { get; set; } [JsonProperty("missing")] IMissingAggregation Missing { get; set; } + [JsonProperty("moving_avg")] + IMovingAverageAggregation MovingAverage { get; set; } + + [JsonProperty("moving_fn")] + IMovingFunctionAggregation MovingFunction { get; set; } + [JsonProperty("nested")] INestedAggregation Nested { get; set; } - [JsonProperty("reverse_nested")] - IReverseNestedAggregation ReverseNested { get; set; } + [JsonProperty("percentile_ranks")] + IPercentileRanksAggregation PercentileRanks { get; set; } + + [JsonProperty("percentiles")] + IPercentilesAggregation Percentiles { get; set; } + + [JsonProperty("percentiles_bucket")] + IPercentilesBucketAggregation PercentilesBucket { get; set; } [JsonProperty("range")] IRangeAggregation Range { get; set; } - [JsonProperty("stats")] - IStatsAggregation Stats { get; set; } + [JsonProperty("reverse_nested")] + IReverseNestedAggregation ReverseNested { get; set; } - [JsonProperty("sum")] - ISumAggregation Sum { get; set; } + [JsonProperty("sampler")] + ISamplerAggregation Sampler { get; set; } - [JsonProperty("terms")] - ITermsAggregation Terms { get; set; } + [JsonProperty("scripted_metric")] + IScriptedMetricAggregation ScriptedMetric { get; set; } + + [JsonProperty("serial_diff")] + ISerialDifferencingAggregation SerialDifferencing { get; set; } [JsonProperty("significant_terms")] ISignificantTermsAggregation SignificantTerms { get; set; } @@ -143,193 +204,142 @@ public interface IAggregationContainer [JsonProperty("significant_text")] ISignificantTextAggregation SignificantText { get; set; } - [JsonProperty("value_count")] - IValueCountAggregation ValueCount { get; set; } - - [JsonProperty("percentile_ranks")] - IPercentileRanksAggregation PercentileRanks { get; set; } - - [JsonProperty("top_hits")] - ITopHitsAggregation TopHits { get; set; } - - [JsonProperty("children")] - IChildrenAggregation Children { get; set; } - - [JsonProperty("scripted_metric")] - IScriptedMetricAggregation ScriptedMetric { get; set; } - - [JsonProperty("avg_bucket")] - IAverageBucketAggregation AverageBucket { get; set; } - - [JsonProperty("derivative")] - IDerivativeAggregation Derivative { get; set; } - - [JsonProperty("max_bucket")] - IMaxBucketAggregation MaxBucket { get; set; } - - [JsonProperty("min_bucket")] - IMinBucketAggregation MinBucket { get; set; } - - [JsonProperty("sum_bucket")] - ISumBucketAggregation SumBucket { get; set; } + [JsonProperty("stats")] + IStatsAggregation Stats { get; set; } [JsonProperty("stats_bucket")] IStatsBucketAggregation StatsBucket { get; set; } - [JsonProperty("extended_stats_bucket")] - IExtendedStatsBucketAggregation ExtendedStatsBucket { get; set; } - - [JsonProperty("percentiles_bucket")] - IPercentilesBucketAggregation PercentilesBucket { get; set; } - - [JsonProperty("moving_avg")] - IMovingAverageAggregation MovingAverage { get; set; } - - [JsonProperty("moving_fn")] - IMovingFunctionAggregation MovingFunction { get; set; } - - [JsonProperty("cumulative_sum")] - ICumulativeSumAggregation CumulativeSum { get; set; } - - [JsonProperty("serial_diff")] - ISerialDifferencingAggregation SerialDifferencing { get; set; } - - [JsonProperty("bucket_script")] - IBucketScriptAggregation BucketScript { get; set; } - - [JsonProperty("bucket_selector")] - IBucketSelectorAggregation BucketSelector { get; set; } - - [JsonProperty("bucket_sort")] - IBucketSortAggregation BucketSort { get; set; } - - [JsonProperty("sampler")] - ISamplerAggregation Sampler { get; set; } + [JsonProperty("sum")] + ISumAggregation Sum { get; set; } - [JsonProperty("geo_centroid")] - IGeoCentroidAggregation GeoCentroid { get; set; } + [JsonProperty("sum_bucket")] + ISumBucketAggregation SumBucket { get; set; } - [JsonProperty("matrix_stats")] - IMatrixStatsAggregation MatrixStats { get; set; } + [JsonProperty("terms")] + ITermsAggregation Terms { get; set; } - [JsonProperty("adjacency_matrix")] - IAdjacencyMatrixAggregation AdjacencyMatrix { get; set; } + [JsonProperty("top_hits")] + ITopHitsAggregation TopHits { get; set; } - [JsonProperty("composite")] - ICompositeAggregation Composite { get; set; } + [JsonProperty("value_count")] + IValueCountAggregation ValueCount { get; set; } [JsonProperty("weighted_avg")] IWeightedAverageAggregation WeightedAverage { get; set; } - [JsonProperty("aggs")] - AggregationDictionary Aggregations { get; set; } - void Accept(IAggregationVisitor visitor); } public class AggregationContainer : IAggregationContainer { - public IDictionary Meta { get; set; } + public IAdjacencyMatrixAggregation AdjacencyMatrix { get; set; } + + public AggregationDictionary Aggregations { get; set; } public IAverageAggregation Average { get; set; } - public IValueCountAggregation ValueCount { get; set; } - public IMaxAggregation Max { get; set; } - public IMinAggregation Min { get; set; } - public IStatsAggregation Stats { get; set; } - public ISumAggregation Sum { get; set; } - public IExtendedStatsAggregation ExtendedStats { get; set; } - public IDateHistogramAggregation DateHistogram { get; set; } - public IPercentilesAggregation Percentiles { get; set; } + public IAverageBucketAggregation AverageBucket { get; set; } - public IDateRangeAggregation DateRange { get; set; } + public IBucketScriptAggregation BucketScript { get; set; } - public IFilterAggregation Filter { get; set; } + public IBucketSelectorAggregation BucketSelector { get; set; } - public IFiltersAggregation Filters { get; set; } + public IBucketSortAggregation BucketSort { get; set; } - public IGeoDistanceAggregation GeoDistance { get; set; } + public ICardinalityAggregation Cardinality { get; set; } - public IGeoHashGridAggregation GeoHash { get; set; } + public IChildrenAggregation Children { get; set; } - public IGeoBoundsAggregation GeoBounds { get; set; } + public ICompositeAggregation Composite { get; set; } - public IHistogramAggregation Histogram { get; set; } + public ICumulativeSumAggregation CumulativeSum { get; set; } + public IDateHistogramAggregation DateHistogram { get; set; } - public IGlobalAggregation Global { get; set; } + public IDateRangeAggregation DateRange { get; set; } - public IIpRangeAggregation IpRange { get; set; } + public IDerivativeAggregation Derivative { get; set; } + public IExtendedStatsAggregation ExtendedStats { get; set; } - public ICardinalityAggregation Cardinality { get; set; } + public IExtendedStatsBucketAggregation ExtendedStatsBucket { get; set; } - public IMissingAggregation Missing { get; set; } + public IFilterAggregation Filter { get; set; } - public INestedAggregation Nested { get; set; } + public IFiltersAggregation Filters { get; set; } - public IReverseNestedAggregation ReverseNested { get; set; } + public IGeoBoundsAggregation GeoBounds { get; set; } - public IRangeAggregation Range { get; set; } + public IGeoCentroidAggregation GeoCentroid { get; set; } - public ITermsAggregation Terms { get; set; } + public IGeoDistanceAggregation GeoDistance { get; set; } - public ISignificantTermsAggregation SignificantTerms { get; set; } + public IGeoHashGridAggregation GeoHash { get; set; } - public ISignificantTextAggregation SignificantText { get; set; } + public IGlobalAggregation Global { get; set; } - public IPercentileRanksAggregation PercentileRanks { get; set; } + public IHistogramAggregation Histogram { get; set; } - public ITopHitsAggregation TopHits { get; set; } + public IIpRangeAggregation IpRange { get; set; } - public IChildrenAggregation Children { get; set; } + public IMatrixStatsAggregation MatrixStats { get; set; } + public IMaxAggregation Max { get; set; } - public IScriptedMetricAggregation ScriptedMetric { get; set; } + public IMaxBucketAggregation MaxBucket { get; set; } + public IDictionary Meta { get; set; } + public IMinAggregation Min { get; set; } - public IAverageBucketAggregation AverageBucket { get; set; } + public IMinBucketAggregation MinBucket { get; set; } - public IDerivativeAggregation Derivative { get; set; } + public IMissingAggregation Missing { get; set; } - public IMaxBucketAggregation MaxBucket { get; set; } + public IMovingAverageAggregation MovingAverage { get; set; } - public IMinBucketAggregation MinBucket { get; set; } + public IMovingFunctionAggregation MovingFunction { get; set; } - public ISumBucketAggregation SumBucket { get; set; } + public INestedAggregation Nested { get; set; } - public IStatsBucketAggregation StatsBucket { get; set; } + public IPercentileRanksAggregation PercentileRanks { get; set; } - public IExtendedStatsBucketAggregation ExtendedStatsBucket { get; set; } + public IPercentilesAggregation Percentiles { get; set; } public IPercentilesBucketAggregation PercentilesBucket { get; set; } - public IMovingAverageAggregation MovingAverage { get; set; } - - public IMovingFunctionAggregation MovingFunction { get; set; } + public IRangeAggregation Range { get; set; } - public ICumulativeSumAggregation CumulativeSum { get; set; } + public IReverseNestedAggregation ReverseNested { get; set; } - public ISerialDifferencingAggregation SerialDifferencing { get; set; } + public ISamplerAggregation Sampler { get; set; } - public IBucketScriptAggregation BucketScript { get; set; } + public IScriptedMetricAggregation ScriptedMetric { get; set; } - public IBucketSelectorAggregation BucketSelector { get; set; } + public ISerialDifferencingAggregation SerialDifferencing { get; set; } - public IBucketSortAggregation BucketSort { get; set; } + public ISignificantTermsAggregation SignificantTerms { get; set; } - public ISamplerAggregation Sampler { get; set; } + public ISignificantTextAggregation SignificantText { get; set; } + public IStatsAggregation Stats { get; set; } - public IGeoCentroidAggregation GeoCentroid { get; set; } + public IStatsBucketAggregation StatsBucket { get; set; } + public ISumAggregation Sum { get; set; } - public IMatrixStatsAggregation MatrixStats { get; set; } + public ISumBucketAggregation SumBucket { get; set; } - public IAdjacencyMatrixAggregation AdjacencyMatrix { get; set; } + public ITermsAggregation Terms { get; set; } - public ICompositeAggregation Composite { get; set; } + public ITopHitsAggregation TopHits { get; set; } + public IValueCountAggregation ValueCount { get; set; } public IWeightedAverageAggregation WeightedAverage { get; set; } - public AggregationDictionary Aggregations { get; set; } + public void Accept(IAggregationVisitor visitor) + { + if (visitor.Scope == AggregationVisitorScope.Unknown) visitor.Scope = AggregationVisitorScope.Aggregation; + new AggregationWalker().Walk(this, visitor); + } public static implicit operator AggregationContainer(AggregationBase aggregator) { if (aggregator == null) return null; + var container = new AggregationContainer(); aggregator.WrapInContainer(container); var bucket = aggregator as BucketAggregationBase; @@ -340,332 +350,382 @@ public static implicit operator AggregationContainer(AggregationBase aggregator) { var dict = new AggregationDictionary(); foreach (var agg in combinator.Aggregations) - dict.Add(((IAggregation) agg).Name, agg); + dict.Add(((IAggregation)agg).Name, agg); container.Aggregations = dict; } container.Meta = aggregator.Meta; return container; } - - public void Accept(IAggregationVisitor visitor) - { - if (visitor.Scope == AggregationVisitorScope.Unknown) visitor.Scope = AggregationVisitorScope.Aggregation; - new AggregationWalker().Walk(this, visitor); - } } public class AggregationContainerDescriptor : DescriptorBase, IAggregationContainer>, IAggregationContainer where T : class { - IDictionary IAggregationContainer.Meta { get; set; } + IAdjacencyMatrixAggregation IAggregationContainer.AdjacencyMatrix { get; set; } AggregationDictionary IAggregationContainer.Aggregations { get; set; } IAverageAggregation IAggregationContainer.Average { get; set; } - IDateHistogramAggregation IAggregationContainer.DateHistogram { get; set; } - - IPercentilesAggregation IAggregationContainer.Percentiles { get; set; } - - IDateRangeAggregation IAggregationContainer.DateRange { get; set; } - - IExtendedStatsAggregation IAggregationContainer.ExtendedStats { get; set; } + IAverageBucketAggregation IAggregationContainer.AverageBucket { get; set; } - IFilterAggregation IAggregationContainer.Filter { get; set; } + IBucketScriptAggregation IAggregationContainer.BucketScript { get; set; } - IFiltersAggregation IAggregationContainer.Filters { get; set; } + IBucketSelectorAggregation IAggregationContainer.BucketSelector { get; set; } - IGeoDistanceAggregation IAggregationContainer.GeoDistance { get; set; } + IBucketSortAggregation IAggregationContainer.BucketSort { get; set; } - IGeoHashGridAggregation IAggregationContainer.GeoHash { get; set; } + ICardinalityAggregation IAggregationContainer.Cardinality { get; set; } - IGeoBoundsAggregation IAggregationContainer.GeoBounds { get; set; } + IChildrenAggregation IAggregationContainer.Children { get; set; } - IHistogramAggregation IAggregationContainer.Histogram { get; set; } + ICompositeAggregation IAggregationContainer.Composite { get; set; } - IGlobalAggregation IAggregationContainer.Global { get; set; } + ICumulativeSumAggregation IAggregationContainer.CumulativeSum { get; set; } - IIpRangeAggregation IAggregationContainer.IpRange { get; set; } + IDateHistogramAggregation IAggregationContainer.DateHistogram { get; set; } - IMaxAggregation IAggregationContainer.Max { get; set; } + IDateRangeAggregation IAggregationContainer.DateRange { get; set; } - IMinAggregation IAggregationContainer.Min { get; set; } + IDerivativeAggregation IAggregationContainer.Derivative { get; set; } - ICardinalityAggregation IAggregationContainer.Cardinality { get; set; } + IExtendedStatsAggregation IAggregationContainer.ExtendedStats { get; set; } - IMissingAggregation IAggregationContainer.Missing { get; set; } + IExtendedStatsBucketAggregation IAggregationContainer.ExtendedStatsBucket { get; set; } - INestedAggregation IAggregationContainer.Nested { get; set; } + IFilterAggregation IAggregationContainer.Filter { get; set; } - IReverseNestedAggregation IAggregationContainer.ReverseNested { get; set; } + IFiltersAggregation IAggregationContainer.Filters { get; set; } - IRangeAggregation IAggregationContainer.Range { get; set; } + IGeoBoundsAggregation IAggregationContainer.GeoBounds { get; set; } - IStatsAggregation IAggregationContainer.Stats { get; set; } + IGeoCentroidAggregation IAggregationContainer.GeoCentroid { get; set; } - ISumAggregation IAggregationContainer.Sum { get; set; } + IGeoDistanceAggregation IAggregationContainer.GeoDistance { get; set; } - IValueCountAggregation IAggregationContainer.ValueCount { get; set; } + IGeoHashGridAggregation IAggregationContainer.GeoHash { get; set; } - ISignificantTermsAggregation IAggregationContainer.SignificantTerms { get; set; } + IGlobalAggregation IAggregationContainer.Global { get; set; } - ISignificantTextAggregation IAggregationContainer.SignificantText { get; set; } + IHistogramAggregation IAggregationContainer.Histogram { get; set; } - IPercentileRanksAggregation IAggregationContainer.PercentileRanks { get; set; } + IIpRangeAggregation IAggregationContainer.IpRange { get; set; } - ITermsAggregation IAggregationContainer.Terms { get; set; } + IMatrixStatsAggregation IAggregationContainer.MatrixStats { get; set; } - ITopHitsAggregation IAggregationContainer.TopHits { get; set; } + IMaxAggregation IAggregationContainer.Max { get; set; } - IChildrenAggregation IAggregationContainer.Children { get; set; } + IMaxBucketAggregation IAggregationContainer.MaxBucket { get; set; } + IDictionary IAggregationContainer.Meta { get; set; } - IScriptedMetricAggregation IAggregationContainer.ScriptedMetric { get; set; } + IMinAggregation IAggregationContainer.Min { get; set; } - IAverageBucketAggregation IAggregationContainer.AverageBucket { get; set; } + IMinBucketAggregation IAggregationContainer.MinBucket { get; set; } - IDerivativeAggregation IAggregationContainer.Derivative { get; set; } + IMissingAggregation IAggregationContainer.Missing { get; set; } - IMaxBucketAggregation IAggregationContainer.MaxBucket { get; set; } + IMovingAverageAggregation IAggregationContainer.MovingAverage { get; set; } - IMinBucketAggregation IAggregationContainer.MinBucket { get; set; } + IMovingFunctionAggregation IAggregationContainer.MovingFunction { get; set; } - ISumBucketAggregation IAggregationContainer.SumBucket { get; set; } + INestedAggregation IAggregationContainer.Nested { get; set; } - IStatsBucketAggregation IAggregationContainer.StatsBucket { get; set; } + IPercentileRanksAggregation IAggregationContainer.PercentileRanks { get; set; } - IExtendedStatsBucketAggregation IAggregationContainer.ExtendedStatsBucket { get; set; } + IPercentilesAggregation IAggregationContainer.Percentiles { get; set; } IPercentilesBucketAggregation IAggregationContainer.PercentilesBucket { get; set; } - IMovingAverageAggregation IAggregationContainer.MovingAverage { get; set; } + IRangeAggregation IAggregationContainer.Range { get; set; } - IMovingFunctionAggregation IAggregationContainer.MovingFunction { get; set; } + IReverseNestedAggregation IAggregationContainer.ReverseNested { get; set; } - ICumulativeSumAggregation IAggregationContainer.CumulativeSum { get; set; } + ISamplerAggregation IAggregationContainer.Sampler { get; set; } + + IScriptedMetricAggregation IAggregationContainer.ScriptedMetric { get; set; } ISerialDifferencingAggregation IAggregationContainer.SerialDifferencing { get; set; } - IBucketScriptAggregation IAggregationContainer.BucketScript { get; set; } + ISignificantTermsAggregation IAggregationContainer.SignificantTerms { get; set; } - IBucketSelectorAggregation IAggregationContainer.BucketSelector { get; set; } + ISignificantTextAggregation IAggregationContainer.SignificantText { get; set; } - IBucketSortAggregation IAggregationContainer.BucketSort { get; set; } + IStatsAggregation IAggregationContainer.Stats { get; set; } - ISamplerAggregation IAggregationContainer.Sampler { get; set; } + IStatsBucketAggregation IAggregationContainer.StatsBucket { get; set; } - IGeoCentroidAggregation IAggregationContainer.GeoCentroid { get; set; } + ISumAggregation IAggregationContainer.Sum { get; set; } - IMatrixStatsAggregation IAggregationContainer.MatrixStats { get; set; } + ISumBucketAggregation IAggregationContainer.SumBucket { get; set; } - IAdjacencyMatrixAggregation IAggregationContainer.AdjacencyMatrix { get; set; } + ITermsAggregation IAggregationContainer.Terms { get; set; } - ICompositeAggregation IAggregationContainer.Composite { get; set; } + ITopHitsAggregation IAggregationContainer.TopHits { get; set; } + + IValueCountAggregation IAggregationContainer.ValueCount { get; set; } IWeightedAverageAggregation IAggregationContainer.WeightedAverage { get; set; } + public void Accept(IAggregationVisitor visitor) + { + if (visitor.Scope == AggregationVisitorScope.Unknown) visitor.Scope = AggregationVisitorScope.Aggregation; + new AggregationWalker().Walk(this, visitor); + } + public AggregationContainerDescriptor Average(string name, - Func, IAverageAggregation> selector) => + Func, IAverageAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Average = d); public AggregationContainerDescriptor DateHistogram(string name, - Func, IDateHistogramAggregation> selector) => + Func, IDateHistogramAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.DateHistogram = d); public AggregationContainerDescriptor Percentiles(string name, - Func, IPercentilesAggregation> selector) => + Func, IPercentilesAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Percentiles = d); public AggregationContainerDescriptor PercentileRanks(string name, - Func, IPercentileRanksAggregation> selector) => + Func, IPercentileRanksAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.PercentileRanks = d); public AggregationContainerDescriptor DateRange(string name, - Func, IDateRangeAggregation> selector) => + Func, IDateRangeAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.DateRange = d); public AggregationContainerDescriptor ExtendedStats(string name, - Func, IExtendedStatsAggregation> selector) => + Func, IExtendedStatsAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.ExtendedStats = d); public AggregationContainerDescriptor Filter(string name, - Func, IFilterAggregation> selector) => + Func, IFilterAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Filter = d); public AggregationContainerDescriptor Filters(string name, - Func, IFiltersAggregation> selector) => + Func, IFiltersAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Filters = d); public AggregationContainerDescriptor GeoDistance(string name, - Func, IGeoDistanceAggregation> selector) => + Func, IGeoDistanceAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.GeoDistance = d); public AggregationContainerDescriptor GeoHash(string name, - Func, IGeoHashGridAggregation> selector) => + Func, IGeoHashGridAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.GeoHash = d); public AggregationContainerDescriptor GeoBounds(string name, - Func, IGeoBoundsAggregation> selector) => + Func, IGeoBoundsAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.GeoBounds = d); public AggregationContainerDescriptor Histogram(string name, - Func, IHistogramAggregation> selector) => + Func, IHistogramAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Histogram = d); public AggregationContainerDescriptor Global(string name, - Func, IGlobalAggregation> selector) => + Func, IGlobalAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Global = d); public AggregationContainerDescriptor IpRange(string name, - Func, IIpRangeAggregation> selector) => + Func, IIpRangeAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.IpRange = d); public AggregationContainerDescriptor Max(string name, - Func, IMaxAggregation> selector) => + Func, IMaxAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Max = d); public AggregationContainerDescriptor Min(string name, - Func, IMinAggregation> selector) => + Func, IMinAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Min = d); public AggregationContainerDescriptor Cardinality(string name, - Func, ICardinalityAggregation> selector) => + Func, ICardinalityAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Cardinality = d); public AggregationContainerDescriptor Missing(string name, - Func, IMissingAggregation> selector) => + Func, IMissingAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Missing = d); public AggregationContainerDescriptor Nested(string name, - Func, INestedAggregation> selector) => + Func, INestedAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Nested = d); public AggregationContainerDescriptor ReverseNested(string name, - Func, IReverseNestedAggregation> selector) => + Func, IReverseNestedAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.ReverseNested = d); public AggregationContainerDescriptor Range(string name, - Func, IRangeAggregation> selector) => + Func, IRangeAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Range = d); public AggregationContainerDescriptor Stats(string name, - Func, IStatsAggregation> selector) => + Func, IStatsAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Stats = d); public AggregationContainerDescriptor Sum(string name, - Func, ISumAggregation> selector) => + Func, ISumAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Sum = d); public AggregationContainerDescriptor Terms(string name, - Func, ITermsAggregation> selector) => + Func, ITermsAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Terms = d); public AggregationContainerDescriptor SignificantTerms(string name, - Func, ISignificantTermsAggregation> selector) => + Func, ISignificantTermsAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.SignificantTerms = d); public AggregationContainerDescriptor SignificantText(string name, - Func, ISignificantTextAggregation> selector) => + Func, ISignificantTextAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.SignificantText = d); public AggregationContainerDescriptor ValueCount(string name, - Func, IValueCountAggregation> selector) => + Func, IValueCountAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.ValueCount = d); public AggregationContainerDescriptor TopHits(string name, - Func, ITopHitsAggregation> selector) => + Func, ITopHitsAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.TopHits = d); public AggregationContainerDescriptor Children(string name, - Func, IChildrenAggregation> selector) where TChild : class => + Func, IChildrenAggregation> selector + ) where TChild : class => _SetInnerAggregation(name, selector, (a, d) => a.Children = d); public AggregationContainerDescriptor ScriptedMetric(string name, - Func, IScriptedMetricAggregation> selector) => + Func, IScriptedMetricAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.ScriptedMetric = d); public AggregationContainerDescriptor AverageBucket(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.AverageBucket = d); public AggregationContainerDescriptor Derivative(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Derivative = d); public AggregationContainerDescriptor MaxBucket(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.MaxBucket = d); public AggregationContainerDescriptor MinBucket(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.MinBucket = d); public AggregationContainerDescriptor SumBucket(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.SumBucket = d); public AggregationContainerDescriptor StatsBucket(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.StatsBucket = d); public AggregationContainerDescriptor ExtendedStatsBucket(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.ExtendedStatsBucket = d); public AggregationContainerDescriptor PercentilesBucket(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.PercentilesBucket = d); public AggregationContainerDescriptor MovingAverage(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.MovingAverage = d); public AggregationContainerDescriptor MovingFunction(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.MovingFunction = d); public AggregationContainerDescriptor CumulativeSum(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.CumulativeSum = d); public AggregationContainerDescriptor SerialDifferencing(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.SerialDifferencing = d); public AggregationContainerDescriptor BucketScript(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.BucketScript = d); public AggregationContainerDescriptor BucketSelector(string name, - Func selector) => + Func selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.BucketSelector = d); public AggregationContainerDescriptor BucketSort(string name, - Func, IBucketSortAggregation> selector) => + Func, IBucketSortAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.BucketSort = d); public AggregationContainerDescriptor Sampler(string name, - Func, ISamplerAggregation> selector) => + Func, ISamplerAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Sampler = d); public AggregationContainerDescriptor GeoCentroid(string name, - Func, IGeoCentroidAggregation> selector) => + Func, IGeoCentroidAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.GeoCentroid = d); public AggregationContainerDescriptor MatrixStats(string name, - Func, IMatrixStatsAggregation> selector) => + Func, IMatrixStatsAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.MatrixStats = d); public AggregationContainerDescriptor AdjacencyMatrix(string name, - Func, IAdjacencyMatrixAggregation> selector) => + Func, IAdjacencyMatrixAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.AdjacencyMatrix = d); public AggregationContainerDescriptor Composite(string name, - Func, ICompositeAggregation> selector) => + Func, ICompositeAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.Composite = d); public AggregationContainerDescriptor WeightedAverage(string name, - Func, IWeightedAverageAggregation> selector) => + Func, IWeightedAverageAggregation> selector + ) => _SetInnerAggregation(name, selector, (a, d) => a.WeightedAverage = d); /// @@ -703,12 +763,6 @@ Func selector return this; } - public void Accept(IAggregationVisitor visitor) - { - if (visitor.Scope == AggregationVisitorScope.Unknown) visitor.Scope = AggregationVisitorScope.Aggregation; - new AggregationWalker().Walk(this, visitor); - } - //always evaluate to false so that each side of && equation is evaluated public static bool operator false(AggregationContainerDescriptor a) => false; @@ -724,7 +778,7 @@ public void Accept(IAggregationVisitor visitor) var d = new AggregationContainerDescriptor(); var leftAggs = (IDictionary)((IAggregationContainer)left).Aggregations; var rightAggs = (IDictionary)((IAggregationContainer)right).Aggregations; - foreach(var kv in rightAggs) + foreach (var kv in rightAggs) { if (leftAggs.ContainsKey(kv.Key)) { @@ -737,6 +791,5 @@ public void Accept(IAggregationVisitor visitor) ((IAggregationContainer)d).Aggregations = ((IAggregationContainer)left).Aggregations; return d; } - } } diff --git a/src/Nest/Aggregations/AggregationJsonConverter.cs b/src/Nest/Aggregations/AggregationJsonConverter.cs index 7457eb38b5b..0efa771dbf2 100644 --- a/src/Nest/Aggregations/AggregationJsonConverter.cs +++ b/src/Nest/Aggregations/AggregationJsonConverter.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Nest +namespace Nest { internal class AggregationJsonConverter : ReadAsTypeJsonConverter - where TReadAs : class - { } + where TReadAs : class { } } diff --git a/src/Nest/Aggregations/Bucket/AdjacencyMatrix/AdjacencyMatrixAggregation.cs b/src/Nest/Aggregations/Bucket/AdjacencyMatrix/AdjacencyMatrixAggregation.cs index c65c15e8ae5..95bdb97ffba 100644 --- a/src/Nest/Aggregations/Bucket/AdjacencyMatrix/AdjacencyMatrixAggregation.cs +++ b/src/Nest/Aggregations/Bucket/AdjacencyMatrix/AdjacencyMatrixAggregation.cs @@ -24,13 +24,12 @@ public AdjacencyMatrixAggregation(string name) : base(name) { } public class AdjacencyMatrixAggregationDescriptor : BucketAggregationDescriptorBase, IAdjacencyMatrixAggregation, T> - , IAdjacencyMatrixAggregation + , IAdjacencyMatrixAggregation where T : class { INamedFiltersContainer IAdjacencyMatrixAggregation.Filters { get; set; } public AdjacencyMatrixAggregationDescriptor Filters(Func, IPromise> selector) => Assign(a => a.Filters = selector?.Invoke(new NamedFiltersContainerDescriptor())?.Value); - } } diff --git a/src/Nest/Aggregations/Bucket/Bucket.cs b/src/Nest/Aggregations/Bucket/Bucket.cs index a3f24607efd..0a327f7ba4f 100644 --- a/src/Nest/Aggregations/Bucket/Bucket.cs +++ b/src/Nest/Aggregations/Bucket/Bucket.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Nest { diff --git a/src/Nest/Aggregations/Bucket/BucketAggregate.cs b/src/Nest/Aggregations/Bucket/BucketAggregate.cs index 0d47b6568c7..a65dfb5af16 100644 --- a/src/Nest/Aggregations/Bucket/BucketAggregate.cs +++ b/src/Nest/Aggregations/Bucket/BucketAggregate.cs @@ -3,7 +3,7 @@ namespace Nest { - public abstract class BucketAggregateBase : AggregateDictionary , IAggregate + public abstract class BucketAggregateBase : AggregateDictionary, IAggregate { protected BucketAggregateBase(IReadOnlyDictionary aggregations) : base(aggregations) { } @@ -36,17 +36,17 @@ public SingleBucketAggregate(IReadOnlyDictionary aggregation public class MultiBucketAggregate : IAggregate where TBucket : IBucket { - /// - public IReadOnlyDictionary Meta { get; set; } - /// /// The buckets into which results are grouped /// public IReadOnlyCollection Buckets { get; set; } = EmptyReadOnly.Collection; + + /// + public IReadOnlyDictionary Meta { get; set; } } /// - /// Aggregation response of + /// Aggregation response of /// public class CompositeBucketAggregate : MultiBucketAggregate { @@ -54,7 +54,7 @@ public class CompositeBucketAggregate : MultiBucketAggregate /// The composite key of the last bucket returned /// in the response before any filtering by pipeline aggregations. /// If all buckets are filtered/removed by pipeline aggregations, - /// will contain the composite key of the last bucket before filtering. + /// will contain the composite key of the last bucket before filtering. /// /// Valid for Elasticsearch 6.3.0+ public CompositeKey AfterKey { get; set; } @@ -63,12 +63,12 @@ public class CompositeBucketAggregate : MultiBucketAggregate // Intermediate object used for deserialization public class BucketAggregate : IAggregate { - public IReadOnlyCollection Items { get; set; } = EmptyReadOnly.Collection; + public IReadOnlyDictionary AfterKey { get; set; } = EmptyReadOnly.Dictionary; + public long BgCount { get; set; } + public long DocCount { get; set; } public long? DocCountErrorUpperBound { get; set; } - public long? SumOtherDocCount { get; set; } + public IReadOnlyCollection Items { get; set; } = EmptyReadOnly.Collection; public IReadOnlyDictionary Meta { get; set; } = EmptyReadOnly.Dictionary; - public long DocCount { get; set; } - public long BgCount { get; set; } - public IReadOnlyDictionary AfterKey { get; set; } = EmptyReadOnly.Dictionary; + public long? SumOtherDocCount { get; set; } } } diff --git a/src/Nest/Aggregations/Bucket/BucketAggregation.cs b/src/Nest/Aggregations/Bucket/BucketAggregation.cs index c83a7011a06..f287d20259f 100644 --- a/src/Nest/Aggregations/Bucket/BucketAggregation.cs +++ b/src/Nest/Aggregations/Bucket/BucketAggregation.cs @@ -10,30 +10,29 @@ public interface IBucketAggregation : IAggregation public abstract class BucketAggregationBase : AggregationBase, IBucketAggregation { - public AggregationDictionary Aggregations { get; set; } - internal BucketAggregationBase() { } protected BucketAggregationBase(string name) : base(name) { } + + public AggregationDictionary Aggregations { get; set; } } public abstract class BucketAggregationDescriptorBase : IBucketAggregation, IDescriptor where TBucketAggregation : BucketAggregationDescriptorBase - , TBucketAggregationInterface, IBucketAggregation + , TBucketAggregationInterface, IBucketAggregation where T : class where TBucketAggregationInterface : class, IBucketAggregation { + protected TBucketAggregationInterface Self => (TBucketAggregation)this; AggregationDictionary IBucketAggregation.Aggregations { get; set; } - protected TBucketAggregation Assign(Action assigner) => - Fluent.Assign(((TBucketAggregation)this), assigner); - - protected TBucketAggregationInterface Self => (TBucketAggregation)this; + IDictionary IAggregation.Meta { get; set; } string IAggregation.Name { get; set; } - IDictionary IAggregation.Meta { get; set; } + protected TBucketAggregation Assign(Action assigner) => + Fluent.Assign((TBucketAggregation)this, assigner); public TBucketAggregation Aggregations(Func, IAggregationContainer> selector) => Assign(a => a.Aggregations = selector?.Invoke(new AggregationContainerDescriptor())?.Aggregations); @@ -44,5 +43,4 @@ public TBucketAggregation Aggregations(AggregationDictionary aggregations) => public TBucketAggregation Meta(Func, FluentDictionary> selector) => Assign(a => a.Meta = selector?.Invoke(new FluentDictionary())); } - } diff --git a/src/Nest/Aggregations/Bucket/Children/ChildrenAggregation.cs b/src/Nest/Aggregations/Bucket/Children/ChildrenAggregation.cs index a5bcdc8ec6b..03dbf5874fa 100644 --- a/src/Nest/Aggregations/Bucket/Children/ChildrenAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Children/ChildrenAggregation.cs @@ -14,14 +14,11 @@ public interface IChildrenAggregation : IBucketAggregation public class ChildrenAggregation : BucketAggregationBase, IChildrenAggregation { - public RelationName Type { get; set; } - internal ChildrenAggregation() { } - public ChildrenAggregation(string name, RelationName type) : base(name) - { - this.Type = type; - } + public ChildrenAggregation(string name, RelationName type) : base(name) => Type = type; + + public RelationName Type { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.Children = this; } diff --git a/src/Nest/Aggregations/Bucket/Composite/CompositeAggregation.cs b/src/Nest/Aggregations/Bucket/Composite/CompositeAggregation.cs index 5e9a8b6805e..d70ff267791 100644 --- a/src/Nest/Aggregations/Bucket/Composite/CompositeAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Composite/CompositeAggregation.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq.Expressions; using Newtonsoft.Json; namespace Nest @@ -13,10 +12,11 @@ namespace Nest public interface ICompositeAggregation : IBucketAggregation { /// - /// Controls the sources that should be used to build the composite buckets + /// Used to retrieve the composite buckets that are after the + /// last composite buckets returned in a previous round /// - [JsonProperty("sources")] - IEnumerable Sources { get; set; } + [JsonProperty("after")] + object After { get; set; } /// /// Defines how many composite buckets should be returned. @@ -28,50 +28,51 @@ public interface ICompositeAggregation : IBucketAggregation int? Size { get; set; } /// - /// Used to retrieve the composite buckets that are after the - /// last composite buckets returned in a previous round + /// Controls the sources that should be used to build the composite buckets /// - [JsonProperty("after")] - object After { get; set; } + [JsonProperty("sources")] + IEnumerable Sources { get; set; } } - /// + /// public class CompositeAggregation : BucketAggregationBase, ICompositeAggregation { internal CompositeAggregation() { } public CompositeAggregation(string name) : base(name) { } - internal override void WrapInContainer(AggregationContainer c) => c.Composite = this; - /// - public IEnumerable Sources { get; set; } + public object After { get; set; } /// public int? Size { get; set; } /// - public object After { get; set; } + public IEnumerable Sources { get; set; } + + internal override void WrapInContainer(AggregationContainer c) => c.Composite = this; } - /// + /// public class CompositeAggregationDescriptor : BucketAggregationDescriptorBase, ICompositeAggregation, T> , ICompositeAggregation where T : class { - IEnumerable ICompositeAggregation.Sources { get; set; } - int? ICompositeAggregation.Size { get; set; } object ICompositeAggregation.After { get; set; } + int? ICompositeAggregation.Size { get; set; } + IEnumerable ICompositeAggregation.Sources { get; set; } - /// - public CompositeAggregationDescriptor Sources(Func, IPromise>> selector) => + /// + public CompositeAggregationDescriptor Sources( + Func, IPromise>> selector + ) => Assign(a => a.Sources = selector?.Invoke(new CompositeAggregationSourcesDescriptor())?.Value); - /// + /// public CompositeAggregationDescriptor Size(int? size) => Assign(a => a.Size = size); - /// + /// public CompositeAggregationDescriptor After(object after) => Assign(a => a.After = after); } } diff --git a/src/Nest/Aggregations/Bucket/Composite/CompositeAggregationSource.cs b/src/Nest/Aggregations/Bucket/Composite/CompositeAggregationSource.cs index cb736b1f704..a7ea04f992f 100644 --- a/src/Nest/Aggregations/Bucket/Composite/CompositeAggregationSource.cs +++ b/src/Nest/Aggregations/Bucket/Composite/CompositeAggregationSource.cs @@ -8,54 +8,47 @@ namespace Nest { /// - /// A values source for + /// A values source for /// [ContractJsonConverter(typeof(CompositeAggregationSourceConverter))] public interface ICompositeAggregationSource { /// - /// The name of the source + /// The field from which to extract value /// - [JsonIgnore] - string Name { get; set; } + [JsonProperty("field")] + Field Field { get; set; } /// - /// The type of the source + /// By default documents without a value for a given source are ignored. It is possible to include + /// them in the response as null by setting this to true /// - [JsonIgnore] - string SourceType { get; } + [JsonProperty("missing_bucket")] + bool? MissingBucket { get; set; } /// - /// The field from which to extract value + /// The name of the source /// - [JsonProperty("field")] - Field Field { get; set; } + [JsonIgnore] + string Name { get; set; } /// /// Defines the direction of sorting for each - /// value source. Defaults to + /// value source. Defaults to /// [JsonProperty("order")] SortOrder? Order { get; set; } /// - /// By default documents without a value for a given source are ignored. It is possible to include - /// them in the response as null by setting this to true + /// The type of the source /// - [JsonProperty("missing_bucket")] - bool? MissingBucket { get; set; } + [JsonIgnore] + string SourceType { get; } } /// public abstract class CompositeAggregationSourceBase : ICompositeAggregationSource { - /// - string ICompositeAggregationSource.Name { get; set; } - string ICompositeAggregationSource.SourceType => SourceType; - - /// - protected abstract string SourceType { get; } - internal CompositeAggregationSourceBase() { } protected CompositeAggregationSourceBase(string name) => @@ -64,34 +57,48 @@ protected CompositeAggregationSourceBase(string name) => /// public Field Field { get; set; } + /// + public bool? MissingBucket { get; set; } + /// public SortOrder? Order { get; set; } + /// + protected abstract string SourceType { get; } + /// - public bool? MissingBucket { get; set; } + string ICompositeAggregationSource.Name { get; set; } + + string ICompositeAggregationSource.SourceType => SourceType; } - /// - public class CompositeAggregationSourcesDescriptor : - DescriptorPromiseBase, IList> + /// + public class CompositeAggregationSourcesDescriptor + : DescriptorPromiseBase, IList> where T : class { - public CompositeAggregationSourcesDescriptor() : base(new List()) {} + public CompositeAggregationSourcesDescriptor() : base(new List()) { } - /// - public CompositeAggregationSourcesDescriptor Terms(string name, Func, ITermsCompositeAggregationSource> selector) => + /// + public CompositeAggregationSourcesDescriptor Terms(string name, + Func, ITermsCompositeAggregationSource> selector + ) => Assign(a => a.Add(selector?.Invoke(new TermsCompositeAggregationSourceDescriptor(name)))); - /// - public CompositeAggregationSourcesDescriptor Histogram(string name, Func, IHistogramCompositeAggregationSource> selector) => + /// + public CompositeAggregationSourcesDescriptor Histogram(string name, + Func, IHistogramCompositeAggregationSource> selector + ) => Assign(a => a.Add(selector?.Invoke(new HistogramCompositeAggregationSourceDescriptor(name)))); - /// - public CompositeAggregationSourcesDescriptor DateHistogram(string name, Func, IDateHistogramCompositeAggregationSource> selector) => + /// + public CompositeAggregationSourcesDescriptor DateHistogram(string name, + Func, IDateHistogramCompositeAggregationSource> selector + ) => Assign(a => a.Add(selector?.Invoke(new DateHistogramCompositeAggregationSourceDescriptor(name)))); } - /// + /// public abstract class CompositeAggregationSourceDescriptorBase : DescriptorBase, ICompositeAggregationSource where TDescriptor : CompositeAggregationSourceDescriptorBase, TInterface @@ -99,28 +106,29 @@ public abstract class CompositeAggregationSourceDescriptorBase _sourceType; - Field ICompositeAggregationSource.Field { get; set; } - SortOrder? ICompositeAggregationSource.Order { get; set; } - bool? ICompositeAggregationSource.MissingBucket { get; set; } - protected CompositeAggregationSourceDescriptorBase(string name, string sourceType) { _sourceType = sourceType; Self.Name = name; } - /// + Field ICompositeAggregationSource.Field { get; set; } + bool? ICompositeAggregationSource.MissingBucket { get; set; } + + string ICompositeAggregationSource.Name { get; set; } + SortOrder? ICompositeAggregationSource.Order { get; set; } + string ICompositeAggregationSource.SourceType => _sourceType; + + /// public TDescriptor Field(Field field) => Assign(a => a.Field = field); - /// - public TDescriptor Field(Expression> objectPath) => Assign(a => a.Field = objectPath); + /// + public TDescriptor Field(Expression> objectPath) => Assign(a => a.Field = objectPath); - /// + /// public TDescriptor Order(SortOrder? order) => Assign(a => a.Order = order); - /// + /// public TDescriptor MissingBucket(bool? includeMissing = true) => Assign(a => a.MissingBucket = includeMissing); } @@ -158,11 +166,11 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist protected override void SerializeJson(JsonWriter writer, object value, ICompositeAggregationSource castValue, JsonSerializer serializer) { writer.WriteStartObject(); - writer.WritePropertyName(castValue.Name); - writer.WriteStartObject(); - writer.WritePropertyName(castValue.SourceType); - base.Reserialize(writer, value, serializer); - writer.WriteEndObject(); + writer.WritePropertyName(castValue.Name); + writer.WriteStartObject(); + writer.WritePropertyName(castValue.SourceType); + Reserialize(writer, value, serializer); + writer.WriteEndObject(); writer.WriteEndObject(); } } diff --git a/src/Nest/Aggregations/Bucket/Composite/CompositeBucket.cs b/src/Nest/Aggregations/Bucket/Composite/CompositeBucket.cs index 72c95479d35..2eb228e7435 100644 --- a/src/Nest/Aggregations/Bucket/Composite/CompositeBucket.cs +++ b/src/Nest/Aggregations/Bucket/Composite/CompositeBucket.cs @@ -12,26 +12,24 @@ public CompositeBucket(IReadOnlyDictionary dict, CompositeKe Key = key; /// - /// The bucket key + /// The count of documents /// - public CompositeKey Key { get; } + public long? DocCount { get; set; } /// - /// The count of documents + /// The bucket key /// - public long? DocCount { get; set; } + public CompositeKey Key { get; } } /// - /// A key for a + /// A key for a /// public class CompositeKey : IsAReadOnlyDictionaryBase { private static readonly DateTimeOffset Epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, TimeSpan.Zero); - public CompositeKey(IReadOnlyDictionary backingDictionary) : base(backingDictionary) - { - } + public CompositeKey(IReadOnlyDictionary backingDictionary) : base(backingDictionary) { } /// /// Tries to get a value with the given key as a string. Returns false if the key does @@ -92,7 +90,7 @@ public bool TryGetValue(string key, out DateTimeOffset value) private bool TryGetValue(string key, out TValue value) { - if (!this.BackingDictionary.TryGetValue(key, out var obj)) + if (!BackingDictionary.TryGetValue(key, out var obj)) { value = default(TValue); return false; @@ -100,7 +98,7 @@ private bool TryGetValue(string key, out TValue value) try { - value = (TValue) Convert.ChangeType(obj, typeof(TValue)); + value = (TValue)Convert.ChangeType(obj, typeof(TValue)); return true; } catch diff --git a/src/Nest/Aggregations/Bucket/Composite/DateHistogramCompositeAggregationSource.cs b/src/Nest/Aggregations/Bucket/Composite/DateHistogramCompositeAggregationSource.cs index fc700b44987..8cca5eb08ad 100644 --- a/src/Nest/Aggregations/Bucket/Composite/DateHistogramCompositeAggregationSource.cs +++ b/src/Nest/Aggregations/Bucket/Composite/DateHistogramCompositeAggregationSource.cs @@ -10,7 +10,14 @@ namespace Nest public interface IDateHistogramCompositeAggregationSource : ICompositeAggregationSource { /// - /// The interval to use when bucketing documents + /// Return a formatted date string as the key instead an epoch long + /// + /// Valid for Elasticsearch 6.3.0+ + [JsonProperty("format")] + string Format { get; set; } + + /// + /// The interval to use when bucketing documents /// [JsonProperty("interval")] Union Interval { get; set; } @@ -22,56 +29,49 @@ public interface IDateHistogramCompositeAggregationSource : ICompositeAggregatio /// [JsonProperty("time_zone")] string Timezone { get; set; } - - /// - /// Return a formatted date string as the key instead an epoch long - /// - /// Valid for Elasticsearch 6.3.0+ - [JsonProperty("format")] - string Format { get; set; } } - /// + /// public class DateHistogramCompositeAggregationSource : CompositeAggregationSourceBase, IDateHistogramCompositeAggregationSource { - public DateHistogramCompositeAggregationSource(string name) : base(name) {} + public DateHistogramCompositeAggregationSource(string name) : base(name) { } /// - public Union Interval { get; set; } + public string Format { get; set; } /// - public string Timezone { get; set; } + public Union Interval { get; set; } /// - public string Format { get; set; } + public string Timezone { get; set; } /// protected override string SourceType => "date_histogram"; } - /// + /// public class DateHistogramCompositeAggregationSourceDescriptor : CompositeAggregationSourceDescriptorBase, IDateHistogramCompositeAggregationSource, T>, IDateHistogramCompositeAggregationSource { - Union IDateHistogramCompositeAggregationSource.Interval { get; set; } - string IDateHistogramCompositeAggregationSource.Timezone { get; set; } - string IDateHistogramCompositeAggregationSource.Format { get; set; } + public DateHistogramCompositeAggregationSourceDescriptor(string name) : base(name, "date_histogram") { } - public DateHistogramCompositeAggregationSourceDescriptor(string name) : base(name, "date_histogram") {} + string IDateHistogramCompositeAggregationSource.Format { get; set; } + Union IDateHistogramCompositeAggregationSource.Interval { get; set; } + string IDateHistogramCompositeAggregationSource.Timezone { get; set; } - /// + /// public DateHistogramCompositeAggregationSourceDescriptor Interval(DateInterval? interval) => Assign(a => a.Interval = interval); - /// + /// public DateHistogramCompositeAggregationSourceDescriptor Interval(Time interval) => Assign(a => a.Interval = interval); - /// + /// public DateHistogramCompositeAggregationSourceDescriptor Timezone(string timezone) => Assign(a => a.Timezone = timezone); - /// + /// public DateHistogramCompositeAggregationSourceDescriptor Format(string format) => Assign(a => a.Format = format); } } diff --git a/src/Nest/Aggregations/Bucket/Composite/HistogramCompositeAggregationSource.cs b/src/Nest/Aggregations/Bucket/Composite/HistogramCompositeAggregationSource.cs index b9ff0522168..d3ab6b9dfcd 100644 --- a/src/Nest/Aggregations/Bucket/Composite/HistogramCompositeAggregationSource.cs +++ b/src/Nest/Aggregations/Bucket/Composite/HistogramCompositeAggregationSource.cs @@ -11,48 +11,49 @@ namespace Nest /// public interface IHistogramCompositeAggregationSource : ICompositeAggregationSource { - /// - /// A script to create the values for the composite buckets - /// - [JsonProperty("script")] - IScript Script { get; set; } - /// /// The interval to use when bucketing documents /// [JsonProperty("interval")] double? Interval { get; set; } + + /// + /// A script to create the values for the composite buckets + /// + [JsonProperty("script")] + IScript Script { get; set; } } - /// + /// public class HistogramCompositeAggregationSource : CompositeAggregationSourceBase, IHistogramCompositeAggregationSource { - public HistogramCompositeAggregationSource(string name) : base(name) {} + public HistogramCompositeAggregationSource(string name) : base(name) { } /// - public IScript Script { get; set; } + public double? Interval { get; set; } /// - public double? Interval { get; set; } + public IScript Script { get; set; } /// protected override string SourceType => "histogram"; } - /// + /// public class HistogramCompositeAggregationSourceDescriptor - : CompositeAggregationSourceDescriptorBase, IHistogramCompositeAggregationSource, T>, IHistogramCompositeAggregationSource + : CompositeAggregationSourceDescriptorBase, IHistogramCompositeAggregationSource, T>, + IHistogramCompositeAggregationSource { + public HistogramCompositeAggregationSourceDescriptor(string name) : base(name, "histogram") { } + double? IHistogramCompositeAggregationSource.Interval { get; set; } IScript IHistogramCompositeAggregationSource.Script { get; set; } - public HistogramCompositeAggregationSourceDescriptor(string name) : base(name, "histogram") {} - - /// + /// public HistogramCompositeAggregationSourceDescriptor Interval(double? interval) => Assign(a => a.Interval = interval); - /// + /// public HistogramCompositeAggregationSourceDescriptor Script(Func selector) => Assign(a => a.Script = selector?.Invoke(new ScriptDescriptor())); } diff --git a/src/Nest/Aggregations/Bucket/Composite/TermsCompositeAggregationSource.cs b/src/Nest/Aggregations/Bucket/Composite/TermsCompositeAggregationSource.cs index 27e09850f6a..45202289d7d 100644 --- a/src/Nest/Aggregations/Bucket/Composite/TermsCompositeAggregationSource.cs +++ b/src/Nest/Aggregations/Bucket/Composite/TermsCompositeAggregationSource.cs @@ -3,7 +3,6 @@ namespace Nest { - /// /// A values source that is equivalent to a simple terms aggregation. /// The values are extracted from a field or a script exactly like the terms aggregation. @@ -17,10 +16,10 @@ public interface ITermsCompositeAggregationSource : ICompositeAggregationSource IScript Script { get; set; } } - /// + /// public class TermsCompositeAggregationSource : CompositeAggregationSourceBase, ITermsCompositeAggregationSource { - public TermsCompositeAggregationSource(string name) : base(name) {} + public TermsCompositeAggregationSource(string name) : base(name) { } /// public IScript Script { get; set; } @@ -29,15 +28,16 @@ public TermsCompositeAggregationSource(string name) : base(name) {} protected override string SourceType => "terms"; } - /// + /// public class TermsCompositeAggregationSourceDescriptor - : CompositeAggregationSourceDescriptorBase, ITermsCompositeAggregationSource, T>, ITermsCompositeAggregationSource + : CompositeAggregationSourceDescriptorBase, ITermsCompositeAggregationSource, T>, + ITermsCompositeAggregationSource { - IScript ITermsCompositeAggregationSource.Script { get; set; } + public TermsCompositeAggregationSourceDescriptor(string name) : base(name, "terms") { } - public TermsCompositeAggregationSourceDescriptor(string name) : base(name, "terms") {} + IScript ITermsCompositeAggregationSource.Script { get; set; } - /// + /// public TermsCompositeAggregationSourceDescriptor Script(Func selector) => Assign(a => a.Script = selector?.Invoke(new ScriptDescriptor())); } diff --git a/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramAggregation.cs b/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramAggregation.cs index 136fd1e9782..469577c23b1 100644 --- a/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramAggregation.cs +++ b/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramAggregation.cs @@ -9,26 +9,23 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IDateHistogramAggregation : IBucketAggregation { + [JsonProperty("extended_bounds")] + ExtendedBounds ExtendedBounds { get; set; } + [JsonProperty("field")] Field Field { get; set; } - [JsonProperty("script")] - IScript Script { get; set; } - - [JsonProperty("params")] - IDictionary Params { get; set; } + [JsonProperty("format")] + string Format { get; set; } [JsonProperty("interval")] Union Interval { get; set; } - [JsonProperty("format")] - string Format { get; set; } - [JsonProperty("min_doc_count")] int? MinimumDocumentCount { get; set; } - [JsonProperty("time_zone")] - string TimeZone { get; set; } + [JsonProperty("missing")] + DateTime? Missing { get; set; } [JsonProperty("offset")] string Offset { get; set; } @@ -36,41 +33,46 @@ public interface IDateHistogramAggregation : IBucketAggregation [JsonProperty("order")] HistogramOrder Order { get; set; } - [JsonProperty("extended_bounds")] - ExtendedBounds ExtendedBounds { get; set; } + [JsonProperty("params")] + IDictionary Params { get; set; } - [JsonProperty("missing")] - DateTime? Missing { get; set; } + [JsonProperty("script")] + IScript Script { get; set; } + + [JsonProperty("time_zone")] + string TimeZone { get; set; } } public class DateHistogramAggregation : BucketAggregationBase, IDateHistogramAggregation { private string _format; + + internal DateHistogramAggregation() { } + + public DateHistogramAggregation(string name) : base(name) { } + + public ExtendedBounds ExtendedBounds { get; set; } public Field Field { get; set; } - public IScript Script { get; set; } - public IDictionary Params { get; set; } - public Union Interval { get; set; } public string Format { get => !string.IsNullOrEmpty(_format) && - !_format.Contains("date_optional_time") && - (ExtendedBounds != null || Missing.HasValue) - ? _format + "||date_optional_time" - : _format; + !_format.Contains("date_optional_time") && + (ExtendedBounds != null || Missing.HasValue) + ? _format + "||date_optional_time" + : _format; set => _format = value; } + public Union Interval { get; set; } + public int? MinimumDocumentCount { get; set; } - public string TimeZone { get; set; } + public DateTime? Missing { get; set; } public string Offset { get; set; } public HistogramOrder Order { get; set; } - public ExtendedBounds ExtendedBounds { get; set; } - public DateTime? Missing { get; set; } - - internal DateHistogramAggregation() { } - - public DateHistogramAggregation(string name) : base(name) { } + public IDictionary Params { get; set; } + public IScript Script { get; set; } + public string TimeZone { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.DateHistogram = this; } @@ -81,35 +83,35 @@ public class DateHistogramAggregationDescriptor where T : class { private string _format; - Field IDateHistogramAggregation.Field { get; set; } - IScript IDateHistogramAggregation.Script { get; set; } - - IDictionary IDateHistogramAggregation.Params { get; set; } - - Union IDateHistogramAggregation.Interval { get; set; } + ExtendedBounds IDateHistogramAggregation.ExtendedBounds { get; set; } + Field IDateHistogramAggregation.Field { get; set; } string IDateHistogramAggregation.Format { get => !string.IsNullOrEmpty(_format) && - !_format.Contains("date_optional_time") && - (Self.ExtendedBounds != null || Self.Missing.HasValue) - ? _format + "||date_optional_time" - : _format; + !_format.Contains("date_optional_time") && + (Self.ExtendedBounds != null || Self.Missing.HasValue) + ? _format + "||date_optional_time" + : _format; set => _format = value; } + Union IDateHistogramAggregation.Interval { get; set; } + int? IDateHistogramAggregation.MinimumDocumentCount { get; set; } - string IDateHistogramAggregation.TimeZone { get; set; } + DateTime? IDateHistogramAggregation.Missing { get; set; } string IDateHistogramAggregation.Offset { get; set; } HistogramOrder IDateHistogramAggregation.Order { get; set; } - ExtendedBounds IDateHistogramAggregation.ExtendedBounds { get; set; } + IDictionary IDateHistogramAggregation.Params { get; set; } - DateTime? IDateHistogramAggregation.Missing { get; set; } + IScript IDateHistogramAggregation.Script { get; set; } + + string IDateHistogramAggregation.TimeZone { get; set; } public DateHistogramAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); @@ -143,7 +145,7 @@ public DateHistogramAggregationDescriptor OrderDescending(string key) => Assign(a => a.Order = new HistogramOrder { Key = key, Order = SortOrder.Descending }); public DateHistogramAggregationDescriptor ExtendedBounds(DateMath min, DateMath max) => - Assign(a=>a.ExtendedBounds = new ExtendedBounds { Minimum = min, Maximum = max }); + Assign(a => a.ExtendedBounds = new ExtendedBounds { Minimum = min, Maximum = max }); public DateHistogramAggregationDescriptor Missing(DateTime? missing) => Assign(a => a.Missing = missing); } diff --git a/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramBucket.cs b/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramBucket.cs index 6c655595dd6..34cce9f6523 100644 --- a/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramBucket.cs +++ b/src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramBucket.cs @@ -1,18 +1,15 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Nest { public class DateHistogramBucket : KeyedBucket { - private static readonly long EpochTicks = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, TimeSpan.Zero).Ticks; + private static readonly long EpochTicks = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, TimeSpan.Zero).Ticks; public DateHistogramBucket(IReadOnlyDictionary dict) : base(dict) { } // Get a DateTime form of the returned key - public DateTime Date => new DateTime(EpochTicks + ((long)this.Key * TimeSpan.TicksPerMillisecond), DateTimeKind.Utc); + public DateTime Date => new DateTime(EpochTicks + (long)Key * TimeSpan.TicksPerMillisecond, DateTimeKind.Utc); } } diff --git a/src/Nest/Aggregations/Bucket/DateHistogram/DateInterval.cs b/src/Nest/Aggregations/Bucket/DateHistogram/DateInterval.cs index 2b219c36381..91982ab408c 100644 --- a/src/Nest/Aggregations/Bucket/DateHistogram/DateInterval.cs +++ b/src/Nest/Aggregations/Bucket/DateHistogram/DateInterval.cs @@ -8,21 +8,27 @@ namespace Nest public enum DateInterval { [EnumMember(Value = "second")] - Second, + Second, + [EnumMember(Value = "minute")] - Minute, + Minute, + [EnumMember(Value = "hour")] - Hour, + Hour, + [EnumMember(Value = "day")] Day, + [EnumMember(Value = "week")] - Week, + Week, + [EnumMember(Value = "month")] - Month, + Month, + [EnumMember(Value = "quarter")] - Quarter, + Quarter, + [EnumMember(Value = "year")] Year } - } diff --git a/src/Nest/Aggregations/Bucket/DateRange/DateRangeAggregation.cs b/src/Nest/Aggregations/Bucket/DateRange/DateRangeAggregation.cs index 5d8b5d5a014..e904609ff3e 100644 --- a/src/Nest/Aggregations/Bucket/DateRange/DateRangeAggregation.cs +++ b/src/Nest/Aggregations/Bucket/DateRange/DateRangeAggregation.cs @@ -25,15 +25,15 @@ public interface IDateRangeAggregation : IBucketAggregation public class DateRangeAggregation : BucketAggregationBase, IDateRangeAggregation { + internal DateRangeAggregation() { } + + public DateRangeAggregation(string name) : base(name) { } + public Field Field { get; set; } public string Format { get; set; } public IEnumerable Ranges { get; set; } public string TimeZone { get; set; } - internal DateRangeAggregation() { } - - public DateRangeAggregation(string name) : base(name) { } - internal override void WrapInContainer(AggregationContainer c) => c.DateRange = this; } @@ -57,14 +57,14 @@ public class DateRangeAggregationDescriptor public DateRangeAggregationDescriptor Format(string format) => Assign(a => a.Format = format); public DateRangeAggregationDescriptor Ranges(params IDateRangeExpression[] ranges) => - Assign(a=>a.Ranges = ranges.ToListOrNullIfEmpty()); + Assign(a => a.Ranges = ranges.ToListOrNullIfEmpty()); public DateRangeAggregationDescriptor TimeZone(string timeZone) => Assign(a => a.TimeZone = timeZone); public DateRangeAggregationDescriptor Ranges(params Func[] ranges) => - Assign(a=>a.Ranges = ranges?.Select(r=>r(new DateRangeExpressionDescriptor())).ToListOrNullIfEmpty()); + Assign(a => a.Ranges = ranges?.Select(r => r(new DateRangeExpressionDescriptor())).ToListOrNullIfEmpty()); public DateRangeAggregationDescriptor Ranges(IEnumerable> ranges) => - Assign(a=>a.Ranges = ranges?.Select(r=>r(new DateRangeExpressionDescriptor())).ToListOrNullIfEmpty()); + Assign(a => a.Ranges = ranges?.Select(r => r(new DateRangeExpressionDescriptor())).ToListOrNullIfEmpty()); } } diff --git a/src/Nest/Aggregations/Bucket/DateRange/DateRangeExpression.cs b/src/Nest/Aggregations/Bucket/DateRange/DateRangeExpression.cs index b1472e4ce78..f8b10c834be 100644 --- a/src/Nest/Aggregations/Bucket/DateRange/DateRangeExpression.cs +++ b/src/Nest/Aggregations/Bucket/DateRange/DateRangeExpression.cs @@ -8,32 +8,35 @@ public interface IDateRangeExpression [JsonProperty("from")] DateMath From { get; set; } - [JsonProperty("to")] - DateMath To { get; set; } - [JsonProperty("key")] string Key { get; set; } + + [JsonProperty("to")] + DateMath To { get; set; } } public class DateRangeExpression : IDateRangeExpression { public DateMath From { get; set; } - public DateMath To { get; set; } - public string Key { get; set; } + + public DateMath To { get; set; } } public class DateRangeExpressionDescriptor : DescriptorBase, IDateRangeExpression { DateMath IDateRangeExpression.From { get; set; } - public DateRangeExpressionDescriptor From(DateMath from) => Assign(a => a.From = from); + + string IDateRangeExpression.Key { get; set; } DateMath IDateRangeExpression.To { get; set; } + + public DateRangeExpressionDescriptor From(DateMath from) => Assign(a => a.From = from); + public DateRangeExpressionDescriptor To(DateMath to) => Assign(a => a.To = to); - string IDateRangeExpression.Key { get; set; } public DateRangeExpressionDescriptor Key(string key) => Assign(a => a.Key = key); } } diff --git a/src/Nest/Aggregations/Bucket/Filter/FilterAggregation.cs b/src/Nest/Aggregations/Bucket/Filter/FilterAggregation.cs index 89b7fbf90b7..9ca113729ef 100644 --- a/src/Nest/Aggregations/Bucket/Filter/FilterAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Filter/FilterAggregation.cs @@ -13,24 +13,23 @@ public interface IFilterAggregation : IBucketAggregation public class FilterAggregation : BucketAggregationBase, IFilterAggregation { - public QueryContainer Filter { get; set; } - internal FilterAggregation() { } public FilterAggregation(string name) : base(name) { } + public QueryContainer Filter { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.Filter = this; } public class FilterAggregationDescriptor - : BucketAggregationDescriptorBase,IFilterAggregation, T> + : BucketAggregationDescriptorBase, IFilterAggregation, T> , IFilterAggregation where T : class { QueryContainer IFilterAggregation.Filter { get; set; } public FilterAggregationDescriptor Filter(Func, QueryContainer> selector) => - Assign(a=> a.Filter = selector?.Invoke(new QueryContainerDescriptor())); - + Assign(a => a.Filter = selector?.Invoke(new QueryContainerDescriptor())); } } diff --git a/src/Nest/Aggregations/Bucket/Filter/FilterAggregationJsonConverter.cs b/src/Nest/Aggregations/Bucket/Filter/FilterAggregationJsonConverter.cs index f20ead0b1ad..35faa34d500 100644 --- a/src/Nest/Aggregations/Bucket/Filter/FilterAggregationJsonConverter.cs +++ b/src/Nest/Aggregations/Bucket/Filter/FilterAggregationJsonConverter.cs @@ -19,7 +19,8 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s writer.WriteStartObject(); writer.WriteEndObject(); return; - }; + } + ; serializer.Serialize(writer, f.Filter); } @@ -27,6 +28,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.StartObject) return null; + var container = new QueryContainer(); serializer.Populate(reader, container); var agg = new FilterAggregation(); @@ -34,5 +36,4 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return agg; } } - } diff --git a/src/Nest/Aggregations/Bucket/Filters/FiltersAggregate.cs b/src/Nest/Aggregations/Bucket/Filters/FiltersAggregate.cs index 9370d1498cd..1c85a5a95c4 100644 --- a/src/Nest/Aggregations/Bucket/Filters/FiltersAggregate.cs +++ b/src/Nest/Aggregations/Bucket/Filters/FiltersAggregate.cs @@ -1,5 +1,4 @@ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace Nest @@ -25,13 +24,13 @@ public FiltersBucketItem(IReadOnlyDictionary dict) : base(di public class FiltersAggregate : BucketAggregateBase { public FiltersAggregate() : base(EmptyReadOnly.Dictionary) { } - public FiltersAggregate(IReadOnlyDictionary aggregations) : base(aggregations) { } - - public SingleBucketAggregate NamedBucket(string key) => this.Global(key); - public IList AnonymousBuckets() => this.Buckets?.ToList(); + public FiltersAggregate(IReadOnlyDictionary aggregations) : base(aggregations) { } public IReadOnlyCollection Buckets { get; set; } = EmptyReadOnly.Collection; + public SingleBucketAggregate NamedBucket(string key) => Global(key); + + public IList AnonymousBuckets() => Buckets?.ToList(); } } diff --git a/src/Nest/Aggregations/Bucket/Filters/FiltersAggregation.cs b/src/Nest/Aggregations/Bucket/Filters/FiltersAggregation.cs index bda9bd8b4f9..28f972394df 100644 --- a/src/Nest/Aggregations/Bucket/Filters/FiltersAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Filters/FiltersAggregation.cs @@ -21,6 +21,10 @@ public interface IFiltersAggregation : IBucketAggregation public class FiltersAggregation : BucketAggregationBase, IFiltersAggregation { + internal FiltersAggregation() { } + + public FiltersAggregation(string name) : base(name) { } + public Union> Filters { get; set; } /// @@ -36,27 +40,23 @@ public class FiltersAggregation : BucketAggregationBase, IFiltersAggregation /// /// Gets or sets the key for the other bucket to a value other than the default "_other_". - /// Setting this parameter will implicitly set the parameter to true + /// Setting this parameter will implicitly set the parameter to true /// public string OtherBucketKey { get; set; } - internal FiltersAggregation() { } - - public FiltersAggregation(string name) : base(name) { } - internal override void WrapInContainer(AggregationContainer c) => c.Filters = this; } public class FiltersAggregationDescriptor : BucketAggregationDescriptorBase, IFiltersAggregation, T> - , IFiltersAggregation + , IFiltersAggregation where T : class { Union> IFiltersAggregation.Filters { get; set; } - bool? IFiltersAggregation.OtherBucket{ get; set; } + bool? IFiltersAggregation.OtherBucket { get; set; } - string IFiltersAggregation.OtherBucketKey{ get; set; } + string IFiltersAggregation.OtherBucketKey { get; set; } /// /// Adds a bucket to the response which will contain all documents @@ -68,27 +68,27 @@ public class FiltersAggregationDescriptor /// the other bucket. /// /// whether to set the other bucket - /// the + /// the public FiltersAggregationDescriptor OtherBucket(bool? otherBucket = true) => Assign(a => a.OtherBucket = otherBucket); /// /// Sets the key for the other bucket to a value other than the default "_other_". - /// Setting this parameter will implicitly set the parameter to true + /// Setting this parameter will implicitly set the parameter to true /// /// the name for the other bucket - /// the + /// the public FiltersAggregationDescriptor OtherBucketKey(string otherBucketKey) => Assign(a => a.OtherBucketKey = otherBucketKey); public FiltersAggregationDescriptor NamedFilters(Func, IPromise> selector) => - Assign(a => a.Filters = new Union>(selector?.Invoke(new NamedFiltersContainerDescriptor())?.Value)); + Assign(a => a.Filters = + new Union>(selector?.Invoke(new NamedFiltersContainerDescriptor())?.Value)); public FiltersAggregationDescriptor AnonymousFilters(params Func, QueryContainer>[] selectors) => - Assign(a => a.Filters = selectors.Select(s=>s?.Invoke(new QueryContainerDescriptor())).ToList()); + Assign(a => a.Filters = selectors.Select(s => s?.Invoke(new QueryContainerDescriptor())).ToList()); public FiltersAggregationDescriptor AnonymousFilters(IEnumerable, QueryContainer>> selectors) => - Assign(a => a.Filters = selectors.Select(s=>s?.Invoke(new QueryContainerDescriptor())).ToList()); - + Assign(a => a.Filters = selectors.Select(s => s?.Invoke(new QueryContainerDescriptor())).ToList()); } } diff --git a/src/Nest/Aggregations/Bucket/Filters/NamedFiltersContainer.cs b/src/Nest/Aggregations/Bucket/Filters/NamedFiltersContainer.cs index a5cb7d69c7b..18d0443b65a 100644 --- a/src/Nest/Aggregations/Bucket/Filters/NamedFiltersContainer.cs +++ b/src/Nest/Aggregations/Bucket/Filters/NamedFiltersContainer.cs @@ -8,19 +8,22 @@ namespace Nest [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public interface INamedFiltersContainer : IIsADictionary { } - public class NamedFiltersContainer: IsADictionaryBase, INamedFiltersContainer + public class NamedFiltersContainer : IsADictionaryBase, INamedFiltersContainer { - public NamedFiltersContainer() {} + public NamedFiltersContainer() { } + public NamedFiltersContainer(IDictionary container) : base(container) { } + public NamedFiltersContainer(Dictionary container) - : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => (IQueryContainer)kv.Value)) - { } + : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => (IQueryContainer)kv.Value)) { } public void Add(string name, IQueryContainer filter) => BackingDictionary.Add(name, filter); + public void Add(string name, QueryContainer filter) => BackingDictionary.Add(name, filter); } - public class NamedFiltersContainerDescriptor : IsADictionaryDescriptorBase, INamedFiltersContainer, string, IQueryContainer> + public class NamedFiltersContainerDescriptor + : IsADictionaryDescriptorBase, INamedFiltersContainer, string, IQueryContainer> where T : class { public NamedFiltersContainerDescriptor() : base(new NamedFiltersContainer()) { } @@ -33,7 +36,5 @@ public NamedFiltersContainerDescriptor Filter(string name, Func Filter(string name, Func, QueryContainer> selector) where TOther : class => Assign(name, selector?.Invoke(new QueryContainerDescriptor())); - } - } diff --git a/src/Nest/Aggregations/Bucket/GeoDistance/GeoDistanceAggregation.cs b/src/Nest/Aggregations/Bucket/GeoDistance/GeoDistanceAggregation.cs index abd9e00f5de..859ab2e48be 100644 --- a/src/Nest/Aggregations/Bucket/GeoDistance/GeoDistanceAggregation.cs +++ b/src/Nest/Aggregations/Bucket/GeoDistance/GeoDistanceAggregation.cs @@ -10,57 +10,54 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IGeoDistanceAggregation : IBucketAggregation { + [JsonProperty("distance_type")] + GeoDistanceType? DistanceType { get; set; } + [JsonProperty("field")] Field Field { get; set; } [JsonProperty("origin")] GeoLocation Origin { get; set; } - [JsonProperty("unit")] - DistanceUnit? Unit { get; set; } - - [JsonProperty("distance_type")] - GeoDistanceType? DistanceType { get; set; } - [JsonProperty("ranges")] IEnumerable Ranges { get; set; } + [JsonProperty("unit")] + DistanceUnit? Unit { get; set; } } public class GeoDistanceAggregation : BucketAggregationBase, IGeoDistanceAggregation { - public Field Field { get; set; } - - public GeoLocation Origin { get; set; } + internal GeoDistanceAggregation() { } - public DistanceUnit? Unit { get; set; } + public GeoDistanceAggregation(string name) : base(name) { } public GeoDistanceType? DistanceType { get; set; } + public Field Field { get; set; } - public IEnumerable Ranges { get; set; } + public GeoLocation Origin { get; set; } - internal GeoDistanceAggregation() { } + public IEnumerable Ranges { get; set; } - public GeoDistanceAggregation(string name) : base(name) { } + public DistanceUnit? Unit { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.GeoDistance = this; } - public class GeoDistanceAggregationDescriptor : - BucketAggregationDescriptorBase, IGeoDistanceAggregation, T> + public class GeoDistanceAggregationDescriptor + : BucketAggregationDescriptorBase, IGeoDistanceAggregation, T> , IGeoDistanceAggregation where T : class { + GeoDistanceType? IGeoDistanceAggregation.DistanceType { get; set; } Field IGeoDistanceAggregation.Field { get; set; } GeoLocation IGeoDistanceAggregation.Origin { get; set; } - DistanceUnit? IGeoDistanceAggregation.Unit { get; set; } - - GeoDistanceType? IGeoDistanceAggregation.DistanceType { get; set; } - IEnumerable IGeoDistanceAggregation.Ranges { get; set; } + DistanceUnit? IGeoDistanceAggregation.Unit { get; set; } + public GeoDistanceAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); public GeoDistanceAggregationDescriptor Field(Expression> field) => Assign(a => a.Field = field); diff --git a/src/Nest/Aggregations/Bucket/GeoHashGrid/GeoHashGridAggregation.cs b/src/Nest/Aggregations/Bucket/GeoHashGrid/GeoHashGridAggregation.cs index b816bebf52c..d61e82f404c 100644 --- a/src/Nest/Aggregations/Bucket/GeoHashGrid/GeoHashGridAggregation.cs +++ b/src/Nest/Aggregations/Bucket/GeoHashGrid/GeoHashGridAggregation.cs @@ -11,27 +11,27 @@ public interface IGeoHashGridAggregation : IBucketAggregation [JsonProperty("field")] Field Field { get; set; } - [JsonProperty("size")] - int? Size { get; set; } + [JsonProperty("precision")] + GeoHashPrecision? Precision { get; set; } [JsonProperty("shard_size")] int? ShardSize { get; set; } - [JsonProperty("precision")] - GeoHashPrecision? Precision { get; set; } + [JsonProperty("size")] + int? Size { get; set; } } public class GeoHashGridAggregation : BucketAggregationBase, IGeoHashGridAggregation { - public Field Field { get; set; } - public int? Size { get; set; } - public int? ShardSize { get; set; } - public GeoHashPrecision? Precision { get; set; } - internal GeoHashGridAggregation() { } public GeoHashGridAggregation(string name) : base(name) { } + public Field Field { get; set; } + public GeoHashPrecision? Precision { get; set; } + public int? ShardSize { get; set; } + public int? Size { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.GeoHash = this; } @@ -42,11 +42,11 @@ public class GeoHashGridAggregationDescriptor { Field IGeoHashGridAggregation.Field { get; set; } - int? IGeoHashGridAggregation.Size { get; set; } + GeoHashPrecision? IGeoHashGridAggregation.Precision { get; set; } int? IGeoHashGridAggregation.ShardSize { get; set; } - GeoHashPrecision? IGeoHashGridAggregation.Precision { get; set; } + int? IGeoHashGridAggregation.Size { get; set; } public GeoHashGridAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); diff --git a/src/Nest/Aggregations/Bucket/Global/GlobalAggregation.cs b/src/Nest/Aggregations/Bucket/Global/GlobalAggregation.cs index 4a2f080e1dc..6fec34a3b11 100644 --- a/src/Nest/Aggregations/Bucket/Global/GlobalAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Global/GlobalAggregation.cs @@ -2,7 +2,6 @@ namespace Nest { - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IGlobalAggregation : IBucketAggregation { } @@ -16,8 +15,8 @@ public GlobalAggregation(string name) : base(name) { } internal override void WrapInContainer(AggregationContainer c) => c.Global = this; } - public class GlobalAggregationDescriptor + public class GlobalAggregationDescriptor : BucketAggregationDescriptorBase, IGlobalAggregation, T> , IGlobalAggregation where T : class { } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Bucket/Histogram/ExtendedBounds.cs b/src/Nest/Aggregations/Bucket/Histogram/ExtendedBounds.cs index c3ef9951885..12e58c0e3a2 100644 --- a/src/Nest/Aggregations/Bucket/Histogram/ExtendedBounds.cs +++ b/src/Nest/Aggregations/Bucket/Histogram/ExtendedBounds.cs @@ -4,10 +4,10 @@ namespace Nest { public class ExtendedBounds { - [JsonProperty("min")] - public T Minimum { get; set; } - [JsonProperty("max")] public T Maximum { get; set; } + + [JsonProperty("min")] + public T Minimum { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Bucket/Histogram/HistogramAggregation.cs b/src/Nest/Aggregations/Bucket/Histogram/HistogramAggregation.cs index 7d359ccb712..7e8b6777dcb 100644 --- a/src/Nest/Aggregations/Bucket/Histogram/HistogramAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Histogram/HistogramAggregation.cs @@ -8,45 +8,45 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IHistogramAggregation : IBucketAggregation { + [JsonProperty("extended_bounds")] + ExtendedBounds ExtendedBounds { get; set; } + [JsonProperty("field")] Field Field { get; set; } - [JsonProperty("script")] - IScript Script { get; set; } - [JsonProperty("interval")] double? Interval { get; set; } [JsonProperty("min_doc_count")] int? MinimumDocumentCount { get; set; } - [JsonProperty("order")] - HistogramOrder Order { get; set; } - - [JsonProperty("extended_bounds")] - ExtendedBounds ExtendedBounds { get; set; } + [JsonProperty("missing")] + double? Missing { get; set; } [JsonProperty("offset")] double? Offset { get; set; } - [JsonProperty("missing")] - double? Missing { get; set; } + [JsonProperty("order")] + HistogramOrder Order { get; set; } + + [JsonProperty("script")] + IScript Script { get; set; } } public class HistogramAggregation : BucketAggregationBase, IHistogramAggregation { + internal HistogramAggregation() { } + + public HistogramAggregation(string name) : base(name) { } + + public ExtendedBounds ExtendedBounds { get; set; } public Field Field { get; set; } - public IScript Script { get; set; } public double? Interval { get; set; } public int? MinimumDocumentCount { get; set; } - public HistogramOrder Order { get; set; } - public ExtendedBounds ExtendedBounds { get; set; } - public double? Offset { get; set; } public double? Missing { get; set; } - - internal HistogramAggregation() { } - - public HistogramAggregation(string name) : base(name) { } + public double? Offset { get; set; } + public HistogramOrder Order { get; set; } + public IScript Script { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.Histogram = this; } @@ -55,21 +55,20 @@ public class HistogramAggregationDescriptor : BucketAggregationDescriptorBase, IHistogramAggregation, T>, IHistogramAggregation where T : class { + ExtendedBounds IHistogramAggregation.ExtendedBounds { get; set; } Field IHistogramAggregation.Field { get; set; } - IScript IHistogramAggregation.Script { get; set; } - double? IHistogramAggregation.Interval { get; set; } int? IHistogramAggregation.MinimumDocumentCount { get; set; } - HistogramOrder IHistogramAggregation.Order { get; set; } - - ExtendedBounds IHistogramAggregation.ExtendedBounds { get; set; } + double? IHistogramAggregation.Missing { get; set; } double? IHistogramAggregation.Offset { get; set; } - double? IHistogramAggregation.Missing { get; set; } + HistogramOrder IHistogramAggregation.Order { get; set; } + + IScript IHistogramAggregation.Script { get; set; } public HistogramAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); diff --git a/src/Nest/Aggregations/Bucket/Histogram/HistogramOrder.cs b/src/Nest/Aggregations/Bucket/Histogram/HistogramOrder.cs index 176c610248d..2903ebe7e26 100644 --- a/src/Nest/Aggregations/Bucket/Histogram/HistogramOrder.cs +++ b/src/Nest/Aggregations/Bucket/Histogram/HistogramOrder.cs @@ -5,14 +5,12 @@ namespace Nest [JsonConverter(typeof(KeyValueJsonConverter))] public class HistogramOrder { - public string Key { get; set; } - public SortOrder Order { get; set; } - public static HistogramOrder CountAscending => new HistogramOrder { Key = "_count", Order = SortOrder.Ascending }; public static HistogramOrder CountDescending => new HistogramOrder { Key = "_count", Order = SortOrder.Descending }; + public string Key { get; set; } public static HistogramOrder KeyAscending => new HistogramOrder { Key = "_key", Order = SortOrder.Ascending }; public static HistogramOrder KeyDescending => new HistogramOrder { Key = "_key", Order = SortOrder.Descending }; - + public SortOrder Order { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Bucket/IpRange/IpRange.cs b/src/Nest/Aggregations/Bucket/IpRange/IpRange.cs index a79beed37c7..b84b6aa1abf 100644 --- a/src/Nest/Aggregations/Bucket/IpRange/IpRange.cs +++ b/src/Nest/Aggregations/Bucket/IpRange/IpRange.cs @@ -9,20 +9,20 @@ public interface IIpRange [JsonProperty("from")] string From { get; set; } - [JsonProperty("to")] - string To { get; set; } - [JsonProperty("mask")] string Mask { get; set; } + + [JsonProperty("to")] + string To { get; set; } } public class IpRange : IIpRange { public string From { get; set; } - public string To { get; set; } - public string Mask { get; set; } + + public string To { get; set; } } public class IpRangeDescriptor @@ -33,7 +33,9 @@ public class IpRangeDescriptor string IIpRange.To { get; set; } public IpRangeDescriptor From(string from) => Assign(a => a.From = from); + public IpRangeDescriptor To(string to) => Assign(a => a.To = to); + public IpRangeDescriptor Mask(string mask) => Assign(a => a.Mask = mask); } } diff --git a/src/Nest/Aggregations/Bucket/IpRange/IpRangeAggregation.cs b/src/Nest/Aggregations/Bucket/IpRange/IpRangeAggregation.cs index e6c179393aa..54e14f964b3 100644 --- a/src/Nest/Aggregations/Bucket/IpRange/IpRangeAggregation.cs +++ b/src/Nest/Aggregations/Bucket/IpRange/IpRangeAggregation.cs @@ -19,18 +19,18 @@ public interface IIpRangeAggregation : IBucketAggregation public class IpRangeAggregation : BucketAggregationBase, IIpRangeAggregation { - public Field Field { get; set; } - public IEnumerable Ranges { get; set; } - internal IpRangeAggregation() { } public IpRangeAggregation(string name) : base(name) { } + public Field Field { get; set; } + public IEnumerable Ranges { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.IpRange = this; } - public class IpRangeAggregationDescriptor : - BucketAggregationDescriptorBase,IIpRangeAggregation, T> + public class IpRangeAggregationDescriptor + : BucketAggregationDescriptorBase, IIpRangeAggregation, T> , IIpRangeAggregation where T : class { diff --git a/src/Nest/Aggregations/Bucket/KeyedBucket.cs b/src/Nest/Aggregations/Bucket/KeyedBucket.cs index 4577f9cc0e4..7817ee9ac62 100644 --- a/src/Nest/Aggregations/Bucket/KeyedBucket.cs +++ b/src/Nest/Aggregations/Bucket/KeyedBucket.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Nest { @@ -9,10 +6,11 @@ public class KeyedBucket : BucketBase { public KeyedBucket(IReadOnlyDictionary dict) : base(dict) { } - public TKey Key { get; set; } - public string KeyAsString { get; set; } public long? DocCount { get; set; } public long? DocCountErrorUpperBound { get; set; } + + public TKey Key { get; set; } + public string KeyAsString { get; set; } } } diff --git a/src/Nest/Aggregations/Bucket/Missing/MissingAggregation.cs b/src/Nest/Aggregations/Bucket/Missing/MissingAggregation.cs index 1c14dd97680..4a5789bfd1d 100644 --- a/src/Nest/Aggregations/Bucket/Missing/MissingAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Missing/MissingAggregation.cs @@ -14,17 +14,17 @@ public interface IMissingAggregation : IBucketAggregation public class MissingAggregation : BucketAggregationBase, IMissingAggregation { - public Field Field { get; set; } - internal MissingAggregation() { } public MissingAggregation(string name) : base(name) { } + public Field Field { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.Missing = this; } public class MissingAggregationDescriptor - : BucketAggregationDescriptorBase,IMissingAggregation, T> + : BucketAggregationDescriptorBase, IMissingAggregation, T> , IMissingAggregation where T : class { diff --git a/src/Nest/Aggregations/Bucket/Nested/NestedAggregation.cs b/src/Nest/Aggregations/Bucket/Nested/NestedAggregation.cs index 0e1a27c857c..f806b5a39bb 100644 --- a/src/Nest/Aggregations/Bucket/Nested/NestedAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Nested/NestedAggregation.cs @@ -9,17 +9,17 @@ namespace Nest public interface INestedAggregation : IBucketAggregation { [JsonProperty("path")] - Field Path { get; set;} + Field Path { get; set; } } public class NestedAggregation : BucketAggregationBase, INestedAggregation { - public Field Path { get; set; } - internal NestedAggregation() { } public NestedAggregation(string name) : base(name) { } + public Field Path { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.Nested = this; } diff --git a/src/Nest/Aggregations/Bucket/Range/RangeAggregation.cs b/src/Nest/Aggregations/Bucket/Range/RangeAggregation.cs index b36396a59a4..da951727be7 100644 --- a/src/Nest/Aggregations/Bucket/Range/RangeAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Range/RangeAggregation.cs @@ -13,22 +13,23 @@ public interface IRangeAggregation : IBucketAggregation [JsonProperty("field")] Field Field { get; set; } - [JsonProperty("script")] - IScript Script { get; set; } - [JsonProperty("ranges")] IEnumerable Ranges { get; set; } + + [JsonProperty("script")] + IScript Script { get; set; } } public class RangeAggregation : BucketAggregationBase, IRangeAggregation { - public Field Field { get; set; } - public IScript Script { get; set; } - public IEnumerable Ranges { get; set; } internal RangeAggregation() { } public RangeAggregation(string name) : base(name) { } + public Field Field { get; set; } + public IEnumerable Ranges { get; set; } + public IScript Script { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.Range = this; } @@ -38,10 +39,10 @@ public class RangeAggregationDescriptor { Field IRangeAggregation.Field { get; set; } - IScript IRangeAggregation.Script { get; set; } - IEnumerable IRangeAggregation.Ranges { get; set; } + IScript IRangeAggregation.Script { get; set; } + public RangeAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); public RangeAggregationDescriptor Field(Expression> field) => Assign(a => a.Field = field); diff --git a/src/Nest/Aggregations/Bucket/Range/RangeBucket.cs b/src/Nest/Aggregations/Bucket/Range/RangeBucket.cs index 20f11969d58..490e9a7a3f4 100644 --- a/src/Nest/Aggregations/Bucket/Range/RangeBucket.cs +++ b/src/Nest/Aggregations/Bucket/Range/RangeBucket.cs @@ -6,11 +6,12 @@ public class RangeBucket : BucketBase, IBucket { public RangeBucket(IReadOnlyDictionary dict) : base(dict) { } - public string Key { get; set; } + public long DocCount { get; set; } public double? From { get; set; } public string FromAsString { get; set; } + + public string Key { get; set; } public double? To { get; set; } public string ToAsString { get; set; } - public long DocCount { get; set; } } } diff --git a/src/Nest/Aggregations/Bucket/ReverseNested/ReverseNestedAggregation.cs b/src/Nest/Aggregations/Bucket/ReverseNested/ReverseNestedAggregation.cs index 098fde530ff..e4e9377e3fd 100644 --- a/src/Nest/Aggregations/Bucket/ReverseNested/ReverseNestedAggregation.cs +++ b/src/Nest/Aggregations/Bucket/ReverseNested/ReverseNestedAggregation.cs @@ -14,18 +14,18 @@ public interface IReverseNestedAggregation : IBucketAggregation public class ReverseNestedAggregation : BucketAggregationBase, IReverseNestedAggregation { - [JsonProperty("path")] - public Field Path { get; set; } - internal ReverseNestedAggregation() { } public ReverseNestedAggregation(string name) : base(name) { } + [JsonProperty("path")] + public Field Path { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.ReverseNested = this; } public class ReverseNestedAggregationDescriptor - : BucketAggregationDescriptorBase,IReverseNestedAggregation, T> + : BucketAggregationDescriptorBase, IReverseNestedAggregation, T> , IReverseNestedAggregation where T : class { diff --git a/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregation.cs b/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregation.cs index 1f28e64638a..da703030afc 100644 --- a/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregation.cs @@ -1,5 +1,4 @@ using System; -using System.Linq.Expressions; using Newtonsoft.Json; namespace Nest @@ -8,8 +7,8 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface ISamplerAggregation : IBucketAggregation { - [JsonProperty("shard_size")] - int? ShardSize { get; set; } + [JsonProperty("execution_hint")] + SamplerAggregationExecutionHint? ExecutionHint { get; set; } [JsonProperty("max_docs_per_value")] int? MaxDocsPerValue { get; set; } @@ -17,21 +16,21 @@ public interface ISamplerAggregation : IBucketAggregation [JsonProperty("script")] IScript Script { get; set; } - [JsonProperty("execution_hint")] - SamplerAggregationExecutionHint? ExecutionHint { get; set; } + [JsonProperty("shard_size")] + int? ShardSize { get; set; } } public class SamplerAggregation : BucketAggregationBase, ISamplerAggregation { + internal SamplerAggregation() { } + + public SamplerAggregation(string name) : base(name) { } + public SamplerAggregationExecutionHint? ExecutionHint { get; set; } public int? MaxDocsPerValue { get; set; } public IScript Script { get; set; } public int? ShardSize { get; set; } - internal SamplerAggregation() { } - - public SamplerAggregation(string name) : base(name) { } - internal override void WrapInContainer(AggregationContainer c) => c.Sampler = this; } diff --git a/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregationExecutionHint.cs b/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregationExecutionHint.cs index de04ff9104f..16f7a8c4921 100644 --- a/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregationExecutionHint.cs +++ b/src/Nest/Aggregations/Bucket/Sampler/SamplerAggregationExecutionHint.cs @@ -9,9 +9,11 @@ public enum SamplerAggregationExecutionHint { [EnumMember(Value = "map")] Map, - [EnumMember(Value = "global_ordinals")] + + [EnumMember(Value = "global_ordinals")] GlobalOrdinals, - [EnumMember(Value = "bytes_hash")] + + [EnumMember(Value = "bytes_hash")] BytesHash } } diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ChiSquareHeuristic.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ChiSquareHeuristic.cs index 09d3640805b..438b9989146 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ChiSquareHeuristic.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ChiSquareHeuristic.cs @@ -6,17 +6,17 @@ namespace Nest [JsonConverter(typeof(ReadAsTypeJsonConverter))] public interface IChiSquareHeuristic { - [JsonProperty("include_negatives")] - bool? IncludeNegatives { get; set; } - [JsonProperty("background_is_superset")] bool? BackgroundIsSuperSet { get; set; } + + [JsonProperty("include_negatives")] + bool? IncludeNegatives { get; set; } } public class ChiSquareHeuristic : IChiSquareHeuristic { - public bool? IncludeNegatives { get; set; } public bool? BackgroundIsSuperSet { get; set; } + public bool? IncludeNegatives { get; set; } } public class ChiSquareHeuristicDescriptor diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/MutualInformationHeuristic.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/MutualInformationHeuristic.cs index 8fb00aa7355..c4be34af93e 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/MutualInformationHeuristic.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/MutualInformationHeuristic.cs @@ -6,24 +6,24 @@ namespace Nest [JsonConverter(typeof(ReadAsTypeJsonConverter))] public interface IMutualInformationHeuristic { - [JsonProperty("include_negatives")] - bool? IncludeNegatives { get; set; } - [JsonProperty("background_is_superset")] bool? BackgroundIsSuperSet { get; set; } + + [JsonProperty("include_negatives")] + bool? IncludeNegatives { get; set; } } public class MutualInformationHeuristic : IMutualInformationHeuristic { - public bool? IncludeNegatives { get; set; } public bool? BackgroundIsSuperSet { get; set; } + public bool? IncludeNegatives { get; set; } } public class MutualInformationHeuristicDescriptor : DescriptorBase, IMutualInformationHeuristic { - bool? IMutualInformationHeuristic.IncludeNegatives { get; set; } bool? IMutualInformationHeuristic.BackgroundIsSuperSet { get; set; } + bool? IMutualInformationHeuristic.IncludeNegatives { get; set; } public MutualInformationHeuristicDescriptor IncludeNegatives(bool? includeNegatives = true) => Assign(a => a.IncludeNegatives = includeNegatives); diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/PercentageScoreHeuristic.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/PercentageScoreHeuristic.cs index 16782ff88dc..6305fa96236 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/PercentageScoreHeuristic.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/PercentageScoreHeuristic.cs @@ -8,7 +8,6 @@ public interface IPercentageScoreHeuristic { } public class PercentageScoreHeuristic { } - public class PercentageScoreHeuristicDescriptor - : DescriptorBase, IPercentageScoreHeuristic - { } -} \ No newline at end of file + public class PercentageScoreHeuristicDescriptor + : DescriptorBase, IPercentageScoreHeuristic { } +} diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ScriptedHeuristic.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ScriptedHeuristic.cs index 20b4dda9489..c4e1bb5d91a 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ScriptedHeuristic.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/Heuristics/ScriptedHeuristic.cs @@ -5,7 +5,7 @@ namespace Nest { [JsonObject] [JsonConverter(typeof(ReadAsTypeJsonConverter))] - public interface IScriptedHeuristic + public interface IScriptedHeuristic { [JsonProperty("script")] IScript Script { get; set; } @@ -16,7 +16,7 @@ public class ScriptedHeuristic : IScriptedHeuristic public IScript Script { get; set; } } - public class ScriptedHeuristicDescriptor + public class ScriptedHeuristicDescriptor : DescriptorBase, IScriptedHeuristic { IScript IScriptedHeuristic.Script { get; set; } @@ -26,4 +26,4 @@ public class ScriptedHeuristicDescriptor public ScriptedHeuristicDescriptor Script(Func scriptSelector) => Assign(a => a.Script = scriptSelector?.Invoke(new ScriptDescriptor())); } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregate.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregate.cs index 61f452a18a2..d15d2c3941c 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregate.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregate.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Nest +namespace Nest { public class SignificantTermsAggregate : MultiBucketAggregate { - public long DocCount { get; set; } public long? BgCount { get; set; } + public long DocCount { get; set; } } } diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregation.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregation.cs index 92180e0a143..0f9f81735c3 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregation.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregation.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using Newtonsoft.Json; @@ -11,46 +10,43 @@ namespace Nest public interface ISignificantTermsAggregation : IBucketAggregation { /// - /// The field on which to run the aggregation + /// The default source of statistical information for background term + /// frequencies is the entire index. This scope can be narrowed + /// through the use of a background filter to focus in on significant + /// terms within a narrower context /// - [JsonProperty("field")] - Field Field { get; set; } + [JsonProperty("background_filter")] + QueryContainer BackgroundFilter { get; set; } /// - /// Defines how many term buckets should be returned out of the overall - /// terms list + /// Use chi square to calculate significance score /// - [JsonProperty("size")] - int? Size { get; set; } + [JsonProperty("chi_square")] + IChiSquareHeuristic ChiSquare { get; set; } /// - /// Controls the number of candidate terms produced by each shard from which - /// the of terms is selected. + /// Exclude term values for which buckets will be created. /// - [JsonProperty("shard_size")] - int? ShardSize { get; set; } + [JsonProperty("exclude")] + SignificantTermsIncludeExclude Exclude { get; set; } /// - /// Return only terms that match equal to or more than a configurable - /// number of hits + /// Determines the mechanism by which aggregations are executed /// - [JsonProperty("min_doc_count")] - long? MinimumDocumentCount { get; set; } + [JsonProperty("execution_hint")] + TermsAggregationExecutionHint? ExecutionHint { get; set; } /// - /// Regulates the certainty a shard has if the term should actually be added to the candidate - /// list or not with respect to the . - /// Terms will only be considered if their local shard frequency within - /// the set is higher than the . + /// The field on which to run the aggregation /// - [JsonProperty("shard_min_doc_count")] - long? ShardMinimumDocumentCount { get; set; } + [JsonProperty("field")] + Field Field { get; set; } /// - /// Determines the mechanism by which aggregations are executed + /// Use Google normalized distance to calculate significance score /// - [JsonProperty("execution_hint")] - TermsAggregationExecutionHint? ExecutionHint { get; set; } + [JsonProperty("gnd")] + IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } /// /// Include term values for which buckets will be created. @@ -59,10 +55,11 @@ public interface ISignificantTermsAggregation : IBucketAggregation SignificantTermsIncludeExclude Include { get; set; } /// - /// Exclude term values for which buckets will be created. + /// Return only terms that match equal to or more than a configurable + /// number of hits /// - [JsonProperty("exclude")] - SignificantTermsIncludeExclude Exclude { get; set; } + [JsonProperty("min_doc_count")] + long? MinimumDocumentCount { get; set; } /// /// Use mutual information to calculate significance score @@ -70,24 +67,14 @@ public interface ISignificantTermsAggregation : IBucketAggregation [JsonProperty("mutual_information")] IMutualInformationHeuristic MutualInformation { get; set; } - /// - /// Use chi square to calculate significance score - /// - [JsonProperty("chi_square")] - IChiSquareHeuristic ChiSquare { get; set; } - - /// - /// Use Google normalized distance to calculate significance score - /// - [JsonProperty("gnd")] - IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } - /// /// Use percentage to calculate significance score. - /// A simple calculation of the number of documents in the foreground + /// + /// A simple calculation of the number of documents in the foreground /// sample with a term divided by the number of documents in the background /// with the term. By default this produces a score greater than zero - /// and less than one. + /// and less than one. + /// /// [JsonProperty("percentage")] IPercentageScoreHeuristic PercentageScore { get; set; } @@ -99,49 +86,76 @@ public interface ISignificantTermsAggregation : IBucketAggregation IScriptedHeuristic Script { get; set; } /// - /// The default source of statistical information for background term - /// frequencies is the entire index. This scope can be narrowed - /// through the use of a background filter to focus in on significant - /// terms within a narrower context + /// Regulates the certainty a shard has if the term should actually be added to the candidate + /// list or not with respect to the . + /// Terms will only be considered if their local shard frequency within + /// the set is higher than the . /// - [JsonProperty("background_filter")] - QueryContainer BackgroundFilter { get; set; } + [JsonProperty("shard_min_doc_count")] + long? ShardMinimumDocumentCount { get; set; } + + /// + /// Controls the number of candidate terms produced by each shard from which + /// the of terms is selected. + /// + [JsonProperty("shard_size")] + int? ShardSize { get; set; } + + /// + /// Defines how many term buckets should be returned out of the overall + /// terms list + /// + [JsonProperty("size")] + int? Size { get; set; } } public class SignificantTermsAggregation : BucketAggregationBase, ISignificantTermsAggregation { + internal SignificantTermsAggregation() { } + + public SignificantTermsAggregation(string name) : base(name) { } + /// - public Field Field { get; set; } + public QueryContainer BackgroundFilter { get; set; } + /// - public int? Size { get; set; } + public IChiSquareHeuristic ChiSquare { get; set; } + /// - public int? ShardSize { get; set; } + public SignificantTermsIncludeExclude Exclude { get; set; } + /// - public long? MinimumDocumentCount { get; set; } + public TermsAggregationExecutionHint? ExecutionHint { get; set; } + /// - public long? ShardMinimumDocumentCount { get; set; } + public Field Field { get; set; } + /// - public TermsAggregationExecutionHint? ExecutionHint { get; set; } + public IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } + /// public SignificantTermsIncludeExclude Include { get; set; } + /// - public SignificantTermsIncludeExclude Exclude { get; set; } + public long? MinimumDocumentCount { get; set; } + /// public IMutualInformationHeuristic MutualInformation { get; set; } - /// - public IChiSquareHeuristic ChiSquare { get; set; } - /// - public IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } + /// public IPercentageScoreHeuristic PercentageScore { get; set; } + /// public IScriptedHeuristic Script { get; set; } + /// - public QueryContainer BackgroundFilter { get; set; } + public long? ShardMinimumDocumentCount { get; set; } - internal SignificantTermsAggregation() { } + /// + public int? ShardSize { get; set; } - public SignificantTermsAggregation(string name) : base(name) { } + /// + public int? Size { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.SignificantTerms = this; } @@ -151,33 +165,32 @@ public class SignificantTermsAggregationDescriptor , ISignificantTermsAggregation where T : class { - Field ISignificantTermsAggregation.Field { get; set; } - - int? ISignificantTermsAggregation.Size { get; set; } - - int? ISignificantTermsAggregation.ShardSize { get; set; } + QueryContainer ISignificantTermsAggregation.BackgroundFilter { get; set; } - long? ISignificantTermsAggregation.MinimumDocumentCount { get; set; } + IChiSquareHeuristic ISignificantTermsAggregation.ChiSquare { get; set; } - long? ISignificantTermsAggregation.ShardMinimumDocumentCount { get; set; } + SignificantTermsIncludeExclude ISignificantTermsAggregation.Exclude { get; set; } TermsAggregationExecutionHint? ISignificantTermsAggregation.ExecutionHint { get; set; } + Field ISignificantTermsAggregation.Field { get; set; } + + IGoogleNormalizedDistanceHeuristic ISignificantTermsAggregation.GoogleNormalizedDistance { get; set; } SignificantTermsIncludeExclude ISignificantTermsAggregation.Include { get; set; } - SignificantTermsIncludeExclude ISignificantTermsAggregation.Exclude { get; set; } + long? ISignificantTermsAggregation.MinimumDocumentCount { get; set; } IMutualInformationHeuristic ISignificantTermsAggregation.MutualInformation { get; set; } - IChiSquareHeuristic ISignificantTermsAggregation.ChiSquare { get; set; } - - IGoogleNormalizedDistanceHeuristic ISignificantTermsAggregation.GoogleNormalizedDistance { get; set; } - IPercentageScoreHeuristic ISignificantTermsAggregation.PercentageScore { get; set; } IScriptedHeuristic ISignificantTermsAggregation.Script { get; set; } - QueryContainer ISignificantTermsAggregation.BackgroundFilter { get; set; } + long? ISignificantTermsAggregation.ShardMinimumDocumentCount { get; set; } + + int? ISignificantTermsAggregation.ShardSize { get; set; } + + int? ISignificantTermsAggregation.Size { get; set; } /// public SignificantTermsAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); @@ -219,7 +232,9 @@ public SignificantTermsAggregationDescriptor ShardMinimumDocumentCount(long? Assign(a => a.ShardMinimumDocumentCount = shardMinimumDocumentCount); /// - public SignificantTermsAggregationDescriptor MutualInformation(Func mutualInformationSelector = null) => + public SignificantTermsAggregationDescriptor MutualInformation( + Func mutualInformationSelector = null + ) => Assign(a => a.MutualInformation = mutualInformationSelector.InvokeOrDefault(new MutualInformationHeuristicDescriptor())); /// @@ -227,11 +242,15 @@ public SignificantTermsAggregationDescriptor ChiSquare(Func a.ChiSquare = chiSquareSelector.InvokeOrDefault(new ChiSquareHeuristicDescriptor())); /// - public SignificantTermsAggregationDescriptor GoogleNormalizedDistance(Func gndSelector) => + public SignificantTermsAggregationDescriptor GoogleNormalizedDistance( + Func gndSelector + ) => Assign(a => a.GoogleNormalizedDistance = gndSelector.InvokeOrDefault(new GoogleNormalizedDistanceHeuristicDescriptor())); /// - public SignificantTermsAggregationDescriptor PercentageScore(Func percentageScoreSelector) => + public SignificantTermsAggregationDescriptor PercentageScore( + Func percentageScoreSelector + ) => Assign(a => a.PercentageScore = percentageScoreSelector.InvokeOrDefault(new PercentageScoreHeuristicDescriptor())); /// diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsBucket.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsBucket.cs index db04ad36936..6be5df8b49d 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsBucket.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsBucket.cs @@ -6,9 +6,10 @@ public class SignificantTermsBucket : BucketBase, IBucket { public SignificantTermsBucket(IReadOnlyDictionary dict) : base(dict) { } - public string Key { get; set; } public long BgCount { get; set; } public long DocCount { get; set; } + + public string Key { get; set; } public double Score { get; set; } } } diff --git a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsIncludeExclude.cs b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsIncludeExclude.cs index b47dd4e1ead..7578bbcbeed 100644 --- a/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsIncludeExclude.cs +++ b/src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsIncludeExclude.cs @@ -7,15 +7,15 @@ namespace Nest [JsonConverter(typeof(SignificantTermsIncludeExcludeJsonConverter))] public class SignificantTermsIncludeExclude { + public SignificantTermsIncludeExclude(string pattern) => Pattern = pattern; + + public SignificantTermsIncludeExclude(IEnumerable values) => Values = values; + [JsonIgnore] public string Pattern { get; set; } [JsonIgnore] public IEnumerable Values { get; set; } - - public SignificantTermsIncludeExclude(string pattern) => Pattern = pattern; - - public SignificantTermsIncludeExclude(IEnumerable values) => Values = values; } internal class SignificantTermsIncludeExcludeJsonConverter : JsonConverter diff --git a/src/Nest/Aggregations/Bucket/SignificantText/SignificantTextAggregation.cs b/src/Nest/Aggregations/Bucket/SignificantText/SignificantTextAggregation.cs index c76196a0939..2a9cf7245c2 100644 --- a/src/Nest/Aggregations/Bucket/SignificantText/SignificantTextAggregation.cs +++ b/src/Nest/Aggregations/Bucket/SignificantText/SignificantTextAggregation.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using Newtonsoft.Json; @@ -14,46 +13,49 @@ namespace Nest public interface ISignificantTextAggregation : IBucketAggregation { /// - /// The field on which to run the aggregation + /// The default source of statistical information for background term + /// frequencies is the entire index. This scope can be narrowed + /// through the use of a background filter to focus in on significant + /// terms within a narrower context /// - [JsonProperty("field")] - Field Field { get; set; } + [JsonProperty("background_filter")] + QueryContainer BackgroundFilter { get; set; } /// - /// Defines how many term buckets should be returned out of the overall - /// terms list + /// Use chi square to calculate significance score /// - [JsonProperty("size")] - int? Size { get; set; } + [JsonProperty("chi_square")] + IChiSquareHeuristic ChiSquare { get; set; } /// - /// Controls the number of candidate terms produced by each shard from which - /// the of terms is selected. + /// Exclude term values for which buckets will be created. /// - [JsonProperty("shard_size")] - int? ShardSize { get; set; } + [JsonProperty("exclude")] + SignificantTermsIncludeExclude Exclude { get; set; } /// - /// Return only terms that match equal to or more than a configurable - /// number of hits + /// Determines the mechanism by which aggregations are executed /// - [JsonProperty("min_doc_count")] - long? MinimumDocumentCount { get; set; } + [JsonProperty("execution_hint")] + TermsAggregationExecutionHint? ExecutionHint { get; set; } /// - /// Regulates the certainty a shard has if the term should actually be added to the candidate - /// list or not with respect to the . - /// Terms will only be considered if their local shard frequency within - /// the set is higher than the . + /// The field on which to run the aggregation /// - [JsonProperty("shard_min_doc_count")] - long? ShardMinimumDocumentCount { get; set; } + [JsonProperty("field")] + Field Field { get; set; } /// - /// Determines the mechanism by which aggregations are executed + /// Whether to filter out near-duplicate text /// - [JsonProperty("execution_hint")] - TermsAggregationExecutionHint? ExecutionHint { get; set; } + [JsonProperty("filter_duplicate_text")] + bool? FilterDuplicateText { get; set; } + + /// + /// Use Google normalized distance to calculate significance score + /// + [JsonProperty("gnd")] + IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } /// /// Include term values for which buckets will be created. @@ -62,10 +64,11 @@ public interface ISignificantTextAggregation : IBucketAggregation SignificantTermsIncludeExclude Include { get; set; } /// - /// Exclude term values for which buckets will be created. + /// Return only terms that match equal to or more than a configurable + /// number of hits /// - [JsonProperty("exclude")] - SignificantTermsIncludeExclude Exclude { get; set; } + [JsonProperty("min_doc_count")] + long? MinimumDocumentCount { get; set; } /// /// Use mutual information to calculate significance score @@ -73,24 +76,14 @@ public interface ISignificantTextAggregation : IBucketAggregation [JsonProperty("mutual_information")] IMutualInformationHeuristic MutualInformation { get; set; } - /// - /// Use chi square to calculate significance score - /// - [JsonProperty("chi_square")] - IChiSquareHeuristic ChiSquare { get; set; } - - /// - /// Use Google normalized distance to calculate significance score - /// - [JsonProperty("gnd")] - IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } - /// /// Use percentage to calculate significance score. - /// A simple calculation of the number of documents in the foreground + /// + /// A simple calculation of the number of documents in the foreground /// sample with a term divided by the number of documents in the background /// with the term. By default this produces a score greater than zero - /// and less than one. + /// and less than one. + /// /// [JsonProperty("percentage")] IPercentageScoreHeuristic PercentageScore { get; set; } @@ -102,19 +95,27 @@ public interface ISignificantTextAggregation : IBucketAggregation IScriptedHeuristic Script { get; set; } /// - /// The default source of statistical information for background term - /// frequencies is the entire index. This scope can be narrowed - /// through the use of a background filter to focus in on significant - /// terms within a narrower context + /// Regulates the certainty a shard has if the term should actually be added to the candidate + /// list or not with respect to the . + /// Terms will only be considered if their local shard frequency within + /// the set is higher than the . /// - [JsonProperty("background_filter")] - QueryContainer BackgroundFilter { get; set; } + [JsonProperty("shard_min_doc_count")] + long? ShardMinimumDocumentCount { get; set; } /// - /// Whether to filter out near-duplicate text + /// Controls the number of candidate terms produced by each shard from which + /// the of terms is selected. /// - [JsonProperty("filter_duplicate_text")] - bool? FilterDuplicateText { get; set; } + [JsonProperty("shard_size")] + int? ShardSize { get; set; } + + /// + /// Defines how many term buckets should be returned out of the overall + /// terms list + /// + [JsonProperty("size")] + int? Size { get; set; } /// /// Ordinarily the indexed field name and the original JSON field being @@ -122,165 +123,185 @@ public interface ISignificantTextAggregation : IBucketAggregation /// mappings using features like copy_to the source JSON field(s) /// and the indexed field being aggregated can differ. /// In these cases it is possible to list the JSON _source fields - /// from which text will be analyzed using + /// from which text will be analyzed using /// [JsonProperty("source_fields")] Fields SourceFields { get; set; } } - /// + /// public class SignificantTextAggregation : BucketAggregationBase, ISignificantTextAggregation { + internal SignificantTextAggregation() { } + + public SignificantTextAggregation(string name) : base(name) { } + /// - public Field Field { get; set; } + public QueryContainer BackgroundFilter { get; set; } + /// - public int? Size { get; set; } + public IChiSquareHeuristic ChiSquare { get; set; } + /// - public int? ShardSize { get; set; } + public SignificantTermsIncludeExclude Exclude { get; set; } + /// - public long? MinimumDocumentCount { get; set; } + public TermsAggregationExecutionHint? ExecutionHint { get; set; } + /// - public long? ShardMinimumDocumentCount { get; set; } + public Field Field { get; set; } + /// - public TermsAggregationExecutionHint? ExecutionHint { get; set; } + public bool? FilterDuplicateText { get; set; } + + /// + public IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } + /// public SignificantTermsIncludeExclude Include { get; set; } + /// - public SignificantTermsIncludeExclude Exclude { get; set; } + public long? MinimumDocumentCount { get; set; } + /// public IMutualInformationHeuristic MutualInformation { get; set; } - /// - public IChiSquareHeuristic ChiSquare { get; set; } - /// - public IGoogleNormalizedDistanceHeuristic GoogleNormalizedDistance { get; set; } + /// public IPercentageScoreHeuristic PercentageScore { get; set; } + /// public IScriptedHeuristic Script { get; set; } + /// - public QueryContainer BackgroundFilter { get; set; } - /// - public bool? FilterDuplicateText { get; set; } + public long? ShardMinimumDocumentCount { get; set; } + /// - public Fields SourceFields { get; set; } + public int? ShardSize { get; set; } - internal SignificantTextAggregation() { } + /// + public int? Size { get; set; } - public SignificantTextAggregation(string name) : base(name) { } + /// + public Fields SourceFields { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.SignificantText = this; } - /// + /// public class SignificantTextAggregationDescriptor : BucketAggregationDescriptorBase, ISignificantTextAggregation, T> , ISignificantTextAggregation where T : class { - Field ISignificantTextAggregation.Field { get; set; } + QueryContainer ISignificantTextAggregation.BackgroundFilter { get; set; } - int? ISignificantTextAggregation.Size { get; set; } + IChiSquareHeuristic ISignificantTextAggregation.ChiSquare { get; set; } - int? ISignificantTextAggregation.ShardSize { get; set; } + SignificantTermsIncludeExclude ISignificantTextAggregation.Exclude { get; set; } - long? ISignificantTextAggregation.MinimumDocumentCount { get; set; } + TermsAggregationExecutionHint? ISignificantTextAggregation.ExecutionHint { get; set; } + Field ISignificantTextAggregation.Field { get; set; } - long? ISignificantTextAggregation.ShardMinimumDocumentCount { get; set; } + bool? ISignificantTextAggregation.FilterDuplicateText { get; set; } - TermsAggregationExecutionHint? ISignificantTextAggregation.ExecutionHint { get; set; } + IGoogleNormalizedDistanceHeuristic ISignificantTextAggregation.GoogleNormalizedDistance { get; set; } SignificantTermsIncludeExclude ISignificantTextAggregation.Include { get; set; } - SignificantTermsIncludeExclude ISignificantTextAggregation.Exclude { get; set; } + long? ISignificantTextAggregation.MinimumDocumentCount { get; set; } IMutualInformationHeuristic ISignificantTextAggregation.MutualInformation { get; set; } - IChiSquareHeuristic ISignificantTextAggregation.ChiSquare { get; set; } - - IGoogleNormalizedDistanceHeuristic ISignificantTextAggregation.GoogleNormalizedDistance { get; set; } - IPercentageScoreHeuristic ISignificantTextAggregation.PercentageScore { get; set; } IScriptedHeuristic ISignificantTextAggregation.Script { get; set; } - QueryContainer ISignificantTextAggregation.BackgroundFilter { get; set; } + long? ISignificantTextAggregation.ShardMinimumDocumentCount { get; set; } - bool? ISignificantTextAggregation.FilterDuplicateText { get; set; } + int? ISignificantTextAggregation.ShardSize { get; set; } + + int? ISignificantTextAggregation.Size { get; set; } Fields ISignificantTextAggregation.SourceFields { get; set; } - /// + /// public SignificantTextAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); - /// + /// public SignificantTextAggregationDescriptor Field(Expression> field) => Assign(a => a.Field = field); - /// + /// public SignificantTextAggregationDescriptor Size(int? size) => Assign(a => a.Size = size); - /// + /// public SignificantTextAggregationDescriptor ExecutionHint(TermsAggregationExecutionHint? hint) => Assign(a => a.ExecutionHint = hint); - /// + /// public SignificantTextAggregationDescriptor Include(string includePattern) => Assign(a => a.Include = new SignificantTermsIncludeExclude(includePattern)); - /// + /// public SignificantTextAggregationDescriptor Include(IEnumerable values) => Assign(a => a.Include = new SignificantTermsIncludeExclude(values)); - /// + /// public SignificantTextAggregationDescriptor Exclude(string excludePattern) => Assign(a => a.Exclude = new SignificantTermsIncludeExclude(excludePattern)); - /// + /// public SignificantTextAggregationDescriptor Exclude(IEnumerable values) => Assign(a => a.Exclude = new SignificantTermsIncludeExclude(values)); - /// + /// public SignificantTextAggregationDescriptor ShardSize(int? shardSize) => Assign(a => a.ShardSize = shardSize); - /// + /// public SignificantTextAggregationDescriptor MinimumDocumentCount(long? minimumDocumentCount) => Assign(a => a.MinimumDocumentCount = minimumDocumentCount); - /// + /// public SignificantTextAggregationDescriptor ShardMinimumDocumentCount(long? shardMinimumDocumentCount) => Assign(a => a.ShardMinimumDocumentCount = shardMinimumDocumentCount); - /// - public SignificantTextAggregationDescriptor MutualInformation(Func mutualInformationSelector = null) => + /// + public SignificantTextAggregationDescriptor MutualInformation( + Func mutualInformationSelector = null + ) => Assign(a => a.MutualInformation = mutualInformationSelector.InvokeOrDefault(new MutualInformationHeuristicDescriptor())); - /// + /// public SignificantTextAggregationDescriptor ChiSquare(Func chiSquareSelector) => Assign(a => a.ChiSquare = chiSquareSelector.InvokeOrDefault(new ChiSquareHeuristicDescriptor())); - /// - public SignificantTextAggregationDescriptor GoogleNormalizedDistance(Func gndSelector) => + /// + public SignificantTextAggregationDescriptor GoogleNormalizedDistance( + Func gndSelector + ) => Assign(a => a.GoogleNormalizedDistance = gndSelector.InvokeOrDefault(new GoogleNormalizedDistanceHeuristicDescriptor())); - /// - public SignificantTextAggregationDescriptor PercentageScore(Func percentageScoreSelector) => + /// + public SignificantTextAggregationDescriptor PercentageScore( + Func percentageScoreSelector + ) => Assign(a => a.PercentageScore = percentageScoreSelector.InvokeOrDefault(new PercentageScoreHeuristicDescriptor())); - /// + /// public SignificantTextAggregationDescriptor Script(Func scriptSelector) => Assign(a => a.Script = scriptSelector?.Invoke(new ScriptedHeuristicDescriptor())); - /// + /// public SignificantTextAggregationDescriptor BackgroundFilter(Func, QueryContainer> selector) => Assign(a => a.BackgroundFilter = selector?.Invoke(new QueryContainerDescriptor())); - /// - public SignificantTextAggregationDescriptor FilterDuplicateText(bool? filterDuplicateText = true) => Assign(a => a.FilterDuplicateText = filterDuplicateText); + /// + public SignificantTextAggregationDescriptor FilterDuplicateText(bool? filterDuplicateText = true) => + Assign(a => a.FilterDuplicateText = filterDuplicateText); - /// + /// public SignificantTextAggregationDescriptor SourceFields(Func, IPromise> sourceFields) => Assign(a => a.SourceFields = sourceFields?.Invoke(new FieldsDescriptor())?.Value); - /// + /// public SignificantTextAggregationDescriptor SourceFields(Fields sourceFields) => Assign(a => a.SourceFields = sourceFields); - } } diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsAggregate.cs b/src/Nest/Aggregations/Bucket/Terms/TermsAggregate.cs index b88eb8e8c73..d177a1d3d40 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsAggregate.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsAggregate.cs @@ -1,9 +1,8 @@ namespace Nest { - public class TermsAggregate : MultiBucketAggregate> - { + public class TermsAggregate : MultiBucketAggregate> + { public long? DocCountErrorUpperBound { get; set; } public long? SumOtherDocCount { get; set; } - - } + } } diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsAggregation.cs b/src/Nest/Aggregations/Bucket/Terms/TermsAggregation.cs index aed0865f013..1b25292a56e 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsAggregation.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsAggregation.cs @@ -9,61 +9,61 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface ITermsAggregation : IBucketAggregation { - [JsonProperty("field")] - Field Field { get; set; } + [JsonProperty("collect_mode")] + TermsAggregationCollectMode? CollectMode { get; set; } - [JsonProperty("script")] - IScript Script { get; set; } + [JsonProperty("exclude")] + TermsExclude Exclude { get; set; } - [JsonProperty("size")] - int? Size { get; set; } + [JsonProperty("execution_hint")] + TermsAggregationExecutionHint? ExecutionHint { get; set; } - [JsonProperty("shard_size")] - int? ShardSize { get; set; } + [JsonProperty("field")] + Field Field { get; set; } + + [JsonProperty("include")] + TermsInclude Include { get; set; } [JsonProperty("min_doc_count")] int? MinimumDocumentCount { get; set; } - [JsonProperty("execution_hint")] - TermsAggregationExecutionHint? ExecutionHint { get; set; } + [JsonProperty("missing")] + object Missing { get; set; } [JsonProperty("order")] IList Order { get; set; } - [JsonProperty("include")] - TermsInclude Include { get; set; } - - [JsonProperty("exclude")] - TermsExclude Exclude { get; set; } + [JsonProperty("script")] + IScript Script { get; set; } - [JsonProperty("collect_mode")] - TermsAggregationCollectMode? CollectMode { get; set; } + [JsonProperty("shard_size")] + int? ShardSize { get; set; } [JsonProperty("show_term_doc_count_error")] bool? ShowTermDocCountError { get; set; } - [JsonProperty("missing")] - object Missing { get; set; } + [JsonProperty("size")] + int? Size { get; set; } } public class TermsAggregation : BucketAggregationBase, ITermsAggregation { - public Field Field { get; set; } - public IScript Script { get; set; } - public int? Size { get; set; } - public int? ShardSize { get; set; } - public int? MinimumDocumentCount { get; set; } + internal TermsAggregation() { } + + public TermsAggregation(string name) : base(name) { } + + public TermsAggregationCollectMode? CollectMode { get; set; } + public TermsExclude Exclude { get; set; } public TermsAggregationExecutionHint? ExecutionHint { get; set; } - public IList Order { get; set; } + public Field Field { get; set; } public TermsInclude Include { get; set; } - public TermsExclude Exclude { get; set; } - public TermsAggregationCollectMode? CollectMode { get; set; } + public int? MinimumDocumentCount { get; set; } public object Missing { get; set; } + public IList Order { get; set; } + public IScript Script { get; set; } + public int? ShardSize { get; set; } public bool? ShowTermDocCountError { get; set; } - - internal TermsAggregation() { } - - public TermsAggregation(string name) : base(name) { } + public int? Size { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.Terms = this; } @@ -72,30 +72,29 @@ public class TermsAggregationDescriptor : BucketAggregationDescriptorBase, ITermsAggregation, T>, ITermsAggregation where T : class { - Field ITermsAggregation.Field { get; set; } + TermsAggregationCollectMode? ITermsAggregation.CollectMode { get; set; } - IScript ITermsAggregation.Script { get; set; } + TermsExclude ITermsAggregation.Exclude { get; set; } - int? ITermsAggregation.Size { get; set; } + TermsAggregationExecutionHint? ITermsAggregation.ExecutionHint { get; set; } + Field ITermsAggregation.Field { get; set; } - int? ITermsAggregation.ShardSize { get; set; } + TermsInclude ITermsAggregation.Include { get; set; } int? ITermsAggregation.MinimumDocumentCount { get; set; } - TermsAggregationExecutionHint? ITermsAggregation.ExecutionHint { get; set; } + object ITermsAggregation.Missing { get; set; } IList ITermsAggregation.Order { get; set; } - TermsInclude ITermsAggregation.Include { get; set; } - - TermsExclude ITermsAggregation.Exclude { get; set; } - - TermsAggregationCollectMode? ITermsAggregation.CollectMode { get; set; } + IScript ITermsAggregation.Script { get; set; } - object ITermsAggregation.Missing { get; set; } + int? ITermsAggregation.ShardSize { get; set; } bool? ITermsAggregation.ShowTermDocCountError { get; set; } + int? ITermsAggregation.Size { get; set; } + public TermsAggregationDescriptor Field(Field field) => Assign(a => a.Field = field); public TermsAggregationDescriptor Field(Expression> field) => Assign(a => a.Field = field); @@ -138,6 +137,7 @@ public TermsAggregationDescriptor CollectMode(TermsAggregationCollectMode? co public TermsAggregationDescriptor Missing(object missing) => Assign(a => a.Missing = missing); - public TermsAggregationDescriptor ShowTermDocCountError(bool? showTermDocCountError = true) => Assign(a => a.ShowTermDocCountError = showTermDocCountError); + public TermsAggregationDescriptor ShowTermDocCountError(bool? showTermDocCountError = true) => + Assign(a => a.ShowTermDocCountError = showTermDocCountError); } } diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsAggregationCollectMode.cs b/src/Nest/Aggregations/Bucket/Terms/TermsAggregationCollectMode.cs index bc394690548..267d86a58ae 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsAggregationCollectMode.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsAggregationCollectMode.cs @@ -11,14 +11,15 @@ namespace Nest public enum TermsAggregationCollectMode { /// - /// Order by using field values directly in order to aggregate data per-bucket + /// Order by using field values directly in order to aggregate data per-bucket /// [EnumMember(Value = "depth_first")] DepthFirst, + /// /// Order by using ordinals of the field values instead of the values themselves /// [EnumMember(Value = "breadth_first")] BreadthFirst } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsAggregationExecutionHint.cs b/src/Nest/Aggregations/Bucket/Terms/TermsAggregationExecutionHint.cs index 533ccfc14f9..146d353040d 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsAggregationExecutionHint.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsAggregationExecutionHint.cs @@ -11,24 +11,27 @@ namespace Nest public enum TermsAggregationExecutionHint { /// - /// Order by using field values directly in order to aggregate data per-bucket + /// Order by using field values directly in order to aggregate data per-bucket /// [EnumMember(Value = "map")] Map, + /// /// Order by using ordinals of the field and preemptively allocating one bucket per ordinal value /// [EnumMember(Value = "global_ordinals")] GlobalOrdinals, + /// /// Order by using ordinals of the field and dynamically allocating one bucket per ordinal value /// [EnumMember(Value = "global_ordinals_hash")] GlobalOrdinalsHash, + /// /// Order by using per-segment ordinals to compute counts and remap these counts to global counts using global ordinals /// [EnumMember(Value = "global_ordinals_low_cardinality")] GlobalOrdinalsLowCardinality } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsExclude.cs b/src/Nest/Aggregations/Bucket/Terms/TermsExclude.cs index 08a4d530eee..e22a7111c76 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsExclude.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsExclude.cs @@ -10,29 +10,29 @@ namespace Nest public class TermsExclude { /// - /// The regular expression pattern to determine terms to exclude from the response - /// - [JsonIgnore] - public string Pattern { get; set; } - - /// - /// Collection of terms to exclude from the response - /// - [JsonIgnore] - public IEnumerable Values { get; set; } - - /// - /// Creates an instance of that uses a regular expression pattern + /// Creates an instance of that uses a regular expression pattern /// to determine the terms to exclude from the response /// /// The regular expression pattern public TermsExclude(string pattern) => Pattern = pattern; /// - /// Creates an instance of that uses a collection of terms + /// Creates an instance of that uses a collection of terms /// to exclude from the response /// /// The exact terms to exclude public TermsExclude(IEnumerable values) => Values = values; + + /// + /// The regular expression pattern to determine terms to exclude from the response + /// + [JsonIgnore] + public string Pattern { get; set; } + + /// + /// Collection of terms to exclude from the response + /// + [JsonIgnore] + public IEnumerable Values { get; set; } } } diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsExcludeJsonConverter.cs b/src/Nest/Aggregations/Bucket/Terms/TermsExcludeJsonConverter.cs index a000ba4bf46..9dbf85881f4 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsExcludeJsonConverter.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsExcludeJsonConverter.cs @@ -40,4 +40,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s writer.WriteValue(termsExclude.Pattern); } } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsInclude.cs b/src/Nest/Aggregations/Bucket/Terms/TermsInclude.cs index b036181c26b..702da055ec4 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsInclude.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsInclude.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Newtonsoft.Json; @@ -11,22 +10,30 @@ namespace Nest public class TermsInclude { /// - /// The regular expression pattern to determine terms to include in the response + /// Creates an instance of that uses a regular expression pattern + /// to determine the terms to include in the response /// - [JsonIgnore] - public string Pattern { get; set; } + /// The regular expression pattern + public TermsInclude(string pattern) => Pattern = pattern; /// - /// Collection of terms to include in the response + /// Creates an instance of that uses a collection of terms + /// to include in the response /// - [JsonIgnore] - public IEnumerable Values { get; set; } + /// The exact terms to include + public TermsInclude(IEnumerable values) => Values = values; /// - /// The current partition of terms we are interested in + /// Creates an instance of that partitions the terms into a number of + /// partitions to receive in multiple requests. Used to process many unique terms /// - [JsonProperty("partition")] - public long? Partition { get; set; } + /// The 0-based partition number for this request + /// The total number of partitions + public TermsInclude(long partition, long numberOfPartitions) + { + Partition = partition; + NumberOfPartitions = numberOfPartitions; + } /// /// The total number of paritions we are interested in @@ -35,29 +42,21 @@ public class TermsInclude public long? NumberOfPartitions { get; set; } /// - /// Creates an instance of that uses a regular expression pattern - /// to determine the terms to include in the response + /// The current partition of terms we are interested in /// - /// The regular expression pattern - public TermsInclude(string pattern) => Pattern = pattern; + [JsonProperty("partition")] + public long? Partition { get; set; } /// - /// Creates an instance of that uses a collection of terms - /// to include in the response + /// The regular expression pattern to determine terms to include in the response /// - /// The exact terms to include - public TermsInclude(IEnumerable values) => Values = values; + [JsonIgnore] + public string Pattern { get; set; } /// - /// Creates an instance of that partitions the terms into a number of - /// partitions to receive in multiple requests. Used to process many unique terms + /// Collection of terms to include in the response /// - /// The 0-based partition number for this request - /// The total number of partitions - public TermsInclude(long partition, long numberOfPartitions) - { - Partition = partition; - NumberOfPartitions = numberOfPartitions; - } + [JsonIgnore] + public IEnumerable Values { get; set; } } } diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsIncludeJsonConverter.cs b/src/Nest/Aggregations/Bucket/Terms/TermsIncludeJsonConverter.cs index 7ce678ef75f..4fa3742f50a 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsIncludeJsonConverter.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsIncludeJsonConverter.cs @@ -16,7 +16,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist switch (reader.TokenType) { case JsonToken.StartArray: - termsInclude =new TermsInclude(serializer.Deserialize>(reader)); + termsInclude = new TermsInclude(serializer.Deserialize>(reader)); break; case JsonToken.StartObject: long partition = 0; diff --git a/src/Nest/Aggregations/Bucket/Terms/TermsOrder.cs b/src/Nest/Aggregations/Bucket/Terms/TermsOrder.cs index b7d77b6c66d..bced94033ce 100644 --- a/src/Nest/Aggregations/Bucket/Terms/TermsOrder.cs +++ b/src/Nest/Aggregations/Bucket/Terms/TermsOrder.cs @@ -6,16 +6,17 @@ namespace Nest [JsonConverter(typeof(KeyValueJsonConverter))] public class TermsOrder { + public static TermsOrder CountAscending => new TermsOrder { Key = "_count", Order = SortOrder.Ascending }; + public static TermsOrder CountDescending => new TermsOrder { Key = "_count", Order = SortOrder.Descending }; public string Key { get; set; } + public static TermsOrder KeyAscending => new TermsOrder { Key = "_key", Order = SortOrder.Ascending }; + public static TermsOrder KeyDescending => new TermsOrder { Key = "_key", Order = SortOrder.Descending }; public SortOrder Order { get; set; } - public static TermsOrder CountAscending => new TermsOrder { Key = "_count", Order = SortOrder.Ascending }; - public static TermsOrder CountDescending => new TermsOrder { Key = "_count", Order = SortOrder.Descending }; [Obsolete("Deprecated in Elasticsearch 6.0. Use KeyAscending")] public static TermsOrder TermAscending => new TermsOrder { Key = "_key", Order = SortOrder.Ascending }; + [Obsolete("Deprecated in Elasticsearch 6.0. Use KeyDescending")] public static TermsOrder TermDescending => new TermsOrder { Key = "_key", Order = SortOrder.Descending }; - public static TermsOrder KeyAscending => new TermsOrder { Key = "_key", Order = SortOrder.Ascending }; - public static TermsOrder KeyDescending => new TermsOrder { Key = "_key", Order = SortOrder.Descending }; } } diff --git a/src/Nest/Aggregations/Matrix/MatrixAggregate.cs b/src/Nest/Aggregations/Matrix/MatrixAggregate.cs index a00055ff240..5673a6e2ba2 100644 --- a/src/Nest/Aggregations/Matrix/MatrixAggregate.cs +++ b/src/Nest/Aggregations/Matrix/MatrixAggregate.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Nest { diff --git a/src/Nest/Aggregations/Matrix/MatrixAggregation.cs b/src/Nest/Aggregations/Matrix/MatrixAggregation.cs index 7e83e05c6c2..d34ce5f4f13 100644 --- a/src/Nest/Aggregations/Matrix/MatrixAggregation.cs +++ b/src/Nest/Aggregations/Matrix/MatrixAggregation.cs @@ -1,10 +1,6 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; +using Newtonsoft.Json; namespace Nest { @@ -21,10 +17,7 @@ public abstract class MatrixAggregationBase : AggregationBase, IMatrixAggregatio { internal MatrixAggregationBase() { } - protected MatrixAggregationBase(string name, Fields field) : base(name) - { - this.Fields = field; - } + protected MatrixAggregationBase(string name, Fields field) : base(name) => Fields = field; public Fields Fields { get; set; } diff --git a/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregate.cs b/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregate.cs index edab5fa89be..db8c28b0fc5 100644 --- a/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregate.cs +++ b/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregate.cs @@ -1,40 +1,34 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Nest { - [JsonObject] public class MatrixStatsField { - [JsonProperty("name")] - public string Name { get; set; } + [JsonProperty("correlation")] + public Dictionary Correlation { get; set; } [JsonProperty("count")] public int Count { get; set; } + [JsonProperty("covariance")] + public Dictionary Covariance { get; set; } + + [JsonProperty("kurtosis")] + public double Kurtosis { get; set; } + [JsonProperty("mean")] public double Mean { get; set; } - [JsonProperty("variance")] - public double Variance { get; set; } + [JsonProperty("name")] + public string Name { get; set; } [JsonProperty("skewness")] public double Skewness { get; set; } - [JsonProperty("kurtosis")] - public double Kurtosis { get; set; } - - [JsonProperty("covariance")] - public Dictionary Covariance { get; set; } - - [JsonProperty("correlation")] - public Dictionary Correlation { get; set; } - + [JsonProperty("variance")] + public double Variance { get; set; } } [JsonObject] diff --git a/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregation.cs b/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregation.cs index 06e550d8f5c..6d9641e51e1 100644 --- a/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregation.cs +++ b/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsAggregation.cs @@ -1,9 +1,4 @@ using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Nest { @@ -28,7 +23,7 @@ public MatrixStatsAggregation(string name, Fields fields) : base(name, fields) { public class MatrixStatsAggregationDescriptor : MatrixAggregationDescriptorBase, IMatrixStatsAggregation, T> - , IMatrixStatsAggregation + , IMatrixStatsAggregation where T : class { MatrixStatsMode? IMatrixStatsAggregation.Mode { get; set; } diff --git a/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsMode.cs b/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsMode.cs index 659b57837f9..9dd08161a70 100644 --- a/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsMode.cs +++ b/src/Nest/Aggregations/Matrix/MatrixStats/MatrixStatsMode.cs @@ -1,11 +1,6 @@ -using Newtonsoft.Json; +using System.Runtime.Serialization; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Nest { @@ -22,21 +17,25 @@ public enum MatrixStatsMode /// [EnumMember(Value = "avg")] Avg, + /// /// Pick the lowest value. /// [EnumMember(Value = "min")] Min, + /// - /// Pick the highest value. + /// Pick the highest value. /// [EnumMember(Value = "max")] Max, + /// /// Use the sum of all values. /// [EnumMember(Value = "sum")] Sum, + /// /// Use the median of all values. /// diff --git a/src/Nest/Aggregations/Metric/Average/AverageAggregation.cs b/src/Nest/Aggregations/Metric/Average/AverageAggregation.cs index 08e77057a23..2539eba4cb1 100644 --- a/src/Nest/Aggregations/Metric/Average/AverageAggregation.cs +++ b/src/Nest/Aggregations/Metric/Average/AverageAggregation.cs @@ -15,8 +15,8 @@ public AverageAggregation(string name, Field field) : base(name, field) { } internal override void WrapInContainer(AggregationContainer c) => c.Average = this; } - public class AverageAggregationDescriptor + public class AverageAggregationDescriptor : MetricAggregationDescriptorBase, IAverageAggregation, T> - , IAverageAggregation + , IAverageAggregation where T : class { } } diff --git a/src/Nest/Aggregations/Metric/Cardinality/CardinalityAggregation.cs b/src/Nest/Aggregations/Metric/Cardinality/CardinalityAggregation.cs index 885a2ea1597..0338ac4a68d 100644 --- a/src/Nest/Aggregations/Metric/Cardinality/CardinalityAggregation.cs +++ b/src/Nest/Aggregations/Metric/Cardinality/CardinalityAggregation.cs @@ -15,13 +15,13 @@ public interface ICardinalityAggregation : IMetricAggregation public class CardinalityAggregation : MetricAggregationBase, ICardinalityAggregation { - public int? PrecisionThreshold { get; set; } - public bool? Rehash { get; set; } - internal CardinalityAggregation() { } public CardinalityAggregation(string name, Field field) : base(name, field) { } + public int? PrecisionThreshold { get; set; } + public bool? Rehash { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.Cardinality = this; } @@ -38,6 +38,5 @@ public CardinalityAggregationDescriptor PrecisionThreshold(int? precisionThre => Assign(a => a.PrecisionThreshold = precisionThreshold); public CardinalityAggregationDescriptor Rehash(bool? rehash = true) => Assign(a => a.Rehash = rehash); - } } diff --git a/src/Nest/Aggregations/Metric/ExtendedStats/ExtendedStatsAggregate.cs b/src/Nest/Aggregations/Metric/ExtendedStats/ExtendedStatsAggregate.cs index 8945ccf3b1e..fdec3f71267 100644 --- a/src/Nest/Aggregations/Metric/ExtendedStats/ExtendedStatsAggregate.cs +++ b/src/Nest/Aggregations/Metric/ExtendedStats/ExtendedStatsAggregate.cs @@ -2,20 +2,20 @@ { public class ExtendedStatsAggregate : MetricAggregateBase { + public double? Average { get; set; } public long Count { get; set; } - public double? Min { get; set; } public double? Max { get; set; } - public double? Average { get; set; } + public double? Min { get; set; } + public double? StdDeviation { get; set; } + public StandardDeviationBounds StdDeviationBounds { get; set; } public double? Sum { get; set; } public double? SumOfSquares { get; set; } public double? Variance { get; set; } - public double? StdDeviation { get; set; } - public StandardDeviationBounds StdDeviationBounds { get; set; } } public class StandardDeviationBounds { - public double? Upper { get; set; } public double? Lower { get; set; } + public double? Upper { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregate.cs b/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregate.cs index 9fde9789ed0..3aee6736de4 100644 --- a/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregate.cs +++ b/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregate.cs @@ -2,17 +2,14 @@ { public class GeoBoundsAggregate : MetricAggregateBase { - public GeoBoundsAggregate() - { - Bounds = new GeoBounds(); - } + public GeoBoundsAggregate() => Bounds = new GeoBounds(); public GeoBounds Bounds { get; set; } } public class GeoBounds { - public LatLon TopLeft { get; set; } public LatLon BottomRight { get; set; } + public LatLon TopLeft { get; set; } } } diff --git a/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregation.cs b/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregation.cs index 5393c6f5f74..6ea24ed1e6e 100644 --- a/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregation.cs +++ b/src/Nest/Aggregations/Metric/GeoBounds/GeoBoundsAggregation.cs @@ -12,12 +12,12 @@ public interface IGeoBoundsAggregation : IMetricAggregation public class GeoBoundsAggregation : MetricAggregationBase, IGeoBoundsAggregation { - public bool? WrapLongitude { get; set; } - internal GeoBoundsAggregation() { } public GeoBoundsAggregation(string name, Field field) : base(name, field) { } + public bool? WrapLongitude { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.GeoBounds = this; } diff --git a/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregate.cs b/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregate.cs index 079f967607c..fbbf81a39cf 100644 --- a/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregate.cs +++ b/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregate.cs @@ -4,9 +4,10 @@ namespace Nest { public class GeoCentroidAggregate : MetricAggregateBase { - [JsonProperty("location")] - public GeoLocation Location { get; set; } [JsonProperty("count")] public long Count { get; set; } + + [JsonProperty("location")] + public GeoLocation Location { get; set; } } } diff --git a/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregation.cs b/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregation.cs index 43ef8ee3ca8..d653ea65313 100644 --- a/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregation.cs +++ b/src/Nest/Aggregations/Metric/GeoCentroid/GeoCentroidAggregation.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -23,7 +18,5 @@ public GeoCentroidAggregation(string name, Field field) : base(name, field) { } public class GeoCentroidAggregationDescriptor : MetricAggregationDescriptorBase, IGeoCentroidAggregation, T> , IGeoCentroidAggregation - where T : class - { - } + where T : class { } } diff --git a/src/Nest/Aggregations/Metric/Max/MaxAggregation.cs b/src/Nest/Aggregations/Metric/Max/MaxAggregation.cs index 5cf419108a4..5b9599a4715 100644 --- a/src/Nest/Aggregations/Metric/Max/MaxAggregation.cs +++ b/src/Nest/Aggregations/Metric/Max/MaxAggregation.cs @@ -15,8 +15,8 @@ public MaxAggregation(string name, Field field) : base(name, field) { } internal override void WrapInContainer(AggregationContainer c) => c.Max = this; } - public class MaxAggregationDescriptor + public class MaxAggregationDescriptor : MetricAggregationDescriptorBase, IMaxAggregation, T> - , IMaxAggregation + , IMaxAggregation where T : class { } } diff --git a/src/Nest/Aggregations/Metric/MetricAggregate.cs b/src/Nest/Aggregations/Metric/MetricAggregate.cs index ef6b67b8fba..81d5b53e8b0 100644 --- a/src/Nest/Aggregations/Metric/MetricAggregate.cs +++ b/src/Nest/Aggregations/Metric/MetricAggregate.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; namespace Nest @@ -7,6 +6,6 @@ namespace Nest public abstract class MetricAggregateBase : IAggregate { [JsonProperty("meta")] - public IReadOnlyDictionary Meta { get; set; } = EmptyReadOnly.Dictionary; + public IReadOnlyDictionary Meta { get; set; } = EmptyReadOnly.Dictionary; } } diff --git a/src/Nest/Aggregations/Metric/MetricAggregation.cs b/src/Nest/Aggregations/Metric/MetricAggregation.cs index eb429e81b02..d8141e0748b 100644 --- a/src/Nest/Aggregations/Metric/MetricAggregation.cs +++ b/src/Nest/Aggregations/Metric/MetricAggregation.cs @@ -10,40 +10,40 @@ public interface IMetricAggregation : IAggregation [JsonProperty("field")] Field Field { get; set; } - [JsonProperty("script")] - IScript Script { get; set; } - [JsonProperty("missing")] double? Missing { get; set; } + + [JsonProperty("script")] + IScript Script { get; set; } } public abstract class MetricAggregationBase : AggregationBase, IMetricAggregation { internal MetricAggregationBase() { } - protected MetricAggregationBase(string name, Field field) : base(name) => this.Field = field; + protected MetricAggregationBase(string name, Field field) : base(name) => Field = field; public Field Field { get; set; } - public virtual IScript Script { get; set; } public double? Missing { get; set; } + public virtual IScript Script { get; set; } } public abstract class MetricAggregationDescriptorBase - : DescriptorBase, IMetricAggregation + : DescriptorBase, IMetricAggregation where TMetricAggregation : MetricAggregationDescriptorBase - , TMetricAggregationInterface, IMetricAggregation + , TMetricAggregationInterface, IMetricAggregation where T : class where TMetricAggregationInterface : class, IMetricAggregation { Field IMetricAggregation.Field { get; set; } - IScript IMetricAggregation.Script { get; set; } + IDictionary IAggregation.Meta { get; set; } double? IMetricAggregation.Missing { get; set; } string IAggregation.Name { get; set; } - IDictionary IAggregation.Meta { get; set; } + IScript IMetricAggregation.Script { get; set; } public TMetricAggregation Field(Field field) => Assign(a => a.Field = field); diff --git a/src/Nest/Aggregations/Metric/Min/MinAggregation.cs b/src/Nest/Aggregations/Metric/Min/MinAggregation.cs index 39e5545979d..bd804f481d3 100644 --- a/src/Nest/Aggregations/Metric/Min/MinAggregation.cs +++ b/src/Nest/Aggregations/Metric/Min/MinAggregation.cs @@ -15,8 +15,8 @@ public MinAggregation(string name, Field field) : base(name, field) { } internal override void WrapInContainer(AggregationContainer c) => c.Min = this; } - public class MinAggregationDescriptor + public class MinAggregationDescriptor : MetricAggregationDescriptorBase, IMinAggregation, T> - , IMinAggregation + , IMinAggregation where T : class { } } diff --git a/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregation.cs b/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregation.cs index 496af2553a2..fc26bf8b125 100644 --- a/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregation.cs +++ b/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregation.cs @@ -7,29 +7,28 @@ namespace Nest [ContractJsonConverter(typeof(PercentileRanksAggregationJsonConverter))] public interface IPercentileRanksAggregation : IMetricAggregation { - IEnumerable Values { get; set; } IPercentilesMethod Method { get; set; } + IEnumerable Values { get; set; } } public class PercentileRanksAggregation : MetricAggregationBase, IPercentileRanksAggregation { - public IEnumerable Values { get; set; } - public IPercentilesMethod Method { get; set; } - internal PercentileRanksAggregation() { } public PercentileRanksAggregation(string name, Field field) : base(name, field) { } + public IPercentilesMethod Method { get; set; } + public IEnumerable Values { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.PercentileRanks = this; } - public class PercentileRanksAggregationDescriptor + public class PercentileRanksAggregationDescriptor : MetricAggregationDescriptorBase, IPercentileRanksAggregation, T>, IPercentileRanksAggregation where T : class { - IEnumerable IPercentileRanksAggregation.Values { get; set; } - IPercentilesMethod IPercentileRanksAggregation.Method { get; set; } + IEnumerable IPercentileRanksAggregation.Values { get; set; } public PercentileRanksAggregationDescriptor Values(IEnumerable values) => Assign(a => a.Values = values?.ToList()); diff --git a/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregationJsonConverter.cs b/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregationJsonConverter.cs index 72b15201678..cc3546fcc2f 100644 --- a/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregationJsonConverter.cs +++ b/src/Nest/Aggregations/Metric/PercentileRanks/PercentileRanksAggregationJsonConverter.cs @@ -19,13 +19,16 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist percentileRanks.Method = ReadMethodProperty(properties); if (properties.ContainsKey("values")) percentileRanks.Values = properties["values"].ToObject>(); - return percentileRanks;; + return percentileRanks; + + ; } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var percentileRanks = value as IPercentileRanksAggregation; if (percentileRanks == null) return; + writer.WriteStartObject(); WriteMetricProperties(percentileRanks, writer, serializer); if (percentileRanks.Values != null) diff --git a/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregation.cs b/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregation.cs index 886c0c5c2d7..4ad15f7cfa3 100644 --- a/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregation.cs +++ b/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregation.cs @@ -7,38 +7,37 @@ namespace Nest [ContractJsonConverter(typeof(PercentilesAggregationJsonConverter))] public interface IPercentilesAggregation : IMetricAggregation { - IEnumerable Percents { get; set; } IPercentilesMethod Method { get; set; } + IEnumerable Percents { get; set; } } public class PercentilesAggregation : MetricAggregationBase, IPercentilesAggregation { - public IEnumerable Percents { get; set; } - public IPercentilesMethod Method { get; set; } - internal PercentilesAggregation() { } - public PercentilesAggregation(string name, Field field) : base(name, field) { } + public PercentilesAggregation(string name, Field field) : base(name, field) { } + + public IPercentilesMethod Method { get; set; } + public IEnumerable Percents { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.Percentiles = this; } - public class PercentilesAggregationDescriptor + public class PercentilesAggregationDescriptor : MetricAggregationDescriptorBase, IPercentilesAggregation, T> - , IPercentilesAggregation + , IPercentilesAggregation where T : class { - IEnumerable IPercentilesAggregation.Percents { get; set; } - IPercentilesMethod IPercentilesAggregation.Method { get; set; } + IEnumerable IPercentilesAggregation.Percents { get; set; } - public PercentilesAggregationDescriptor Percents(IEnumerable percentages) => + public PercentilesAggregationDescriptor Percents(IEnumerable percentages) => Assign(a => a.Percents = percentages?.ToList()); - public PercentilesAggregationDescriptor Percents(params double[] percentages) => + public PercentilesAggregationDescriptor Percents(params double[] percentages) => Assign(a => a.Percents = percentages?.ToList()); - public PercentilesAggregationDescriptor Method(Func methodSelector) => + public PercentilesAggregationDescriptor Method(Func methodSelector) => Assign(a => a.Method = methodSelector?.Invoke(new PercentilesMethodDescriptor())); } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregationJsonConverter.cs b/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregationJsonConverter.cs index aed0f3b634a..457bda12d8f 100644 --- a/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregationJsonConverter.cs +++ b/src/Nest/Aggregations/Metric/Percentiles/PercentilesAggregationJsonConverter.cs @@ -54,6 +54,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { var percentiles = value as IPercentilesAggregation; if (percentiles == null) return; + writer.WriteStartObject(); WriteMetricProperties(percentiles, writer, serializer); if (percentiles.Percents != null) @@ -98,7 +99,6 @@ protected void WriteMethodProperty(IPercentilesMethod method, JsonWriter writer, protected void WriteMetricProperties(IMetricAggregation metric, JsonWriter writer, JsonSerializer serializer) { - if (metric.Field != null) { var settings = serializer.GetConnectionSettings(); diff --git a/src/Nest/Aggregations/Metric/Percentiles/PercentilesMetricAggregate.cs b/src/Nest/Aggregations/Metric/Percentiles/PercentilesMetricAggregate.cs index 044418220b6..d50b0e75b78 100644 --- a/src/Nest/Aggregations/Metric/Percentiles/PercentilesMetricAggregate.cs +++ b/src/Nest/Aggregations/Metric/Percentiles/PercentilesMetricAggregate.cs @@ -2,7 +2,6 @@ namespace Nest { - public class PercentileItem { public double Percentile { get; internal set; } @@ -13,4 +12,4 @@ public class PercentilesAggregate : MetricAggregateBase { public IList Items { get; internal set; } = new List(); } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregate.cs b/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregate.cs index 097b26e8493..fe9e9c88697 100644 --- a/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregate.cs +++ b/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregate.cs @@ -1,24 +1,21 @@ - -using System; -using Newtonsoft.Json.Linq; +using System; namespace Nest { public class ScriptedMetricAggregate : MetricAggregateBase { private readonly object _value; + internal ScriptedMetricAggregate(object value) => _value = value; + public ScriptedMetricAggregate() { } /// /// Get the result of the scripted metric aggregation as T /// /// The type that best represents the result of your scripted metric aggrgation - public T Value() - { - return this._value is LazyDocument lazyDocument - ? lazyDocument.As() - : (T)Convert.ChangeType(this._value, typeof(T)); - } + public T Value() => _value is LazyDocument lazyDocument + ? lazyDocument.As() + : (T)Convert.ChangeType(_value, typeof(T)); } } diff --git a/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregation.cs b/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregation.cs index 4462e7fb1d3..c458c49161c 100644 --- a/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregation.cs +++ b/src/Nest/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregation.cs @@ -8,64 +8,70 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IScriptedMetricAggregation : IMetricAggregation { + [JsonProperty("combine_script")] + IScript CombineScript { get; set; } + [JsonProperty("init_script")] IScript InitScript { get; set; } - + [JsonProperty("map_script")] IScript MapScript { get; set; } - [JsonProperty("combine_script")] - IScript CombineScript { get; set; } + [JsonProperty("params")] + IDictionary Params { get; set; } [JsonProperty("reduce_script")] IScript ReduceScript { get; set; } - - [JsonProperty("params")] - IDictionary Params { get; set; } } public class ScriptedMetricAggregation : MetricAggregationBase, IScriptedMetricAggregation { - public IScript InitScript { get; set; } - public IScript MapScript { get; set; } - public IScript CombineScript { get; set; } - public IScript ReduceScript { get; set; } - public IDictionary Params { get; set; } - internal ScriptedMetricAggregation() { } public ScriptedMetricAggregation(string name) : base(name, null) { } + public IScript CombineScript { get; set; } + public IScript InitScript { get; set; } + public IScript MapScript { get; set; } + public IDictionary Params { get; set; } + public IScript ReduceScript { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.ScriptedMetric = this; } + public class ScriptedMetricAggregationDescriptor : MetricAggregationDescriptorBase, IScriptedMetricAggregation, T> - , IScriptedMetricAggregation + , IScriptedMetricAggregation where T : class { + IScript IScriptedMetricAggregation.CombineScript { get; set; } IScript IScriptedMetricAggregation.InitScript { get; set; } IScript IScriptedMetricAggregation.MapScript { get; set; } - IScript IScriptedMetricAggregation.CombineScript { get; set; } - IScript IScriptedMetricAggregation.ReduceScript { get; set; } IDictionary IScriptedMetricAggregation.Params { get; set; } + IScript IScriptedMetricAggregation.ReduceScript { get; set; } public ScriptedMetricAggregationDescriptor InitScript(string script) => Assign(a => a.InitScript = (InlineScript)script); - public ScriptedMetricAggregationDescriptor InitScript(Func scriptSelector) => + + public ScriptedMetricAggregationDescriptor InitScript(Func scriptSelector) => Assign(a => a.InitScript = scriptSelector?.Invoke(new ScriptDescriptor())); public ScriptedMetricAggregationDescriptor MapScript(string script) => Assign(a => a.MapScript = (InlineScript)script); - public ScriptedMetricAggregationDescriptor MapScript(Func scriptSelector) => + + public ScriptedMetricAggregationDescriptor MapScript(Func scriptSelector) => Assign(a => a.MapScript = scriptSelector?.Invoke(new ScriptDescriptor())); public ScriptedMetricAggregationDescriptor CombineScript(string script) => Assign(a => a.CombineScript = (InlineScript)script); - public ScriptedMetricAggregationDescriptor CombineScript(Func scriptSelector) => + + public ScriptedMetricAggregationDescriptor CombineScript(Func scriptSelector) => Assign(a => a.CombineScript = scriptSelector?.Invoke(new ScriptDescriptor())); public ScriptedMetricAggregationDescriptor ReduceScript(string script) => Assign(a => a.ReduceScript = (InlineScript)script); - public ScriptedMetricAggregationDescriptor ReduceScript(Func scriptSelector) => + + public ScriptedMetricAggregationDescriptor ReduceScript(Func scriptSelector) => Assign(a => a.ReduceScript = scriptSelector?.Invoke(new ScriptDescriptor())); - public ScriptedMetricAggregationDescriptor Params(Func, FluentDictionary> paramSelector) => - Assign(a => a.Params = paramSelector?.Invoke(new FluentDictionary())); + public ScriptedMetricAggregationDescriptor + Params(Func, FluentDictionary> paramSelector) => + Assign(a => a.Params = paramSelector?.Invoke(new FluentDictionary())); } } diff --git a/src/Nest/Aggregations/Metric/Stats/StatsAggregate.cs b/src/Nest/Aggregations/Metric/Stats/StatsAggregate.cs index 84eb9d6c805..33eff2af25c 100644 --- a/src/Nest/Aggregations/Metric/Stats/StatsAggregate.cs +++ b/src/Nest/Aggregations/Metric/Stats/StatsAggregate.cs @@ -2,10 +2,10 @@ { public class StatsAggregate : MetricAggregateBase { + public double? Average { get; set; } public long Count { get; set; } - public double? Min { get; set; } public double? Max { get; set; } - public double? Average { get; set; } + public double? Min { get; set; } public double? Sum { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Metric/Sum/SumAggregation.cs b/src/Nest/Aggregations/Metric/Sum/SumAggregation.cs index c55dc191a35..148928447cd 100644 --- a/src/Nest/Aggregations/Metric/Sum/SumAggregation.cs +++ b/src/Nest/Aggregations/Metric/Sum/SumAggregation.cs @@ -15,8 +15,8 @@ public SumAggregation(string name, Field field) : base(name, field) { } internal override void WrapInContainer(AggregationContainer c) => c.Sum = this; } - public class SumAggregationDescriptor + public class SumAggregationDescriptor : MetricAggregationDescriptorBase, ISumAggregation, T> - , ISumAggregation + , ISumAggregation where T : class { } } diff --git a/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregate.cs b/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregate.cs index 1050b9130fa..31cc245237f 100644 --- a/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregate.cs +++ b/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregate.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace Nest { @@ -9,25 +7,22 @@ public class TopHitsAggregate : MetricAggregateBase { private readonly IList _hits; - public long Total { get; set; } + public TopHitsAggregate() { } - public double? MaxScore { get; set; } + internal TopHitsAggregate(IList hits) => _hits = hits; - public TopHitsAggregate() { } + public double? MaxScore { get; set; } - internal TopHitsAggregate(IList hits) - { - _hits = hits; - } + public long Total { get; set; } private IEnumerable> ConvertHits() where TDocument : class => _hits.Select(h => h.As>()); public IReadOnlyCollection> Hits() where TDocument : class => - this.ConvertHits().ToList().AsReadOnly(); + ConvertHits().ToList().AsReadOnly(); public IReadOnlyCollection Documents() where TDocument : class => - this.ConvertHits().Select(h => h.Source).ToList().AsReadOnly(); + ConvertHits().Select(h => h.Source).ToList().AsReadOnly(); } } diff --git a/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregation.cs b/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregation.cs index 9ec0eba2196..2575cbdd36e 100644 --- a/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregation.cs +++ b/src/Nest/Aggregations/Metric/TopHits/TopHitsAggregation.cs @@ -8,9 +8,22 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface ITopHitsAggregation : IMetricAggregation { + [JsonProperty("docvalue_fields")] + Fields DocValueFields { get; set; } + + [JsonProperty("explain")] + bool? Explain { get; set; } + [JsonProperty("from")] int? From { get; set; } + [JsonProperty("highlight")] + IHighlight Highlight { get; set; } + + [JsonProperty("script_fields")] + [JsonConverter(typeof(ReadAsTypeJsonConverter))] + IScriptFields ScriptFields { get; set; } + [JsonProperty("size")] int? Size { get; set; } @@ -20,46 +33,33 @@ public interface ITopHitsAggregation : IMetricAggregation [JsonProperty("_source")] Union Source { get; set; } - [JsonProperty("highlight")] - IHighlight Highlight { get; set; } - - [JsonProperty("explain")] - bool? Explain { get; set; } - - [JsonProperty("script_fields")] - [JsonConverter(typeof(ReadAsTypeJsonConverter))] - IScriptFields ScriptFields { get; set; } - [JsonProperty("stored_fields")] Fields StoredFields { get; set; } - [JsonProperty("docvalue_fields")] - Fields DocValueFields { get; set; } + [JsonProperty("track_scores")] + bool? TrackScores { get; set; } [JsonProperty("version")] bool? Version { get; set; } - - [JsonProperty("track_scores")] - bool? TrackScores { get; set; } } public class TopHitsAggregation : MetricAggregationBase, ITopHitsAggregation { + internal TopHitsAggregation() { } + + public TopHitsAggregation(string name) : base(name, null) { } + + public Fields DocValueFields { get; set; } + public bool? Explain { get; set; } public int? From { get; set; } + public IHighlight Highlight { get; set; } + public IScriptFields ScriptFields { get; set; } public int? Size { get; set; } public IList Sort { get; set; } public Union Source { get; set; } - public IHighlight Highlight { get; set; } - public bool? Explain { get; set; } - public IScriptFields ScriptFields { get; set; } public Fields StoredFields { get; set; } - public bool? Version { get; set; } public bool? TrackScores { get; set; } - public Fields DocValueFields { get; set; } - - internal TopHitsAggregation() { } - - public TopHitsAggregation(string name) : base(name, null) { } + public bool? Version { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.TopHits = this; } @@ -69,27 +69,26 @@ public class TopHitsAggregationDescriptor , ITopHitsAggregation where T : class { + Fields ITopHitsAggregation.DocValueFields { get; set; } + + bool? ITopHitsAggregation.Explain { get; set; } int? ITopHitsAggregation.From { get; set; } + IHighlight ITopHitsAggregation.Highlight { get; set; } + + IScriptFields ITopHitsAggregation.ScriptFields { get; set; } + int? ITopHitsAggregation.Size { get; set; } IList ITopHitsAggregation.Sort { get; set; } Union ITopHitsAggregation.Source { get; set; } - IHighlight ITopHitsAggregation.Highlight { get; set; } - - bool? ITopHitsAggregation.Explain { get; set; } - - IScriptFields ITopHitsAggregation.ScriptFields { get; set; } - Fields ITopHitsAggregation.StoredFields { get; set; } - bool? ITopHitsAggregation.Version { get; set; } - bool? ITopHitsAggregation.TrackScores { get; set; } - Fields ITopHitsAggregation.DocValueFields { get; set; } + bool? ITopHitsAggregation.Version { get; set; } public TopHitsAggregationDescriptor From(int? from) => Assign(a => a.From = from); diff --git a/src/Nest/Aggregations/Metric/ValueCount/ValueCountAggregation.cs b/src/Nest/Aggregations/Metric/ValueCount/ValueCountAggregation.cs index 5c90cd111e0..1efdf709877 100644 --- a/src/Nest/Aggregations/Metric/ValueCount/ValueCountAggregation.cs +++ b/src/Nest/Aggregations/Metric/ValueCount/ValueCountAggregation.cs @@ -2,7 +2,6 @@ namespace Nest { - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IValueCountAggregation : IMetricAggregation { } @@ -16,8 +15,8 @@ public ValueCountAggregation(string name, Field field) : base(name, field) { } internal override void WrapInContainer(AggregationContainer c) => c.ValueCount = this; } - public class ValueCountAggregationDescriptor + public class ValueCountAggregationDescriptor : MetricAggregationDescriptorBase, IValueCountAggregation, T> - , IValueCountAggregation + , IValueCountAggregation where T : class { } -} \ No newline at end of file +} diff --git a/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageAggregation.cs b/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageAggregation.cs index 678fd785b31..fd2ee0e8d6c 100644 --- a/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageAggregation.cs +++ b/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageAggregation.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq.Expressions; using Newtonsoft.Json; namespace Nest @@ -9,35 +8,42 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IWeightedAverageAggregation : IAggregation { - /// The configuration for the field or script that provides the values - [JsonProperty("value")] - IWeightedAverageValue Value { get; set; } - /// The configuration for the field or script that provides the weights - [JsonProperty("weight")] - IWeightedAverageValue Weight { get; set; } /// The optional numeric response formatter [JsonProperty("format")] string Format { get; set; } + + /// The configuration for the field or script that provides the values + [JsonProperty("value")] + IWeightedAverageValue Value { get; set; } + /// A hint about the values for pure scripts or unmapped fields [JsonProperty("value_type")] ValueType? ValueType { get; set; } + + /// The configuration for the field or script that provides the weights + [JsonProperty("weight")] + IWeightedAverageValue Weight { get; set; } } public class WeightedAverageAggregation : AggregationBase, IWeightedAverageAggregation { internal WeightedAverageAggregation() { } + public WeightedAverageAggregation(string name) : base(name) { } - internal override void WrapInContainer(AggregationContainer c) => c.WeightedAverage = this; + /// + public string Format { get; set; } - /// + /// public IWeightedAverageValue Value { get; set; } - /// - public IWeightedAverageValue Weight { get; set; } - /// - public string Format { get; set; } - /// + + /// public ValueType? ValueType { get; set; } + + /// + public IWeightedAverageValue Weight { get; set; } + + internal override void WrapInContainer(AggregationContainer c) => c.WeightedAverage = this; } public class WeightedAverageAggregationDescriptor @@ -45,29 +51,29 @@ public class WeightedAverageAggregationDescriptor , IWeightedAverageAggregation where T : class { - IWeightedAverageValue IWeightedAverageAggregation.Value { get; set; } - IWeightedAverageValue IWeightedAverageAggregation.Weight { get; set; } string IWeightedAverageAggregation.Format { get; set; } - ValueType? IWeightedAverageAggregation.ValueType { get; set; } - string IAggregation.Name { get; set; } IDictionary IAggregation.Meta { get; set; } + string IAggregation.Name { get; set; } + IWeightedAverageValue IWeightedAverageAggregation.Value { get; set; } + ValueType? IWeightedAverageAggregation.ValueType { get; set; } + IWeightedAverageValue IWeightedAverageAggregation.Weight { get; set; } - /// + /// public WeightedAverageAggregationDescriptor Meta(Func, FluentDictionary> selector) => Assign(a => a.Meta = selector?.Invoke(new FluentDictionary())); - /// + /// public WeightedAverageAggregationDescriptor Value(Func, IWeightedAverageValue> selector) => Assign(a => a.Value = selector?.Invoke(new WeightedAverageValueDescriptor())); - /// + /// public WeightedAverageAggregationDescriptor Weight(Func, IWeightedAverageValue> selector) => Assign(a => a.Weight = selector?.Invoke(new WeightedAverageValueDescriptor())); - /// + /// public WeightedAverageAggregationDescriptor Format(string format) => Assign(a => a.Format = format); - /// + /// public WeightedAverageAggregationDescriptor ValueType(ValueType? valueType) => Assign(a => a.ValueType = valueType); } } diff --git a/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageValue.cs b/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageValue.cs index 8c83af09915..65476b99674 100644 --- a/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageValue.cs +++ b/src/Nest/Aggregations/Metric/WeightedAverage/WeightedAverageValue.cs @@ -8,7 +8,7 @@ namespace Nest { /// /// The configuration for a field or scrip that provides a value or weight - /// for + /// for /// [JsonObject(MemberSerialization = MemberSerialization.OptIn)] [ContractJsonConverter(typeof(ReadAsTypeJsonConverter))] @@ -20,12 +20,6 @@ public interface IWeightedAverageValue [JsonProperty("field")] Field Field { get; set; } - /// - /// A script to derive the value and the weight from - /// - [JsonProperty("script")] - IScript Script { get; set; } - /// /// defines how documents that are missing a value should be treated. /// The default behavior is different for value and weight: @@ -35,31 +29,42 @@ public interface IWeightedAverageValue /// [JsonProperty("missing")] double? Missing { get; set; } + + /// + /// A script to derive the value and the weight from + /// + [JsonProperty("script")] + IScript Script { get; set; } } /// public class WeightedAverageValue : IWeightedAverageValue { internal WeightedAverageValue() { } - public WeightedAverageValue(Field field) => this.Field = field; - public WeightedAverageValue(IScript script) => this.Script = script; + + public WeightedAverageValue(Field field) => Field = field; + + public WeightedAverageValue(IScript script) => Script = script; /// public Field Field { get; set; } - /// - public IScript Script { get; set; } + /// public double? Missing { get; set; } + + /// + public IScript Script { get; set; } } /// - public class WeightedAverageValueDescriptor : DescriptorBase, IWeightedAverageValue> + public class WeightedAverageValueDescriptor + : DescriptorBase, IWeightedAverageValue> , IWeightedAverageValue where T : class { Field IWeightedAverageValue.Field { get; set; } - IScript IWeightedAverageValue.Script { get; set; } double? IWeightedAverageValue.Missing { get; set; } + IScript IWeightedAverageValue.Script { get; set; } /// public WeightedAverageValueDescriptor Field(Field field) => Assign(a => a.Field = field); @@ -86,20 +91,28 @@ public enum ValueType { /// A string value [EnumMember(Value = "string")] String, + /// A long value that can be used to represent byte, short, integer and long [EnumMember(Value = "long")] Long, + /// A double value that can be used to represent float and double [EnumMember(Value = "double")] Double, + /// A number value [EnumMember(Value = "number")] Number, + /// A date value [EnumMember(Value = "date")] Date, + /// An IP value [EnumMember(Value = "ip")] Ip, + /// A numeric value [EnumMember(Value = "numeric")] Numeric, + /// A geo_point value [EnumMember(Value = "geo_point")] GeoPoint, + /// A boolean value [EnumMember(Value = "boolean")] Boolean, } diff --git a/src/Nest/Aggregations/Pipeline/AverageBucket/AverageBucketAggregation.cs b/src/Nest/Aggregations/Pipeline/AverageBucket/AverageBucketAggregation.cs index 332ea99e201..f80d70e283b 100644 --- a/src/Nest/Aggregations/Pipeline/AverageBucket/AverageBucketAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/AverageBucket/AverageBucketAggregation.cs @@ -9,7 +9,7 @@ public interface IAverageBucketAggregation : IPipelineAggregation { } public class AverageBucketAggregation : PipelineAggregationBase, IAverageBucketAggregation { - internal AverageBucketAggregation () { } + internal AverageBucketAggregation() { } public AverageBucketAggregation(string name, SingleBucketsPath bucketsPath) : base(name, bucketsPath) { } @@ -19,7 +19,5 @@ public AverageBucketAggregation(string name, SingleBucketsPath bucketsPath) public class AverageBucketAggregationDescriptor : PipelineAggregationDescriptorBase - , IAverageBucketAggregation - { - } + , IAverageBucketAggregation { } } diff --git a/src/Nest/Aggregations/Pipeline/BucketScript/BucketScriptAggregation.cs b/src/Nest/Aggregations/Pipeline/BucketScript/BucketScriptAggregation.cs index b38f5c76636..5ee0fe01538 100644 --- a/src/Nest/Aggregations/Pipeline/BucketScript/BucketScriptAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/BucketScript/BucketScriptAggregation.cs @@ -14,19 +14,19 @@ public interface IBucketScriptAggregation : IPipelineAggregation public class BucketScriptAggregation : PipelineAggregationBase, IBucketScriptAggregation { - public IScript Script { get; set; } - - internal BucketScriptAggregation () { } + internal BucketScriptAggregation() { } public BucketScriptAggregation(string name, MultiBucketsPath bucketsPath) : base(name, bucketsPath) { } + public IScript Script { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.BucketScript = this; } public class BucketScriptAggregationDescriptor : PipelineAggregationDescriptorBase - , IBucketScriptAggregation + , IBucketScriptAggregation { IScript IBucketScriptAggregation.Script { get; set; } diff --git a/src/Nest/Aggregations/Pipeline/BucketSelector/BucketSelectorAggregation.cs b/src/Nest/Aggregations/Pipeline/BucketSelector/BucketSelectorAggregation.cs index e6a2f4e652e..ecd50dd9c59 100644 --- a/src/Nest/Aggregations/Pipeline/BucketSelector/BucketSelectorAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/BucketSelector/BucketSelectorAggregation.cs @@ -14,19 +14,19 @@ public interface IBucketSelectorAggregation : IPipelineAggregation public class BucketSelectorAggregation : PipelineAggregationBase, IBucketSelectorAggregation { - public IScript Script { get; set; } - - internal BucketSelectorAggregation () { } + internal BucketSelectorAggregation() { } public BucketSelectorAggregation(string name, MultiBucketsPath bucketsPath) : base(name, bucketsPath) { } + public IScript Script { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.BucketSelector = this; } public class BucketSelectorAggregationDescriptor : PipelineAggregationDescriptorBase - , IBucketSelectorAggregation + , IBucketSelectorAggregation { IScript IBucketSelectorAggregation.Script { get; set; } diff --git a/src/Nest/Aggregations/Pipeline/BucketSort/BucketSortAggregation.cs b/src/Nest/Aggregations/Pipeline/BucketSort/BucketSortAggregation.cs index 48b5d0a64dc..5158a3099a8 100644 --- a/src/Nest/Aggregations/Pipeline/BucketSort/BucketSortAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/BucketSort/BucketSortAggregation.cs @@ -14,12 +14,6 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IBucketSortAggregation : IAggregation { - /// - /// The list of fields to sort on - /// - [JsonProperty("sort")] - IList Sort { get; set; } - /// /// Buckets in positions prior to the set value will be truncated /// @@ -27,42 +21,44 @@ public interface IBucketSortAggregation : IAggregation int? From { get; set; } /// - /// The number of buckets to return. Defaults to all buckets of the parent aggregation + /// The policy to apply when gaps are found in the data + /// + [JsonProperty("gap_policy")] + GapPolicy? GapPolicy { get; set; } + + /// + /// The number of buckets to return. Defaults to all buckets of the parent aggregation /// [JsonProperty("size")] int? Size { get; set; } /// - /// The policy to apply when gaps are found in the data + /// The list of fields to sort on /// - [JsonProperty("gap_policy")] - GapPolicy? GapPolicy { get; set; } + [JsonProperty("sort")] + IList Sort { get; set; } } /// public class BucketSortAggregation : AggregationBase, IBucketSortAggregation { - internal BucketSortAggregation() - { - } + internal BucketSortAggregation() { } public BucketSortAggregation(string name) - : base(name) - { - } + : base(name) { } /// - public IList Sort { get; set; } + public int? From { get; set; } /// - public int? From { get; set; } + public GapPolicy? GapPolicy { get; set; } /// public int? Size { get; set; } /// - public GapPolicy? GapPolicy { get; set; } + public IList Sort { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.BucketSort = this; } @@ -73,12 +69,11 @@ public class BucketSortAggregationDescriptor , IBucketSortAggregation where T : class { - string IAggregation.Name { get; set; } - IDictionary IAggregation.Meta { get; set; } - int? IBucketSortAggregation.From { get; set; } - int? IBucketSortAggregation.Size { get; set; } GapPolicy? IBucketSortAggregation.GapPolicy { get; set; } + IDictionary IAggregation.Meta { get; set; } + string IAggregation.Name { get; set; } + int? IBucketSortAggregation.Size { get; set; } IList IBucketSortAggregation.Sort { get; set; } /// @@ -93,7 +88,7 @@ public BucketSortAggregationDescriptor Sort(Func, IPromise< public BucketSortAggregationDescriptor From(int? from) => Assign(a => a.From = from); /// - /// The number of buckets to return. Defaults to all buckets of the parent aggregation + /// The number of buckets to return. Defaults to all buckets of the parent aggregation /// public BucketSortAggregationDescriptor Size(int? size) => Assign(a => a.Size = size); diff --git a/src/Nest/Aggregations/Pipeline/BucketsPath.cs b/src/Nest/Aggregations/Pipeline/BucketsPath.cs index 935293f128d..11d52c9bebe 100644 --- a/src/Nest/Aggregations/Pipeline/BucketsPath.cs +++ b/src/Nest/Aggregations/Pipeline/BucketsPath.cs @@ -10,12 +10,9 @@ public interface IBucketsPath { } public class SingleBucketsPath : IBucketsPath { - public string BucketsPath { get; } + public SingleBucketsPath(string bucketsPath) => BucketsPath = bucketsPath; - public SingleBucketsPath(string bucketsPath) - { - this.BucketsPath = bucketsPath; - } + public string BucketsPath { get; } public static implicit operator SingleBucketsPath(string bucketsPath) => new SingleBucketsPath(bucketsPath); } @@ -24,13 +21,14 @@ public interface IMultiBucketsPath : IIsADictionary, IBucketsPat public class MultiBucketsPath : IsADictionaryBase, IMultiBucketsPath { - public MultiBucketsPath() {} + public MultiBucketsPath() { } + public MultiBucketsPath(IDictionary container) : base(container) { } + public MultiBucketsPath(Dictionary container) - : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) - { } + : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) { } - public void Add(string name, string bucketsPath) => this.BackingDictionary.Add(name, bucketsPath); + public void Add(string name, string bucketsPath) => BackingDictionary.Add(name, bucketsPath); public static implicit operator MultiBucketsPath(Dictionary bucketsPath) => new MultiBucketsPath(bucketsPath); } @@ -83,7 +81,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s if (multi != null) { writer.WriteStartObject(); - foreach(var kv in multi) + foreach (var kv in multi) { writer.WritePropertyName(kv.Key); writer.WriteValue(kv.Value); diff --git a/src/Nest/Aggregations/Pipeline/CumulativeSum/CumulativeSumAggregation.cs b/src/Nest/Aggregations/Pipeline/CumulativeSum/CumulativeSumAggregation.cs index e6d50e41914..0e0186f900f 100644 --- a/src/Nest/Aggregations/Pipeline/CumulativeSum/CumulativeSumAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/CumulativeSum/CumulativeSumAggregation.cs @@ -9,7 +9,7 @@ public interface ICumulativeSumAggregation : IPipelineAggregation { } public class CumulativeSumAggregation : PipelineAggregationBase, ICumulativeSumAggregation { - internal CumulativeSumAggregation () { } + internal CumulativeSumAggregation() { } public CumulativeSumAggregation(string name, SingleBucketsPath bucketsPath) : base(name, bucketsPath) { } @@ -19,7 +19,5 @@ public CumulativeSumAggregation(string name, SingleBucketsPath bucketsPath) public class CumulativeSumAggregationDescriptor : PipelineAggregationDescriptorBase - , ICumulativeSumAggregation - { - } + , ICumulativeSumAggregation { } } diff --git a/src/Nest/Aggregations/Pipeline/Derivative/DerivativeAggregation.cs b/src/Nest/Aggregations/Pipeline/Derivative/DerivativeAggregation.cs index ec660300c18..18f38bb0084 100644 --- a/src/Nest/Aggregations/Pipeline/Derivative/DerivativeAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/Derivative/DerivativeAggregation.cs @@ -18,5 +18,5 @@ public DerivativeAggregation(string name, SingleBucketsPath bucketsPath) public class DerivativeAggregationDescriptor : PipelineAggregationDescriptorBase - , IDerivativeAggregation { } + , IDerivativeAggregation { } } diff --git a/src/Nest/Aggregations/Pipeline/ExtendedStatsBucket/ExtendedStatsBucketAggregation.cs b/src/Nest/Aggregations/Pipeline/ExtendedStatsBucket/ExtendedStatsBucketAggregation.cs index 096b1260ab0..145014968a2 100644 --- a/src/Nest/Aggregations/Pipeline/ExtendedStatsBucket/ExtendedStatsBucketAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/ExtendedStatsBucket/ExtendedStatsBucketAggregation.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -17,8 +16,7 @@ public class ExtendedStatsBucketAggregation internal ExtendedStatsBucketAggregation() { } public ExtendedStatsBucketAggregation(string name, SingleBucketsPath bucketsPath) - : base(name, bucketsPath) - { } + : base(name, bucketsPath) { } public double? Sigma { get; set; } @@ -27,12 +25,10 @@ public ExtendedStatsBucketAggregation(string name, SingleBucketsPath bucketsPath public class ExtendedStatsBucketAggregationDescriptor : PipelineAggregationDescriptorBase - , IExtendedStatsBucketAggregation + , IExtendedStatsBucketAggregation { - double? IExtendedStatsBucketAggregation.Sigma { get; set; } public ExtendedStatsBucketAggregationDescriptor Sigma(double? sigma) => Assign(a => a.Sigma = sigma); - } } diff --git a/src/Nest/Aggregations/Pipeline/GapPolicy.cs b/src/Nest/Aggregations/Pipeline/GapPolicy.cs index bd3ba01153a..e2f2c9968b9 100644 --- a/src/Nest/Aggregations/Pipeline/GapPolicy.cs +++ b/src/Nest/Aggregations/Pipeline/GapPolicy.cs @@ -9,6 +9,7 @@ public enum GapPolicy { [EnumMember(Value = "skip")] Skip, + [EnumMember(Value = "insert_zeros")] InsertZeros } diff --git a/src/Nest/Aggregations/Pipeline/MaxBucket/MaxBucketAggregation.cs b/src/Nest/Aggregations/Pipeline/MaxBucket/MaxBucketAggregation.cs index 67aba2981d9..94d4ed47a29 100644 --- a/src/Nest/Aggregations/Pipeline/MaxBucket/MaxBucketAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/MaxBucket/MaxBucketAggregation.cs @@ -9,7 +9,7 @@ public interface IMaxBucketAggregation : IPipelineAggregation { } public class MaxBucketAggregation : PipelineAggregationBase, IMaxBucketAggregation { - internal MaxBucketAggregation () { } + internal MaxBucketAggregation() { } public MaxBucketAggregation(string name, SingleBucketsPath bucketsPath) : base(name, bucketsPath) { } @@ -19,7 +19,5 @@ public MaxBucketAggregation(string name, SingleBucketsPath bucketsPath) public class MaxBucketAggregationDescriptor : PipelineAggregationDescriptorBase - , IMaxBucketAggregation - { - } + , IMaxBucketAggregation { } } diff --git a/src/Nest/Aggregations/Pipeline/MinBucket/MinBucketAggregation.cs b/src/Nest/Aggregations/Pipeline/MinBucket/MinBucketAggregation.cs index 9a27eb026c9..1a7f2983ff8 100644 --- a/src/Nest/Aggregations/Pipeline/MinBucket/MinBucketAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/MinBucket/MinBucketAggregation.cs @@ -9,7 +9,7 @@ public interface IMinBucketAggregation : IPipelineAggregation { } public class MinBucketAggregation : PipelineAggregationBase, IMinBucketAggregation { - internal MinBucketAggregation () { } + internal MinBucketAggregation() { } public MinBucketAggregation(string name, SingleBucketsPath bucketsPath) : base(name, bucketsPath) { } @@ -19,7 +19,5 @@ public MinBucketAggregation(string name, SingleBucketsPath bucketsPath) public class MinBucketAggregationDescriptor : PipelineAggregationDescriptorBase - , IMinBucketAggregation - { - } + , IMinBucketAggregation { } } diff --git a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/EwmaModel.cs b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/EwmaModel.cs index 347a8255ab4..c2caa1d3934 100644 --- a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/EwmaModel.cs +++ b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/EwmaModel.cs @@ -11,16 +11,15 @@ public interface IEwmaModel : IMovingAverageModel public class EwmaModel : IEwmaModel { - string IMovingAverageModel.Name { get; } = "ewma"; - public float? Alpha { get; set; } + string IMovingAverageModel.Name { get; } = "ewma"; } public class EwmaModelDescriptor : DescriptorBase, IEwmaModel { - string IMovingAverageModel.Name { get; } = "ewma"; float? IEwmaModel.Alpha { get; set; } + string IMovingAverageModel.Name { get; } = "ewma"; public EwmaModelDescriptor Alpha(float? alpha) => Assign(a => a.Alpha = alpha); } diff --git a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltLinearModel.cs b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltLinearModel.cs index 07a6cf10f2b..a8a60483f0a 100644 --- a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltLinearModel.cs +++ b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltLinearModel.cs @@ -14,18 +14,17 @@ public interface IHoltLinearModel : IMovingAverageModel public class HoltLinearModel : IHoltLinearModel { - string IMovingAverageModel.Name { get; } = "holt"; - public float? Alpha { get; set; } public float? Beta { get; set; } + string IMovingAverageModel.Name { get; } = "holt"; } public class HoltLinearModelDescriptor : DescriptorBase, IHoltLinearModel { - string IMovingAverageModel.Name { get; } = "holt"; float? IHoltLinearModel.Alpha { get; set; } float? IHoltLinearModel.Beta { get; set; } + string IMovingAverageModel.Name { get; } = "holt"; public HoltLinearModelDescriptor Alpha(float? alpha) => Assign(a => a.Alpha = alpha); diff --git a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltWintersModel.cs b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltWintersModel.cs index 2612f187921..6f76304b030 100644 --- a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltWintersModel.cs +++ b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/HoltWintersModel.cs @@ -9,6 +9,7 @@ public enum HoltWintersType { [EnumMember(Value = "add")] Additive, + [EnumMember(Value = "mult")] Multiplicative } @@ -25,35 +26,34 @@ public interface IHoltWintersModel : IMovingAverageModel [JsonProperty("gamma")] float? Gamma { get; set; } + [JsonProperty("pad")] + bool? Pad { get; set; } + [JsonProperty("period")] int? Period { get; set; } [JsonProperty("type")] HoltWintersType? Type { get; set; } - - [JsonProperty("pad")] - bool? Pad { get; set; } } public class HoltWintersModel : IHoltWintersModel { - string IMovingAverageModel.Name { get; } = "holt_winters"; - public float? Alpha { get; set; } public float? Beta { get; set; } public float? Gamma { get; set; } + public bool? Pad { get; set; } public int? Period { get; set; } public HoltWintersType? Type { get; set; } - public bool? Pad { get; set; } + string IMovingAverageModel.Name { get; } = "holt_winters"; } public class HoltWintersModelDescriptor : DescriptorBase, IHoltWintersModel { - string IMovingAverageModel.Name { get; } = "holt_winters"; float? IHoltWintersModel.Alpha { get; set; } float? IHoltWintersModel.Beta { get; set; } float? IHoltWintersModel.Gamma { get; set; } + string IMovingAverageModel.Name { get; } = "holt_winters"; bool? IHoltWintersModel.Pad { get; set; } int? IHoltWintersModel.Period { get; set; } HoltWintersType? IHoltWintersModel.Type { get; set; } diff --git a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/IMovingAverageModel.cs b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/IMovingAverageModel.cs index f3865903312..6e6c5b6f8fa 100644 --- a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/IMovingAverageModel.cs +++ b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/IMovingAverageModel.cs @@ -2,26 +2,26 @@ namespace Nest { - public interface IMovingAverageModel + public interface IMovingAverageModel { string Name { get; } } public class MovingAverageModelDescriptor : DescriptorBase { - public IEwmaModel Ewma(Func ewmaSelector = null) => + public IEwmaModel Ewma(Func ewmaSelector = null) => ewmaSelector.InvokeOrDefault(new EwmaModelDescriptor()); - public IHoltLinearModel HoltLinear(Func holtSelector = null) => + public IHoltLinearModel HoltLinear(Func holtSelector = null) => holtSelector.InvokeOrDefault(new HoltLinearModelDescriptor()); - public IHoltWintersModel HoltWinters(Func holtWintersSelector) => + public IHoltWintersModel HoltWinters(Func holtWintersSelector) => holtWintersSelector?.Invoke(new HoltWintersModelDescriptor()); - public ILinearModel Linear(Func linearSelector = null) => + public ILinearModel Linear(Func linearSelector = null) => linearSelector.InvokeOrDefault(new LinearModelDescriptor()); - public ISimpleModel Simple(Func simpleSelector = null) => + public ISimpleModel Simple(Func simpleSelector = null) => simpleSelector.InvokeOrDefault(new SimpleModelDescriptor()); } } diff --git a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/LinearModel.cs b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/LinearModel.cs index d83f5ceb634..e58009d9d63 100644 --- a/src/Nest/Aggregations/Pipeline/MovingAverage/Models/LinearModel.cs +++ b/src/Nest/Aggregations/Pipeline/MovingAverage/Models/LinearModel.cs @@ -4,10 +4,10 @@ namespace Nest { [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public interface ILinearModel : IMovingAverageModel { } - + public class LinearModel : ILinearModel { - string IMovingAverageModel.Name { get; } = "linear"; + string IMovingAverageModel.Name { get; } = "linear"; } public class LinearModelDescriptor diff --git a/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregation.cs b/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregation.cs index d3dcaebfd23..2ea83bf3b13 100644 --- a/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregation.cs @@ -7,42 +7,41 @@ namespace Nest [ContractJsonConverter(typeof(MovingAverageAggregationJsonConverter))] public interface IMovingAverageAggregation : IPipelineAggregation { - IMovingAverageModel Model { get; set; } - - [JsonProperty("window")] - int? Window { get; set; } - [JsonProperty("minimize")] bool? Minimize { get; set; } + IMovingAverageModel Model { get; set; } + [JsonProperty("predict")] int? Predict { get; set; } + + [JsonProperty("window")] + int? Window { get; set; } } public class MovingAverageAggregation : PipelineAggregationBase, IMovingAverageAggregation { - public bool? Minimize { get; set; } - public IMovingAverageModel Model { get; set; } - public int? Window { get; set; } - public int? Predict { get; set; } - internal MovingAverageAggregation() { } public MovingAverageAggregation(string name, SingleBucketsPath bucketsPath) - : base(name, bucketsPath) - { } + : base(name, bucketsPath) { } + + public bool? Minimize { get; set; } + public IMovingAverageModel Model { get; set; } + public int? Predict { get; set; } + public int? Window { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.MovingAverage = this; } public class MovingAverageAggregationDescriptor : PipelineAggregationDescriptorBase - , IMovingAverageAggregation + , IMovingAverageAggregation { bool? IMovingAverageAggregation.Minimize { get; set; } IMovingAverageModel IMovingAverageAggregation.Model { get; set; } - int? IMovingAverageAggregation.Window { get; set; } int? IMovingAverageAggregation.Predict { get; set; } + int? IMovingAverageAggregation.Window { get; set; } public MovingAverageAggregationDescriptor Minimize(bool? minimize = true) => Assign(a => a.Minimize = minimize); @@ -52,6 +51,5 @@ public class MovingAverageAggregationDescriptor public MovingAverageAggregationDescriptor Model(Func modelSelector) => Assign(a => a.Model = modelSelector?.Invoke(new MovingAverageModelDescriptor())); - } } diff --git a/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregationJsonConverter.cs b/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregationJsonConverter.cs index a588b1f0737..7d6770a4e02 100644 --- a/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregationJsonConverter.cs +++ b/src/Nest/Aggregations/Pipeline/MovingAverage/MovingAverageAggregationJsonConverter.cs @@ -28,13 +28,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist #if DOTNETCORE JToken value; if (ps.TryGetValue("buckets_path", out value) && value != null) - { aggregation.BucketsPath = new SingleBucketsPath((string)value); - } else - { aggregation.BucketsPath = default(SingleBucketsPath); - } #else aggregation.BucketsPath = GetOrDefault("buckets_path", ps); @@ -46,6 +42,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { var movingAvg = value as IMovingAverageAggregation; if (movingAvg == null) return; + writer.WriteStartObject(); writer.WritePropertyName("buckets_path"); serializer.Serialize(writer, movingAvg.BucketsPath); @@ -100,6 +97,7 @@ private T GetOrDefault(string key, Dictionary properties) if (value.IsNullOrEmpty()) return null; if (value == "insert_zeros") return GapPolicy.InsertZeros; if (value == "skip") return GapPolicy.Skip; + return null; } @@ -121,6 +119,7 @@ private IMovingAverageModel GetModel(Dictionary properties) return settings.ToObject(); else if (name == "holt_winters") return settings.ToObject(); + return null; } } diff --git a/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs b/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs index 13153915c42..d5c1a2109db 100644 --- a/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs @@ -6,33 +6,34 @@ namespace Nest [ContractJsonConverter(typeof(AggregationJsonConverter))] public interface IMovingFunctionAggregation : IPipelineAggregation { - [JsonProperty("window")] - int? Window { get; set; } - [JsonProperty("script")] string Script { get; set; } + + [JsonProperty("window")] + int? Window { get; set; } } public class MovingFunctionAggregation : PipelineAggregationBase, IMovingFunctionAggregation { - internal MovingFunctionAggregation () { } + internal MovingFunctionAggregation() { } public MovingFunctionAggregation(string name, SingleBucketsPath bucketsPath) : base(name, bucketsPath) { } - internal override void WrapInContainer(AggregationContainer c) => c.MovingFunction = this; + public string Script { get; set; } public int? Window { get; set; } - public string Script { get; set; } + + internal override void WrapInContainer(AggregationContainer c) => c.MovingFunction = this; } public class MovingFunctionAggregationDescriptor : PipelineAggregationDescriptorBase - , IMovingFunctionAggregation + , IMovingFunctionAggregation { - int? IMovingFunctionAggregation.Window { get; set; } string IMovingFunctionAggregation.Script { get; set; } + int? IMovingFunctionAggregation.Window { get; set; } public MovingFunctionAggregationDescriptor Window(int? windowSize) => Assign(a => a.Window = windowSize); diff --git a/src/Nest/Aggregations/Pipeline/PercentilesBucket/PercentilesBucketAggregation.cs b/src/Nest/Aggregations/Pipeline/PercentilesBucket/PercentilesBucketAggregation.cs index 2b1430e40fe..5b0086a5d5a 100644 --- a/src/Nest/Aggregations/Pipeline/PercentilesBucket/PercentilesBucketAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/PercentilesBucket/PercentilesBucketAggregation.cs @@ -1,7 +1,6 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json; namespace Nest { @@ -16,20 +15,19 @@ public interface IPercentilesBucketAggregation : IPipelineAggregation public class PercentilesBucketAggregation : PipelineAggregationBase, IPercentilesBucketAggregation { - public IEnumerable Percents { get; set; } - internal PercentilesBucketAggregation() { } public PercentilesBucketAggregation(string name, SingleBucketsPath bucketsPath) - : base(name, bucketsPath) - { } + : base(name, bucketsPath) { } + + public IEnumerable Percents { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.PercentilesBucket = this; } public class PercentilesBucketAggregationDescriptor : PipelineAggregationDescriptorBase - , IPercentilesBucketAggregation + , IPercentilesBucketAggregation { IEnumerable IPercentilesBucketAggregation.Percents { get; set; } @@ -38,6 +36,5 @@ public PercentilesBucketAggregationDescriptor Percents(IEnumerable perce public PercentilesBucketAggregationDescriptor Percents(params double[] percentages) => Assign(a => a.Percents = percentages?.ToList()); - } } diff --git a/src/Nest/Aggregations/Pipeline/PipelineAggregationBase.cs b/src/Nest/Aggregations/Pipeline/PipelineAggregationBase.cs index 42e4483e244..3e8ea39c033 100644 --- a/src/Nest/Aggregations/Pipeline/PipelineAggregationBase.cs +++ b/src/Nest/Aggregations/Pipeline/PipelineAggregationBase.cs @@ -9,18 +9,18 @@ public interface IPipelineAggregation : IAggregation [JsonProperty("buckets_path")] IBucketsPath BucketsPath { get; set; } - [JsonProperty("gap_policy")] - GapPolicy? GapPolicy { get; set; } - [JsonProperty("format")] string Format { get; set; } + + [JsonProperty("gap_policy")] + GapPolicy? GapPolicy { get; set; } } public abstract class PipelineAggregationBase : AggregationBase, IPipelineAggregation { internal PipelineAggregationBase() { } - public PipelineAggregationBase(string name, IBucketsPath bucketsPath) : base(name) => this.BucketsPath = bucketsPath; + public PipelineAggregationBase(string name, IBucketsPath bucketsPath) : base(name) => BucketsPath = bucketsPath; public IBucketsPath BucketsPath { get; set; } public string Format { get; set; } @@ -30,7 +30,7 @@ internal PipelineAggregationBase() { } public abstract class PipelineAggregationDescriptorBase : DescriptorBase, IPipelineAggregation where TPipelineAggregation : PipelineAggregationDescriptorBase - , TPipelineAggregationInterface, IPipelineAggregation + , TPipelineAggregationInterface, IPipelineAggregation where TPipelineAggregationInterface : class, IPipelineAggregation where TBucketsPath : IBucketsPath { @@ -38,10 +38,10 @@ public abstract class PipelineAggregationDescriptorBase IAggregation.Meta { get; set; } + string IAggregation.Name { get; set; } + public TPipelineAggregation Format(string format) => Assign(a => a.Format = format); public TPipelineAggregation GapPolicy(GapPolicy? gapPolicy) => Assign(a => a.GapPolicy = gapPolicy); diff --git a/src/Nest/Aggregations/Pipeline/SerialDifferencing/SerialDifferencingAggregation.cs b/src/Nest/Aggregations/Pipeline/SerialDifferencing/SerialDifferencingAggregation.cs index 9c125616635..bb3b7751173 100644 --- a/src/Nest/Aggregations/Pipeline/SerialDifferencing/SerialDifferencingAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/SerialDifferencing/SerialDifferencingAggregation.cs @@ -12,20 +12,19 @@ public interface ISerialDifferencingAggregation : IPipelineAggregation public class SerialDifferencingAggregation : PipelineAggregationBase, ISerialDifferencingAggregation { - public int? Lag { get; set; } - internal SerialDifferencingAggregation() { } public SerialDifferencingAggregation(string name, SingleBucketsPath bucketsPath) - : base(name, bucketsPath) - { } + : base(name, bucketsPath) { } + + public int? Lag { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.SerialDifferencing = this; } public class SerialDifferencingAggregationDescriptor : PipelineAggregationDescriptorBase - , ISerialDifferencingAggregation + , ISerialDifferencingAggregation { int? ISerialDifferencingAggregation.Lag { get; set; } diff --git a/src/Nest/Aggregations/Pipeline/StatsBucket/StatsBucketAggregation.cs b/src/Nest/Aggregations/Pipeline/StatsBucket/StatsBucketAggregation.cs index d937c86d694..68cce925277 100644 --- a/src/Nest/Aggregations/Pipeline/StatsBucket/StatsBucketAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/StatsBucket/StatsBucketAggregation.cs @@ -12,15 +12,12 @@ public class StatsBucketAggregation internal StatsBucketAggregation() { } public StatsBucketAggregation(string name, SingleBucketsPath bucketsPath) - : base(name, bucketsPath) - { } + : base(name, bucketsPath) { } internal override void WrapInContainer(AggregationContainer c) => c.StatsBucket = this; } public class StatsBucketAggregationDescriptor : PipelineAggregationDescriptorBase - , IStatsBucketAggregation - { - } + , IStatsBucketAggregation { } } diff --git a/src/Nest/Aggregations/Pipeline/SumBucket/SumBucketAggregation.cs b/src/Nest/Aggregations/Pipeline/SumBucket/SumBucketAggregation.cs index 657701003ee..1c780b52abf 100644 --- a/src/Nest/Aggregations/Pipeline/SumBucket/SumBucketAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/SumBucket/SumBucketAggregation.cs @@ -9,7 +9,7 @@ public interface ISumBucketAggregation : IPipelineAggregation { } public class SumBucketAggregation : PipelineAggregationBase, ISumBucketAggregation { - internal SumBucketAggregation () { } + internal SumBucketAggregation() { } public SumBucketAggregation(string name, SingleBucketsPath bucketsPath) : base(name, bucketsPath) { } @@ -19,7 +19,5 @@ public SumBucketAggregation(string name, SingleBucketsPath bucketsPath) public class SumBucketAggregationDescriptor : PipelineAggregationDescriptorBase - , ISumBucketAggregation - { - } + , ISumBucketAggregation { } } diff --git a/src/Nest/Aggregations/Visitor/AggregationVisitor.cs b/src/Nest/Aggregations/Visitor/AggregationVisitor.cs index 8ade3c0fb6b..ac046d2c1e0 100644 --- a/src/Nest/Aggregations/Visitor/AggregationVisitor.cs +++ b/src/Nest/Aggregations/Visitor/AggregationVisitor.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Nest +namespace Nest { public interface IAggregationVisitor { @@ -29,52 +23,99 @@ public interface IAggregationVisitor /// /// The IAggregation object that will be visited void Visit(IAggregation aggregation); + void Visit(IAverageAggregation aggregation); + void Visit(IValueCountAggregation aggregation); + void Visit(IMaxAggregation aggregation); + void Visit(IMinAggregation aggregation); + void Visit(IStatsAggregation aggregation); + void Visit(ISumAggregation aggregation); + void Visit(IExtendedStatsAggregation aggregation); + void Visit(IDateHistogramAggregation aggregation); + void Visit(IPercentilesAggregation aggregation); + void Visit(IDateRangeAggregation aggregation); + void Visit(IFilterAggregation aggregation); + void Visit(IFiltersAggregation aggregation); + void Visit(IGeoDistanceAggregation aggregation); + void Visit(IGeoHashGridAggregation aggregation); + void Visit(IGeoBoundsAggregation aggregation); + void Visit(IHistogramAggregation aggregation); + void Visit(IGlobalAggregation aggregation); + void Visit(IIpRangeAggregation aggregation); + void Visit(ICardinalityAggregation aggregation); + void Visit(IMissingAggregation aggregation); + void Visit(INestedAggregation aggregation); + void Visit(IReverseNestedAggregation aggregation); + void Visit(IRangeAggregation aggregation); + void Visit(ITermsAggregation aggregation); + void Visit(ISignificantTermsAggregation aggregation); + void Visit(ISignificantTextAggregation aggregation); + void Visit(IPercentileRanksAggregation aggregation); + void Visit(ITopHitsAggregation aggregation); + void Visit(IChildrenAggregation aggregation); + void Visit(IScriptedMetricAggregation aggregation); + void Visit(IAverageBucketAggregation aggregation); + void Visit(IDerivativeAggregation aggregation); + void Visit(IMaxBucketAggregation aggregation); + void Visit(IMinBucketAggregation aggregation); + void Visit(ISumBucketAggregation aggregation); + void Visit(IStatsBucketAggregation aggregation); + void Visit(IExtendedStatsBucketAggregation aggregation); + void Visit(IPercentilesBucketAggregation aggregation); + void Visit(IMovingAverageAggregation aggregation); + void Visit(ICumulativeSumAggregation aggregation); + void Visit(ISerialDifferencingAggregation aggregation); + void Visit(IBucketScriptAggregation aggregation); + void Visit(IBucketSelectorAggregation aggregation); + void Visit(IBucketSortAggregation aggregation); + void Visit(ISamplerAggregation aggregation); + void Visit(IGeoCentroidAggregation aggregation); + void Visit(ICompositeAggregation aggregation); } @@ -84,200 +125,102 @@ public class AggregationVisitor : IAggregationVisitor public AggregationVisitorScope Scope { get; set; } - public virtual void Visit(IValueCountAggregation aggregation) - { - } + public virtual void Visit(IValueCountAggregation aggregation) { } - public virtual void Visit(IMinAggregation aggregation) - { - } + public virtual void Visit(IMinAggregation aggregation) { } - public virtual void Visit(ISumAggregation aggregation) - { - } + public virtual void Visit(ISumAggregation aggregation) { } - public virtual void Visit(IDateHistogramAggregation aggregation) - { - } + public virtual void Visit(IDateHistogramAggregation aggregation) { } - public virtual void Visit(IDateRangeAggregation aggregation) - { - } + public virtual void Visit(IDateRangeAggregation aggregation) { } - public virtual void Visit(IFiltersAggregation aggregation) - { - } + public virtual void Visit(IFiltersAggregation aggregation) { } - public virtual void Visit(IGeoHashGridAggregation aggregation) - { - } + public virtual void Visit(IGeoHashGridAggregation aggregation) { } - public virtual void Visit(IHistogramAggregation aggregation) - { - } + public virtual void Visit(IHistogramAggregation aggregation) { } - public virtual void Visit(IIpRangeAggregation aggregation) - { - } + public virtual void Visit(IIpRangeAggregation aggregation) { } - public virtual void Visit(IMissingAggregation aggregation) - { - } + public virtual void Visit(IMissingAggregation aggregation) { } - public virtual void Visit(IReverseNestedAggregation aggregation) - { - } + public virtual void Visit(IReverseNestedAggregation aggregation) { } - public virtual void Visit(ITermsAggregation aggregation) - { - } + public virtual void Visit(ITermsAggregation aggregation) { } - public void Visit(ISignificantTextAggregation aggregation) - { - } + public void Visit(ISignificantTextAggregation aggregation) { } - public virtual void Visit(IPercentileRanksAggregation aggregation) - { - } + public virtual void Visit(IPercentileRanksAggregation aggregation) { } - public virtual void Visit(IChildrenAggregation aggregation) - { - } + public virtual void Visit(IChildrenAggregation aggregation) { } - public virtual void Visit(IAverageBucketAggregation aggregation) - { - } + public virtual void Visit(IAverageBucketAggregation aggregation) { } - public virtual void Visit(IMaxBucketAggregation aggregation) - { - } + public virtual void Visit(IMaxBucketAggregation aggregation) { } - public virtual void Visit(ISumBucketAggregation aggregation) - { - } + public virtual void Visit(ISumBucketAggregation aggregation) { } - public virtual void Visit(IStatsBucketAggregation aggregation) - { - } + public virtual void Visit(IStatsBucketAggregation aggregation) { } - public virtual void Visit(IExtendedStatsBucketAggregation aggregation) - { - } + public virtual void Visit(IExtendedStatsBucketAggregation aggregation) { } - public virtual void Visit(IPercentilesBucketAggregation aggregation) - { - } + public virtual void Visit(IPercentilesBucketAggregation aggregation) { } - public virtual void Visit(ICumulativeSumAggregation aggregation) - { - } + public virtual void Visit(ICumulativeSumAggregation aggregation) { } - public virtual void Visit(IBucketScriptAggregation aggregation) - { - } + public virtual void Visit(IBucketScriptAggregation aggregation) { } - public virtual void Visit(ISamplerAggregation aggregation) - { - } + public virtual void Visit(ISamplerAggregation aggregation) { } - public virtual void Visit(IBucketSelectorAggregation aggregation) - { - } + public virtual void Visit(IBucketSelectorAggregation aggregation) { } - public virtual void Visit(IBucketSortAggregation aggregation) - { - } + public virtual void Visit(IBucketSortAggregation aggregation) { } - public virtual void Visit(ISerialDifferencingAggregation aggregation) - { - } + public virtual void Visit(ISerialDifferencingAggregation aggregation) { } - public virtual void Visit(IMovingAverageAggregation aggregation) - { - } + public virtual void Visit(IMovingAverageAggregation aggregation) { } - public virtual void Visit(IMinBucketAggregation aggregation) - { - } + public virtual void Visit(IMinBucketAggregation aggregation) { } - public virtual void Visit(IDerivativeAggregation aggregation) - { - } + public virtual void Visit(IDerivativeAggregation aggregation) { } - public virtual void Visit(IScriptedMetricAggregation aggregation) - { - } + public virtual void Visit(IScriptedMetricAggregation aggregation) { } - public virtual void Visit(ITopHitsAggregation aggregation) - { - } + public virtual void Visit(ITopHitsAggregation aggregation) { } - public virtual void Visit(ISignificantTermsAggregation aggregation) - { - } + public virtual void Visit(ISignificantTermsAggregation aggregation) { } - public virtual void Visit(IRangeAggregation aggregation) - { - } + public virtual void Visit(IRangeAggregation aggregation) { } - public virtual void Visit(INestedAggregation aggregation) - { - } + public virtual void Visit(INestedAggregation aggregation) { } - public virtual void Visit(ICardinalityAggregation aggregation) - { - } + public virtual void Visit(ICardinalityAggregation aggregation) { } - public virtual void Visit(IGlobalAggregation aggregation) - { - } + public virtual void Visit(IGlobalAggregation aggregation) { } - public virtual void Visit(IGeoBoundsAggregation aggregation) - { - } + public virtual void Visit(IGeoBoundsAggregation aggregation) { } - public virtual void Visit(IGeoDistanceAggregation aggregation) - { - } + public virtual void Visit(IGeoDistanceAggregation aggregation) { } - public virtual void Visit(IFilterAggregation aggregation) - { - } + public virtual void Visit(IFilterAggregation aggregation) { } - public virtual void Visit(IPercentilesAggregation aggregation) - { - } + public virtual void Visit(IPercentilesAggregation aggregation) { } - public virtual void Visit(IExtendedStatsAggregation aggregation) - { - } + public virtual void Visit(IExtendedStatsAggregation aggregation) { } - public virtual void Visit(IStatsAggregation aggregation) - { - } + public virtual void Visit(IStatsAggregation aggregation) { } - public virtual void Visit(IMaxAggregation aggregation) - { - } + public virtual void Visit(IMaxAggregation aggregation) { } - public virtual void Visit(IAverageAggregation aggregation) - { - } + public virtual void Visit(IAverageAggregation aggregation) { } - public virtual void Visit(IGeoCentroidAggregation aggregation) - { - } + public virtual void Visit(IGeoCentroidAggregation aggregation) { } - public virtual void Visit(ICompositeAggregation aggregation) - { - } + public virtual void Visit(ICompositeAggregation aggregation) { } - public virtual void Visit(IAggregation aggregation) - { - } + public virtual void Visit(IAggregation aggregation) { } - public virtual void Visit(IAggregationContainer aggregationContainer) - { - } + public virtual void Visit(IAggregationContainer aggregationContainer) { } } } diff --git a/src/Nest/Aggregations/Visitor/AggregationVisitorScope.cs b/src/Nest/Aggregations/Visitor/AggregationVisitorScope.cs index c8d09f35df1..83374192bcd 100644 --- a/src/Nest/Aggregations/Visitor/AggregationVisitorScope.cs +++ b/src/Nest/Aggregations/Visitor/AggregationVisitorScope.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Nest +namespace Nest { public enum AggregationVisitorScope { diff --git a/src/Nest/Aggregations/Visitor/AggregationWalker.cs b/src/Nest/Aggregations/Visitor/AggregationWalker.cs index 2ea41941bd0..ee506161b34 100644 --- a/src/Nest/Aggregations/Visitor/AggregationWalker.cs +++ b/src/Nest/Aggregations/Visitor/AggregationWalker.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Nest { @@ -11,13 +7,17 @@ public class AggregationWalker private void Accept(IAggregationVisitor visitor, AggregationDictionary aggregations) { if (!aggregations.HasAny()) return; + foreach (var f in aggregations) - this.Accept(visitor, f.Value, AggregationVisitorScope.Bucket); + Accept(visitor, f.Value, AggregationVisitorScope.Bucket); } - private void Accept(IAggregationVisitor visitor, IAggregationContainer aggregation, AggregationVisitorScope scope = AggregationVisitorScope.Aggregation) + private void Accept(IAggregationVisitor visitor, IAggregationContainer aggregation, + AggregationVisitorScope scope = AggregationVisitorScope.Aggregation + ) { if (aggregation == null) return; + visitor.Scope = scope; aggregation.Accept(visitor); } @@ -42,43 +42,115 @@ public void Walk(IAggregationContainer aggregation, IAggregationVisitor visitor) AcceptAggregation(aggregation.BucketSort, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.BucketSelector, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.Cardinality, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.Children, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.Children, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.CumulativeSum, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.DateHistogram, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.DateRange, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.DateHistogram, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.DateRange, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.Derivative, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.ExtendedStats, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.Filter, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.Filters, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.Filter, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.Filters, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.GeoBounds, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.GeoDistance, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.GeoHash, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.Global, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.Histogram, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.IpRange, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.GeoDistance, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.GeoHash, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.Global, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.Histogram, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.IpRange, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.Max, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.MaxBucket, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.Min, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.MinBucket, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.Missing, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.Missing, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.MovingAverage, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.Nested, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.Nested, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.PercentileRanks, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.Percentiles, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.Range, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.ReverseNested, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.Sampler, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.Range, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.ReverseNested, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.Sampler, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.ScriptedMetric, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.SerialDifferencing, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.SignificantTerms, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); - AcceptAggregation(aggregation.SignificantText, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.SignificantTerms, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); + AcceptAggregation(aggregation.SignificantText, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.Stats, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.Sum, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.SumBucket, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.StatsBucket, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.ExtendedStatsBucket, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.PercentilesBucket, visitor, (v, d) => v.Visit(d)); - AcceptAggregation(aggregation.Terms, visitor, (v, d) => { v.Visit(d); this.Accept(v, d.Aggregations); }); + AcceptAggregation(aggregation.Terms, visitor, (v, d) => + { + v.Visit(d); + Accept(v, d.Aggregations); + }); AcceptAggregation(aggregation.TopHits, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.ValueCount, visitor, (v, d) => v.Visit(d)); AcceptAggregation(aggregation.GeoCentroid, visitor, (v, d) => v.Visit(d)); diff --git a/src/Nest/Analysis/Analysis.cs b/src/Nest/Analysis/Analysis.cs index 2f3702f02a6..1ff0dc1b4ef 100644 --- a/src/Nest/Analysis/Analysis.cs +++ b/src/Nest/Analysis/Analysis.cs @@ -7,33 +7,37 @@ public interface IAnalysis { [JsonProperty("analyzer")] IAnalyzers Analyzers { get; set; } + [JsonProperty("char_filter")] ICharFilters CharFilters { get; set; } + + [JsonProperty("normalizer")] + INormalizers Normalizers { get; set; } + [JsonProperty("filter")] ITokenFilters TokenFilters { get; set; } + [JsonProperty("tokenizer")] ITokenizers Tokenizers { get; set; } - [JsonProperty("normalizer")] - INormalizers Normalizers { get; set; } } public class Analysis : IAnalysis { public IAnalyzers Analyzers { get; set; } public ICharFilters CharFilters { get; set; } - public ITokenFilters TokenFilters { get; set; } - public ITokenizers Tokenizers { get; set; } public INormalizers Normalizers { get; set; } + public ITokenFilters TokenFilters { get; set; } + public ITokenizers Tokenizers { get; set; } } public class AnalysisDescriptor : DescriptorBase, IAnalysis { IAnalyzers IAnalysis.Analyzers { get; set; } ICharFilters IAnalysis.CharFilters { get; set; } + INormalizers IAnalysis.Normalizers { get; set; } ITokenFilters IAnalysis.TokenFilters { get; set; } ITokenizers IAnalysis.Tokenizers { get; set; } - INormalizers IAnalysis.Normalizers { get; set; } public AnalysisDescriptor Analyzers(Func> selector) => Assign(a => a.Analyzers = selector?.Invoke(new AnalyzersDescriptor())?.Value); diff --git a/src/Nest/Analysis/Analyzers/AnalyzerBase.cs b/src/Nest/Analysis/Analyzers/AnalyzerBase.cs index 503c0324dd9..321f91597bc 100644 --- a/src/Nest/Analysis/Analyzers/AnalyzerBase.cs +++ b/src/Nest/Analysis/Analyzers/AnalyzerBase.cs @@ -5,11 +5,11 @@ namespace Nest [ContractJsonConverter(typeof(AnalyzerJsonConverter))] public interface IAnalyzer { - [JsonProperty("version")] - string Version { get; set; } - [JsonProperty("type")] string Type { get; } + + [JsonProperty("version")] + string Version { get; set; } } public abstract class AnalyzerBase : IAnalyzer @@ -18,9 +18,9 @@ internal AnalyzerBase() { } protected AnalyzerBase(string type) => Type = type; - public string Version { get; set; } - public virtual string Type { get; protected set; } + + public string Version { get; set; } } public abstract class AnalyzerDescriptorBase @@ -28,11 +28,10 @@ public abstract class AnalyzerDescriptorBase where TAnalyzer : AnalyzerDescriptorBase, TAnalyzerInterface where TAnalyzerInterface : class, IAnalyzer { - string IAnalyzer.Version { get; set; } - string IAnalyzer.Type => this.Type; protected abstract string Type { get; } + string IAnalyzer.Type => Type; + string IAnalyzer.Version { get; set; } public TAnalyzer Version(string version) => Assign(a => a.Version = version); } - } diff --git a/src/Nest/Analysis/Analyzers/AnalyzerJsonConverter.cs b/src/Nest/Analysis/Analyzers/AnalyzerJsonConverter.cs index d47253dfda4..285f019eba3 100644 --- a/src/Nest/Analysis/Analyzers/AnalyzerJsonConverter.cs +++ b/src/Nest/Analysis/Analyzers/AnalyzerJsonConverter.cs @@ -6,9 +6,10 @@ namespace Nest { internal class AnalyzerJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) => true; - public override bool CanWrite => false; public override bool CanRead => true; + public override bool CanWrite => false; + + public override bool CanConvert(Type objectType) => true; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { @@ -18,7 +19,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist if (typeProperty == null) return null; var typePropertyValue = typeProperty.Value.ToString(); - switch(typePropertyValue) + switch (typePropertyValue) { case "stop": return o.ToObject(ElasticContractResolver.Empty); case "standard": return o.ToObject(ElasticContractResolver.Empty); @@ -33,13 +34,11 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist default: if (o.Property("tokenizer") != null) return o.ToObject(ElasticContractResolver.Empty); + return o.ToObject(ElasticContractResolver.Empty); } } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); } } diff --git a/src/Nest/Analysis/Analyzers/Analyzers.cs b/src/Nest/Analysis/Analyzers/Analyzers.cs index 4f78b5e4741..da4987729c4 100644 --- a/src/Nest/Analysis/Analyzers/Analyzers.cs +++ b/src/Nest/Analysis/Analyzers/Analyzers.cs @@ -10,11 +10,12 @@ public interface IAnalyzers : IIsADictionary { } public class Analyzers : IsADictionaryBase, IAnalyzers { - public Analyzers() {} + public Analyzers() { } + public Analyzers(IDictionary container) : base(container) { } + public Analyzers(Dictionary container) - : base(container.ToDictionary(kv => kv.Key, kv => kv.Value)) - { } + : base(container.ToDictionary(kv => kv.Key, kv => kv.Value)) { } public void Add(string name, IAnalyzer analyzer) => BackingDictionary.Add(name, analyzer); } @@ -28,8 +29,10 @@ public AnalyzersDescriptor() : base(new Analyzers()) { } /// /// An analyzer of type custom that allows to combine a Tokenizer with zero or more Token Filters, /// and zero or more Char Filters. - /// The custom analyzer accepts a logical/registered name of the tokenizer to use, and a list of - /// logical/registered names of token filters. + /// + /// The custom analyzer accepts a logical/registered name of the tokenizer to use, and a list of + /// logical/registered names of token filters. + /// /// public AnalyzersDescriptor Custom(string name, Func selector) => Assign(name, selector?.Invoke(new CustomAnalyzerDescriptor())); @@ -61,13 +64,17 @@ public AnalyzersDescriptor Simple(string name, Func /// An analyzer of type snowball that uses the standard tokenizer, with standard filter, lowercase filter, stop filter, and snowball filter. - /// The Snowball Analyzer is a stemming analyzer from Lucene that is originally based on the snowball project from snowball.tartarus.org. + /// + /// The Snowball Analyzer is a stemming analyzer from Lucene that is originally based on the snowball project from + /// snowball.tartarus.org. + /// /// public AnalyzersDescriptor Snowball(string name, Func selector) => Assign(name, selector?.Invoke(new SnowballAnalyzerDescriptor())); /// - /// An analyzer of type standard that is built of using Standard Tokenizer, with Standard Token Filter, Lower Case Token Filter, and Stop Token Filter. + /// An analyzer of type standard that is built of using Standard Tokenizer, with Standard Token Filter, Lower Case Token Filter, and Stop Token + /// Filter. /// public AnalyzersDescriptor Standard(string name, Func selector) => Assign(name, selector?.Invoke(new StandardAnalyzerDescriptor())); @@ -98,7 +105,7 @@ public AnalyzersDescriptor Fingerprint(string name, Func selector = null) => Assign(name, selector.InvokeOrDefault(new KuromojiAnalyzerDescriptor())); - /// + /// public AnalyzersDescriptor Nori(string name, Func selector) => Assign(name, selector?.Invoke(new NoriAnalyzerDescriptor())); } diff --git a/src/Nest/Analysis/Analyzers/CustomAnalyzer.cs b/src/Nest/Analysis/Analyzers/CustomAnalyzer.cs index 15b9bb8e860..f87312643a8 100644 --- a/src/Nest/Analysis/Analyzers/CustomAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/CustomAnalyzer.cs @@ -6,8 +6,10 @@ namespace Nest /// /// An analyzer of type custom that allows to combine a Tokenizer with zero or more Token Filters, /// and zero or more Char Filters. - /// The custom analyzer accepts a logical/registered name of the tokenizer to use, and a list of - /// logical/registered names of token filters. + /// + /// The custom analyzer accepts a logical/registered name of the tokenizer to use, and a list of + /// logical/registered names of token filters. + /// /// public interface ICustomAnalyzer : IAnalyzer { @@ -25,35 +27,35 @@ public interface ICustomAnalyzer : IAnalyzer [JsonConverter(typeof(ReadSingleOrEnumerableJsonConverter))] IEnumerable Filter { get; set; } - /// - /// An optional list of logical / registered name of char filters. - /// - [JsonProperty("tokenizer")] - string Tokenizer { get; set; } - /// /// An optional number of positions to increment between each field value of a /// field using this analyzer. /// [JsonProperty("position_offset_gap")] int? PositionOffsetGap { get; set; } + + /// + /// An optional list of logical / registered name of char filters. + /// + [JsonProperty("tokenizer")] + string Tokenizer { get; set; } } public class CustomAnalyzer : AnalyzerBase, ICustomAnalyzer { - public CustomAnalyzer() : base("custom") {} + public CustomAnalyzer() : base("custom") { } - /// - public string Tokenizer { get; set; } + /// + public IEnumerable CharFilter { get; set; } - /// + /// public IEnumerable Filter { get; set; } - /// - public IEnumerable CharFilter { get; set; } - - /// + /// public int? PositionOffsetGap { get; set; } + + /// + public string Tokenizer { get; set; } } public class CustomAnalyzerDescriptor @@ -63,25 +65,25 @@ public class CustomAnalyzerDescriptor IEnumerable ICustomAnalyzer.CharFilter { get; set; } IEnumerable ICustomAnalyzer.Filter { get; set; } - string ICustomAnalyzer.Tokenizer { get; set; } int? ICustomAnalyzer.PositionOffsetGap { get; set; } + string ICustomAnalyzer.Tokenizer { get; set; } - /// + /// public CustomAnalyzerDescriptor Filters(params string[] filters) => Assign(a => a.Filter = filters); - /// + /// public CustomAnalyzerDescriptor Filters(IEnumerable filters) => Assign(a => a.Filter = filters); - /// + /// public CustomAnalyzerDescriptor CharFilters(params string[] charFilters) => Assign(a => a.CharFilter = charFilters); - /// + /// public CustomAnalyzerDescriptor CharFilters(IEnumerable charFilters) => Assign(a => a.CharFilter = charFilters); - /// + /// public CustomAnalyzerDescriptor Tokenizer(string tokenizer) => Assign(a => a.Tokenizer = tokenizer); - /// + /// public CustomAnalyzerDescriptor PositionOffsetGap(int? positionOffsetGap) => Assign(a => a.PositionOffsetGap = positionOffsetGap); } diff --git a/src/Nest/Analysis/Analyzers/FingerprintAnalyzer.cs b/src/Nest/Analysis/Analyzers/FingerprintAnalyzer.cs index 54aafa207bf..1cd281be5e2 100644 --- a/src/Nest/Analysis/Analyzers/FingerprintAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/FingerprintAnalyzer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Newtonsoft.Json; namespace Nest @@ -13,12 +9,6 @@ namespace Nest /// public interface IFingerprintAnalyzer : IAnalyzer { - /// - /// The character that separates the tokens after concatenation. Defaults to a space. - /// - [JsonProperty("separator")] - string Separator { get; set; } - /// /// The maximum token size to emit. Defaults to 255. /// @@ -32,6 +22,12 @@ public interface IFingerprintAnalyzer : IAnalyzer [JsonProperty("preserve_original")] bool? PreserveOriginal { get; set; } + /// + /// The character that separates the tokens after concatenation. Defaults to a space. + /// + [JsonProperty("separator")] + string Separator { get; set; } + /// /// A list of stop words to use. Defaults to an empty list /// @@ -43,7 +39,7 @@ public interface IFingerprintAnalyzer : IAnalyzer /// A path(either relative to config location, or absolute) to a stopwords /// file configuration.Each stop word should be in its own "line" /// (separated by a line break). The file must be UTF-8 encoded. - /// + /// [JsonProperty("stopwords_path")] string StopWordsPath { get; set; } } @@ -51,28 +47,27 @@ public interface IFingerprintAnalyzer : IAnalyzer /// public class FingerprintAnalyzer : AnalyzerBase, IFingerprintAnalyzer { - public FingerprintAnalyzer() : base("fingerprint") {} - - public string Separator { get; set; } + public FingerprintAnalyzer() : base("fingerprint") { } public int? MaxOutputSize { get; set; } public bool? PreserveOriginal { get; set; } + public string Separator { get; set; } + public StopWords StopWords { get; set; } public string StopWordsPath { get; set; } } - /// - public class FingerprintAnalyzerDescriptor : - AnalyzerDescriptorBase, IFingerprintAnalyzer + /// + public class FingerprintAnalyzerDescriptor : AnalyzerDescriptorBase, IFingerprintAnalyzer { protected override string Type => "fingerprint"; - - string IFingerprintAnalyzer.Separator { get; set; } int? IFingerprintAnalyzer.MaxOutputSize { get; set; } bool? IFingerprintAnalyzer.PreserveOriginal { get; set; } + + string IFingerprintAnalyzer.Separator { get; set; } StopWords IFingerprintAnalyzer.StopWords { get; set; } string IFingerprintAnalyzer.StopWordsPath { get; set; } diff --git a/src/Nest/Analysis/Analyzers/KeywordAnalyzer.cs b/src/Nest/Analysis/Analyzers/KeywordAnalyzer.cs index 2237df6f07f..f0408b88e77 100644 --- a/src/Nest/Analysis/Analyzers/KeywordAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/KeywordAnalyzer.cs @@ -5,13 +5,14 @@ /// Note, when using mapping definitions, it make more sense to simply mark the field as not_analyzed. /// public interface IKeywordAnalyzer : IAnalyzer { } - /// + + /// public class KeywordAnalyzer : AnalyzerBase, IKeywordAnalyzer { - public KeywordAnalyzer() : base("keyword") {} + public KeywordAnalyzer() : base("keyword") { } } - /// + /// public class KeywordAnalyzerDescriptor : AnalyzerDescriptorBase, IKeywordAnalyzer { diff --git a/src/Nest/Analysis/Analyzers/LanguageAnalyzer.cs b/src/Nest/Analysis/Analyzers/LanguageAnalyzer.cs index a0645e3f57d..09e5722be79 100644 --- a/src/Nest/Analysis/Analyzers/LanguageAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/LanguageAnalyzer.cs @@ -9,6 +9,12 @@ namespace Nest /// public interface ILanguageAnalyzer : IAnalyzer { + /// + /// The stem_exclusion parameter allows you to specify an array of lowercase words that should not be stemmed. + /// + [JsonProperty("stem_exclusion")] + IEnumerable StemExclusionList { get; set; } + /// /// A list of stopword to initialize the stop filter with. Defaults to the english stop words. /// @@ -16,12 +22,6 @@ public interface ILanguageAnalyzer : IAnalyzer [JsonConverter(typeof(StopWordsJsonConverter))] StopWords StopWords { get; set; } - /// - /// The stem_exclusion parameter allows you to specify an array of lowercase words that should not be stemmed. - /// - [JsonProperty("stem_exclusion")] - IEnumerable StemExclusionList { get; set; } - /// /// A path (either relative to config location, or absolute) to a stopwords file configuration. /// @@ -29,51 +29,55 @@ public interface ILanguageAnalyzer : IAnalyzer string StopwordsPath { get; set; } } - /// + /// public class LanguageAnalyzer : AnalyzerBase, ILanguageAnalyzer { private string _type = "language"; - public override string Type + + /// + [JsonIgnore] + public Language? Language { - get { return _type; } - protected set { this._type = value; this.Language = value.ToEnum(); } + get => _type.ToEnum(); + set => _type = value.GetStringValue().ToLowerInvariant(); } - /// - public StopWords StopWords { get; set; } - - /// + /// public IEnumerable StemExclusionList { get; set; } - /// - [JsonIgnore] - public Language? Language { - get { return _type.ToEnum(); } - set { _type = value.GetStringValue().ToLowerInvariant(); } - } + /// + public StopWords StopWords { get; set; } - /// + /// public string StopwordsPath { get; set; } + + public override string Type + { + get => _type; + protected set + { + _type = value; + Language = value.ToEnum(); + } + } } - /// - public class LanguageAnalyzerDescriptor : - AnalyzerDescriptorBase, ILanguageAnalyzer + /// + public class LanguageAnalyzerDescriptor : AnalyzerDescriptorBase, ILanguageAnalyzer { private string _type = "language"; protected override string Type => _type; + IEnumerable ILanguageAnalyzer.StemExclusionList { get; set; } StopWords ILanguageAnalyzer.StopWords { get; set; } - IEnumerable ILanguageAnalyzer.StemExclusionList { get; set; } string ILanguageAnalyzer.StopwordsPath { get; set; } - public LanguageAnalyzerDescriptor Language(Language? language) => Assign(a => this._type = language?.GetStringValue().ToLowerInvariant()); + public LanguageAnalyzerDescriptor Language(Language? language) => Assign(a => _type = language?.GetStringValue().ToLowerInvariant()); public LanguageAnalyzerDescriptor StopWords(StopWords stopWords) => Assign(a => a.StopWords = stopWords); public LanguageAnalyzerDescriptor StopWords(params string[] stopWords) => Assign(a => a.StopWords = stopWords); public LanguageAnalyzerDescriptor StopWords(IEnumerable stopWords) => Assign(a => a.StopWords = stopWords.ToListOrNullIfEmpty()); - } } diff --git a/src/Nest/Analysis/Analyzers/NoriAnalyzer.cs b/src/Nest/Analysis/Analyzers/NoriAnalyzer.cs index 010caad0020..6471b724ff8 100644 --- a/src/Nest/Analysis/Analyzers/NoriAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/NoriAnalyzer.cs @@ -4,55 +4,55 @@ namespace Nest { /// - ///The nori analyzer consists of the following tokenizer and token filters: - /// - nori_tokenizer - /// - nori_part_of_speech token filter - /// - nori_readingform token filter - /// - lowercase token filter + /// The nori analyzer consists of the following tokenizer and token filters: + /// - nori_tokenizer + /// - nori_part_of_speech token filter + /// - nori_readingform token filter + /// - lowercase token filter /// public interface INoriAnalyzer : IAnalyzer { - /// + /// [JsonProperty("decompound_mode")] NoriDecompoundMode? DecompoundMode { get; set; } - /// - [JsonProperty("user_dictionary")] - string UserDictionary { get; set; } - - /// + /// [JsonProperty("stoptags")] IEnumerable StopTags { get; set; } + + /// + [JsonProperty("user_dictionary")] + string UserDictionary { get; set; } } - /// + /// public class NoriAnalyzer : AnalyzerBase, INoriAnalyzer { - public NoriAnalyzer() : base("nori") {} - - /// - public NoriDecompoundMode? DecompoundMode { get; set; } + public NoriAnalyzer() : base("nori") { } - /// - public string UserDictionary { get; set; } + /// + public NoriDecompoundMode? DecompoundMode { get; set; } /// public IEnumerable StopTags { get; set; } + + /// + public string UserDictionary { get; set; } } - /// + /// public class NoriAnalyzerDescriptor : AnalyzerDescriptorBase, INoriAnalyzer { protected override string Type => "nori"; - NoriDecompoundMode? INoriAnalyzer.DecompoundMode { get; set; } - string INoriAnalyzer.UserDictionary { get; set; } + NoriDecompoundMode? INoriAnalyzer.DecompoundMode { get; set; } IEnumerable INoriAnalyzer.StopTags { get; set; } + string INoriAnalyzer.UserDictionary { get; set; } - /// + /// public NoriAnalyzerDescriptor DecompoundMode(NoriDecompoundMode? mode) => Assign(a => a.DecompoundMode = mode); - /// + /// public NoriAnalyzerDescriptor UserDictionary(string path) => Assign(a => a.UserDictionary = path); /// @@ -60,6 +60,5 @@ public class NoriAnalyzerDescriptor : AnalyzerDescriptorBase public NoriAnalyzerDescriptor StopTags(params string[] stopTags) => Assign(a => a.StopTags = stopTags); - } } diff --git a/src/Nest/Analysis/Analyzers/PatternAnalyzer.cs b/src/Nest/Analysis/Analyzers/PatternAnalyzer.cs index b296023fbca..22aca44aaea 100644 --- a/src/Nest/Analysis/Analyzers/PatternAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/PatternAnalyzer.cs @@ -8,15 +8,15 @@ namespace Nest /// public interface IPatternAnalyzer : IAnalyzer { + [JsonProperty("flags")] + string Flags { get; set; } + [JsonProperty("lowercase")] bool? Lowercase { get; set; } [JsonProperty("pattern")] string Pattern { get; set; } - [JsonProperty("flags")] - string Flags { get; set; } - /// /// A list of stopword to initialize the stop filter with. Defaults to an empty list /// @@ -25,30 +25,29 @@ public interface IPatternAnalyzer : IAnalyzer StopWords StopWords { get; set; } } - /// + /// public class PatternAnalyzer : AnalyzerBase, IPatternAnalyzer { - public PatternAnalyzer() : base("pattern") {} + public PatternAnalyzer() : base("pattern") { } + + public string Flags { get; set; } public bool? Lowercase { get; set; } public string Pattern { get; set; } - public string Flags { get; set; } - public StopWords StopWords { get; set; } } - /// - public class PatternAnalyzerDescriptor : - AnalyzerDescriptorBase, IPatternAnalyzer + /// + public class PatternAnalyzerDescriptor : AnalyzerDescriptorBase, IPatternAnalyzer { protected override string Type => "pattern"; - - StopWords IPatternAnalyzer.StopWords { get; set; } - string IPatternAnalyzer.Pattern { get; set; } string IPatternAnalyzer.Flags { get; set; } bool? IPatternAnalyzer.Lowercase { get; set; } + string IPatternAnalyzer.Pattern { get; set; } + + StopWords IPatternAnalyzer.StopWords { get; set; } public PatternAnalyzerDescriptor StopWords(params string[] stopWords) => Assign(a => a.StopWords = stopWords); @@ -62,6 +61,5 @@ public PatternAnalyzerDescriptor StopWords(IEnumerable stopWords) => public PatternAnalyzerDescriptor Flags(string flags) => Assign(a => a.Flags = flags); public PatternAnalyzerDescriptor Lowercase(bool? lowercase = true) => Assign(a => a.Lowercase = lowercase); - } } diff --git a/src/Nest/Analysis/Analyzers/SimpleAnalyzer.cs b/src/Nest/Analysis/Analyzers/SimpleAnalyzer.cs index da24bec09e9..cf914acf2ae 100644 --- a/src/Nest/Analysis/Analyzers/SimpleAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/SimpleAnalyzer.cs @@ -5,15 +5,14 @@ /// public interface ISimpleAnalyzer : IAnalyzer { } - /// + /// public class SimpleAnalyzer : AnalyzerBase, ISimpleAnalyzer { - public SimpleAnalyzer() : base("simple") {} + public SimpleAnalyzer() : base("simple") { } } - /// - public class SimpleAnalyzerDescriptor : - AnalyzerDescriptorBase, ISimpleAnalyzer + /// + public class SimpleAnalyzerDescriptor : AnalyzerDescriptorBase, ISimpleAnalyzer { protected override string Type => "simple"; } diff --git a/src/Nest/Analysis/Analyzers/SnowballAnalyzer.cs b/src/Nest/Analysis/Analyzers/SnowballAnalyzer.cs index 8461163b15e..398c210710a 100644 --- a/src/Nest/Analysis/Analyzers/SnowballAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/SnowballAnalyzer.cs @@ -5,7 +5,10 @@ namespace Nest { /// /// An analyzer of type snowball that uses the standard tokenizer, with standard filter, lowercase filter, stop filter, and snowball filter. - /// The Snowball Analyzer is a stemming analyzer from Lucene that is originally based on the snowball project from snowball.tartarus.org. + /// + /// The Snowball Analyzer is a stemming analyzer from Lucene that is originally based on the snowball project from + /// snowball.tartarus.org. + /// /// public interface ISnowballAnalyzer : IAnalyzer { @@ -16,29 +19,31 @@ public interface ISnowballAnalyzer : IAnalyzer [JsonConverter(typeof(StopWordsJsonConverter))] StopWords StopWords { get; set; } } - /// + + /// public class SnowballAnalyzer : AnalyzerBase, ISnowballAnalyzer { - public SnowballAnalyzer() : base("snowball") {} + public SnowballAnalyzer() : base("snowball") { } public SnowballLanguage? Language { get; set; } public StopWords StopWords { get; set; } } - /// - public class SnowballAnalyzerDescriptor : - AnalyzerDescriptorBase, ISnowballAnalyzer + + /// + public class SnowballAnalyzerDescriptor : AnalyzerDescriptorBase, ISnowballAnalyzer { protected override string Type => "snowball"; + SnowballLanguage? ISnowballAnalyzer.Language { get; set; } StopWords ISnowballAnalyzer.StopWords { get; set; } - SnowballLanguage? ISnowballAnalyzer.Language { get; set; } public SnowballAnalyzerDescriptor StopWords(StopWords stopWords) => Assign(a => a.StopWords = stopWords); + public SnowballAnalyzerDescriptor StopWords(IEnumerable stopWords) => Assign(a => a.StopWords = stopWords.ToListOrNullIfEmpty()); + public SnowballAnalyzerDescriptor StopWords(params string[] stopWords) => Assign(a => a.StopWords = stopWords.ToListOrNullIfEmpty()); public SnowballAnalyzerDescriptor Language(SnowballLanguage? language) => Assign(a => a.Language = language); - } } diff --git a/src/Nest/Analysis/Analyzers/StandardAnalyzer.cs b/src/Nest/Analysis/Analyzers/StandardAnalyzer.cs index 6b591d8012f..58403a946a8 100644 --- a/src/Nest/Analysis/Analyzers/StandardAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/StandardAnalyzer.cs @@ -4,44 +4,44 @@ namespace Nest { /// - /// An analyzer of type standard that is built of using Standard Tokenizer, with Standard Token Filter, Lower Case Token Filter, and Stop Token Filter. + /// An analyzer of type standard that is built of using Standard Tokenizer, with Standard Token Filter, Lower Case Token Filter, and Stop Token + /// Filter. /// public interface IStandardAnalyzer : IAnalyzer { + /// + /// The maximum token length. If a token is seen that exceeds this length then it is discarded. Defaults to 255. + /// + [JsonProperty("max_token_length")] + int? MaxTokenLength { get; set; } + /// /// A list of stopword to initialize the stop filter with. Defaults to the english stop words. /// [JsonProperty("stopwords")] [JsonConverter(typeof(StopWordsJsonConverter))] StopWords StopWords { get; set; } - - /// - /// The maximum token length. If a token is seen that exceeds this length then it is discarded. Defaults to 255. - /// - [JsonProperty("max_token_length")] - int? MaxTokenLength { get; set; } } - /// + /// public class StandardAnalyzer : AnalyzerBase, IStandardAnalyzer { - public StandardAnalyzer() : base("standard") {} + public StandardAnalyzer() : base("standard") { } - /// - public StopWords StopWords { get; set; } - - /// + /// public int? MaxTokenLength { get; set; } + + /// + public StopWords StopWords { get; set; } } - /// - public class StandardAnalyzerDescriptor : - AnalyzerDescriptorBase, IStandardAnalyzer + /// + public class StandardAnalyzerDescriptor : AnalyzerDescriptorBase, IStandardAnalyzer { protected override string Type => "standard"; + int? IStandardAnalyzer.MaxTokenLength { get; set; } StopWords IStandardAnalyzer.StopWords { get; set; } - int? IStandardAnalyzer.MaxTokenLength { get; set; } public StandardAnalyzerDescriptor StopWords(params string[] stopWords) => Assign(a => a.StopWords = stopWords); @@ -53,6 +53,5 @@ public StandardAnalyzerDescriptor StopWords(IEnumerable stopWords) => public StandardAnalyzerDescriptor MaxTokenLength(int? maxTokenLength) => Assign(a => a.MaxTokenLength = maxTokenLength); - } } diff --git a/src/Nest/Analysis/Analyzers/StopAnalyzer.cs b/src/Nest/Analysis/Analyzers/StopAnalyzer.cs index 3dde8b4938b..d3be89a7195 100644 --- a/src/Nest/Analysis/Analyzers/StopAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/StopAnalyzer.cs @@ -22,21 +22,20 @@ public interface IStopAnalyzer : IAnalyzer string StopwordsPath { get; set; } } - /// + /// public class StopAnalyzer : AnalyzerBase, IStopAnalyzer { - public StopAnalyzer() : base("stop") {} + public StopAnalyzer() : base("stop") { } - /// + /// public StopWords StopWords { get; set; } - /// + /// public string StopwordsPath { get; set; } } - /// - public class StopAnalyzerDescriptor : - AnalyzerDescriptorBase, IStopAnalyzer + /// + public class StopAnalyzerDescriptor : AnalyzerDescriptorBase, IStopAnalyzer { protected override string Type => "stop"; @@ -51,6 +50,5 @@ public StopAnalyzerDescriptor StopWords(IEnumerable stopWords) => public StopAnalyzerDescriptor StopWords(StopWords stopWords) => Assign(a => a.StopWords = stopWords); public StopAnalyzerDescriptor StopwordsPath(string path) => Assign(a => a.StopwordsPath = path); - } } diff --git a/src/Nest/Analysis/Analyzers/WhitespaceAnalyzer.cs b/src/Nest/Analysis/Analyzers/WhitespaceAnalyzer.cs index 582ad72ca80..8a268b735ea 100644 --- a/src/Nest/Analysis/Analyzers/WhitespaceAnalyzer.cs +++ b/src/Nest/Analysis/Analyzers/WhitespaceAnalyzer.cs @@ -5,15 +5,14 @@ /// public interface IWhitespaceAnalyzer : IAnalyzer { } - /// + /// public class WhitespaceAnalyzer : AnalyzerBase, IWhitespaceAnalyzer { - public WhitespaceAnalyzer() : base("whitespace") {} + public WhitespaceAnalyzer() : base("whitespace") { } } - /// - public class WhitespaceAnalyzerDescriptor : - AnalyzerDescriptorBase, IWhitespaceAnalyzer + /// + public class WhitespaceAnalyzerDescriptor : AnalyzerDescriptorBase, IWhitespaceAnalyzer { protected override string Type => "whitespace"; } diff --git a/src/Nest/Analysis/CharFilters/CharFilterBase.cs b/src/Nest/Analysis/CharFilters/CharFilterBase.cs index c7595d1cb0c..bb33a8bce76 100644 --- a/src/Nest/Analysis/CharFilters/CharFilterBase.cs +++ b/src/Nest/Analysis/CharFilters/CharFilterBase.cs @@ -5,23 +5,20 @@ namespace Nest [ContractJsonConverter(typeof(CharFilterJsonConverter))] public interface ICharFilter { - [JsonProperty("version")] - string Version { get; set; } - [JsonProperty("type")] string Type { get; } + + [JsonProperty("version")] + string Version { get; set; } } public abstract class CharFilterBase : ICharFilter { - protected CharFilterBase(string type) - { - this.Type = type; - } - public string Version { get; set; } + protected CharFilterBase(string type) => Type = type; public string Type { get; protected set; } + public string Version { get; set; } } public abstract class CharFilterDescriptorBase @@ -29,10 +26,10 @@ public abstract class CharFilterDescriptorBase, TCharFilterInterface where TCharFilterInterface : class, ICharFilter { - string ICharFilter.Version { get; set; } - string ICharFilter.Type => this.Type; protected abstract string Type { get; } + string ICharFilter.Type => Type; + string ICharFilter.Version { get; set; } public TCharFilter Version(string version) => Assign(a => a.Version = version); } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/CharFilters/CharFilterJsonConverter.cs b/src/Nest/Analysis/CharFilters/CharFilterJsonConverter.cs index ffa0a912e76..ecc332bd960 100644 --- a/src/Nest/Analysis/CharFilters/CharFilterJsonConverter.cs +++ b/src/Nest/Analysis/CharFilters/CharFilterJsonConverter.cs @@ -6,19 +6,20 @@ namespace Nest { internal class CharFilterJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) => true; - public override bool CanWrite => false; public override bool CanRead => true; + public override bool CanWrite => false; + + public override bool CanConvert(Type objectType) => true; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - JObject o = JObject.Load(reader); + var o = JObject.Load(reader); - JProperty typeProperty = o.Property("type"); + var typeProperty = o.Property("type"); if (typeProperty == null) return null; var typePropertyValue = typeProperty.Value.ToString(); - switch(typePropertyValue) + switch (typePropertyValue) { case "html_strip": return o.ToObject(ElasticContractResolver.Empty); case "mapping": return o.ToObject(ElasticContractResolver.Empty); @@ -29,9 +30,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return null; } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); } } diff --git a/src/Nest/Analysis/CharFilters/CharFilters.cs b/src/Nest/Analysis/CharFilters/CharFilters.cs index 01124d2e7b9..2e8a67019aa 100644 --- a/src/Nest/Analysis/CharFilters/CharFilters.cs +++ b/src/Nest/Analysis/CharFilters/CharFilters.cs @@ -10,11 +10,12 @@ public interface ICharFilters : IIsADictionary { } public class CharFilters : IsADictionaryBase, ICharFilters { - public CharFilters() {} + public CharFilters() { } + public CharFilters(IDictionary container) : base(container) { } + public CharFilters(Dictionary container) - : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) - {} + : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) { } public void Add(string name, ICharFilter analyzer) => BackingDictionary.Add(name, analyzer); } @@ -47,14 +48,17 @@ public CharFiltersDescriptor Mapping(string name, Func - public CharFiltersDescriptor KuromojiIterationMark(string name, Func selector = null) => + public CharFiltersDescriptor KuromojiIterationMark(string name, + Func selector = null + ) => Assign(name, selector?.InvokeOrDefault(new KuromojiIterationMarkCharFilterDescriptor())); /// /// Normalizes as defined here: http://userguide.icu-project.org/transforms/normalization /// Part of the `analysis-icu` plugin: https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu.html /// - public CharFiltersDescriptor IcuNormalization(string name, Func selector) => + public CharFiltersDescriptor IcuNormalization(string name, Func selector + ) => Assign(name, selector?.Invoke(new IcuNormalizationCharFilterDescriptor())); } } diff --git a/src/Nest/Analysis/CharFilters/HtmlStripCharFilter.cs b/src/Nest/Analysis/CharFilters/HtmlStripCharFilter.cs index e0265b12bc3..2f7b667f3ad 100644 --- a/src/Nest/Analysis/CharFilters/HtmlStripCharFilter.cs +++ b/src/Nest/Analysis/CharFilters/HtmlStripCharFilter.cs @@ -4,17 +4,17 @@ /// A char filter of type html_strip stripping out HTML elements from an analyzed text. /// public interface IHtmlStripCharFilter : ICharFilter { } - /// + + /// public class HtmlStripCharFilter : CharFilterBase, IHtmlStripCharFilter { public HtmlStripCharFilter() : base("html_strip") { } } - /// - public class HtmlStripCharFilterDescriptor + /// + public class HtmlStripCharFilterDescriptor : CharFilterDescriptorBase, IHtmlStripCharFilter { protected override string Type => "html_strip"; } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/CharFilters/MappingCharFilter.cs b/src/Nest/Analysis/CharFilters/MappingCharFilter.cs index ed42c97fda3..7cb35ea081e 100644 --- a/src/Nest/Analysis/CharFilters/MappingCharFilter.cs +++ b/src/Nest/Analysis/CharFilters/MappingCharFilter.cs @@ -14,37 +14,37 @@ public interface IMappingCharFilter : ICharFilter [JsonProperty("mappings_path")] string MappingsPath { get; set; } } - /// + + /// public class MappingCharFilter : CharFilterBase, IMappingCharFilter { public MappingCharFilter() : base("mapping") { } - /// + /// public IEnumerable Mappings { get; set; } - /// + /// public string MappingsPath { get; set; } } - /// - public class MappingCharFilterDescriptor + /// + public class MappingCharFilterDescriptor : CharFilterDescriptorBase, IMappingCharFilter { protected override string Type => "mapping"; IEnumerable IMappingCharFilter.Mappings { get; set; } string IMappingCharFilter.MappingsPath { get; set; } - /// + /// public MappingCharFilterDescriptor Mappings(params string[] mappings) => Assign(a => a.Mappings = mappings); - /// + /// public MappingCharFilterDescriptor Mappings(IEnumerable mappings) => Assign(a => a.Mappings = mappings); - /// + /// public MappingCharFilterDescriptor MappingsPath(string path) => Assign(a => a.MappingsPath = path); - } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/CharFilters/PatternReplaceCharFilter.cs b/src/Nest/Analysis/CharFilters/PatternReplaceCharFilter.cs index 308839f181a..2e5f549a47d 100644 --- a/src/Nest/Analysis/CharFilters/PatternReplaceCharFilter.cs +++ b/src/Nest/Analysis/CharFilters/PatternReplaceCharFilter.cs @@ -3,7 +3,7 @@ namespace Nest { /// - /// The pattern_replace char filter allows the use of a regex to manipulate the characters in a string before analysis. + /// The pattern_replace char filter allows the use of a regex to manipulate the characters in a string before analysis. /// public interface IPatternReplaceCharFilter : ICharFilter { @@ -13,33 +13,33 @@ public interface IPatternReplaceCharFilter : ICharFilter [JsonProperty("replacement")] string Replacement { get; set; } } - - /// + + /// public class PatternReplaceCharFilter : CharFilterBase, IPatternReplaceCharFilter { public PatternReplaceCharFilter() : base("pattern_replace") { } - /// + /// public string Pattern { get; set; } - /// + /// public string Replacement { get; set; } } - /// - public class PatternReplaceCharFilterDescriptor + + /// + public class PatternReplaceCharFilterDescriptor : CharFilterDescriptorBase, IPatternReplaceCharFilter { protected override string Type => "pattern_replace"; string IPatternReplaceCharFilter.Pattern { get; set; } string IPatternReplaceCharFilter.Replacement { get; set; } - /// + /// public PatternReplaceCharFilterDescriptor Pattern(string pattern) => Assign(a => a.Pattern = pattern); - /// + /// public PatternReplaceCharFilterDescriptor Replacement(string replacement) => Assign(a => a.Replacement = replacement); - } } diff --git a/src/Nest/Analysis/Languages/Language.cs b/src/Nest/Analysis/Languages/Language.cs index 3ac32c0e0a9..0e897ef4a53 100644 --- a/src/Nest/Analysis/Languages/Language.cs +++ b/src/Nest/Analysis/Languages/Language.cs @@ -9,38 +9,38 @@ namespace Nest [JsonConverter(typeof(StringEnumConverter))] public enum Language { - Arabic, - Armenian, - Basque, - Brazilian, - Bulgarian, - Catalan, - Chinese, - Cjk, - Czech, - Danish, - Dutch, - English, - Finnish, - French, - Galician, - German, - Greek, - Hindi, - Hungarian, - Indonesian, - Irish, - Italian, + Arabic, + Armenian, + Basque, + Brazilian, + Bulgarian, + Catalan, + Chinese, + Cjk, + Czech, + Danish, + Dutch, + English, + Finnish, + French, + Galician, + German, + Greek, + Hindi, + Hungarian, + Indonesian, + Irish, + Italian, Latvian, - Norwegian, - Persian, - Portuguese, - Romanian, - Russian, + Norwegian, + Persian, + Portuguese, + Romanian, + Russian, Sorani, - Spanish, - Swedish, - Turkish, + Spanish, + Swedish, + Turkish, Thai } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Languages/SnowballLanguage.cs b/src/Nest/Analysis/Languages/SnowballLanguage.cs index 9d8bb4d997a..a2e2023983b 100644 --- a/src/Nest/Analysis/Languages/SnowballLanguage.cs +++ b/src/Nest/Analysis/Languages/SnowballLanguage.cs @@ -5,54 +5,75 @@ namespace Nest { /// - /// Snowball compatible languages + /// Snowball compatible languages /// [JsonConverter(typeof(StringEnumConverter))] public enum SnowballLanguage { - [EnumMember(Value="Armenian")] + [EnumMember(Value = "Armenian")] Armenian, - [EnumMember(Value="Basque")] + + [EnumMember(Value = "Basque")] Basque, - [EnumMember(Value="Catalan")] + + [EnumMember(Value = "Catalan")] Catalan, - [EnumMember(Value="Danish")] + + [EnumMember(Value = "Danish")] Danish, - [EnumMember(Value="Dutch")] + + [EnumMember(Value = "Dutch")] Dutch, - [EnumMember(Value="English")] + + [EnumMember(Value = "English")] English, - [EnumMember(Value="Finnish")] + + [EnumMember(Value = "Finnish")] Finnish, - [EnumMember(Value="French")] + + [EnumMember(Value = "French")] French, - [EnumMember(Value="German")] + + [EnumMember(Value = "German")] German, - [EnumMember(Value="German2")] + + [EnumMember(Value = "German2")] German2, - [EnumMember(Value="Hungarian")] + + [EnumMember(Value = "Hungarian")] Hungarian, - [EnumMember(Value="Italian")] + + [EnumMember(Value = "Italian")] Italian, - [EnumMember(Value="Kp")] + + [EnumMember(Value = "Kp")] Kp, - [EnumMember(Value="Lovins")] + + [EnumMember(Value = "Lovins")] Lovins, - [EnumMember(Value="Norwegian")] + + [EnumMember(Value = "Norwegian")] Norwegian, - [EnumMember(Value="Porter")] + + [EnumMember(Value = "Porter")] Porter, - [EnumMember(Value="Portuguese")] + + [EnumMember(Value = "Portuguese")] Portuguese, - [EnumMember(Value="Romanian")] + + [EnumMember(Value = "Romanian")] Romanian, - [EnumMember(Value="Russian")] + + [EnumMember(Value = "Russian")] Russian, - [EnumMember(Value="Spanish")] + + [EnumMember(Value = "Spanish")] Spanish, - [EnumMember(Value="Swedish")] + + [EnumMember(Value = "Swedish")] Swedish, - [EnumMember(Value="Turkish")] + + [EnumMember(Value = "Turkish")] Turkish } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Normalizers/CustomNormalizer.cs b/src/Nest/Analysis/Normalizers/CustomNormalizer.cs index 63bc5630952..dee562fb001 100644 --- a/src/Nest/Analysis/Normalizers/CustomNormalizer.cs +++ b/src/Nest/Analysis/Normalizers/CustomNormalizer.cs @@ -28,19 +28,19 @@ public interface ICustomNormalizer : INormalizer IEnumerable Filter { get; set; } } - /// + /// public class CustomNormalizer : NormalizerBase, ICustomNormalizer { - public CustomNormalizer() : base("custom") {} + public CustomNormalizer() : base("custom") { } - /// - public IEnumerable Filter { get; set; } - - /// + /// public IEnumerable CharFilter { get; set; } + + /// + public IEnumerable Filter { get; set; } } - /// + /// public class CustomNormalizerDescriptor : NormalizerDescriptorBase, ICustomNormalizer { @@ -48,17 +48,17 @@ public class CustomNormalizerDescriptor IEnumerable ICustomNormalizer.CharFilter { get; set; } IEnumerable ICustomNormalizer.Filter { get; set; } - /// + + /// public CustomNormalizerDescriptor Filters(params string[] filters) => Assign(a => a.Filter = filters); - /// + /// public CustomNormalizerDescriptor Filters(IEnumerable filters) => Assign(a => a.Filter = filters); - /// + /// public CustomNormalizerDescriptor CharFilters(params string[] charFilters) => Assign(a => a.CharFilter = charFilters); - /// + /// public CustomNormalizerDescriptor CharFilters(IEnumerable charFilters) => Assign(a => a.CharFilter = charFilters); - } } diff --git a/src/Nest/Analysis/Normalizers/NormalizerBase.cs b/src/Nest/Analysis/Normalizers/NormalizerBase.cs index c34b07df9ca..c745d302494 100644 --- a/src/Nest/Analysis/Normalizers/NormalizerBase.cs +++ b/src/Nest/Analysis/Normalizers/NormalizerBase.cs @@ -5,11 +5,11 @@ namespace Nest [ContractJsonConverter(typeof(NormalizerJsonConverter))] public interface INormalizer { - [JsonProperty("version")] - string Version { get; set; } - [JsonProperty("type")] string Type { get; } + + [JsonProperty("version")] + string Version { get; set; } } public abstract class NormalizerBase : INormalizer @@ -18,9 +18,9 @@ internal NormalizerBase() { } protected NormalizerBase(string type) => Type = type; - public string Version { get; set; } - public virtual string Type { get; protected set; } + + public string Version { get; set; } } public abstract class NormalizerDescriptorBase @@ -28,11 +28,10 @@ public abstract class NormalizerDescriptorBase, TNormalizerInterface where TNormalizerInterface : class, INormalizer { - string INormalizer.Version { get; set; } - string INormalizer.Type => this.Type; protected abstract string Type { get; } + string INormalizer.Type => Type; + string INormalizer.Version { get; set; } public TNormalizer Version(string version) => Assign(a => a.Version = version); } - } diff --git a/src/Nest/Analysis/Normalizers/NormalizerJsonConverter.cs b/src/Nest/Analysis/Normalizers/NormalizerJsonConverter.cs index 6707180f9c2..da84714c085 100644 --- a/src/Nest/Analysis/Normalizers/NormalizerJsonConverter.cs +++ b/src/Nest/Analysis/Normalizers/NormalizerJsonConverter.cs @@ -6,9 +6,10 @@ namespace Nest { internal class NormalizerJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) => true; - public override bool CanWrite => false; public override bool CanRead => true; + public override bool CanWrite => false; + + public override bool CanConvert(Type objectType) => true; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { @@ -18,16 +19,13 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist if (typeProperty == null) return null; var typePropertyValue = typeProperty.Value.ToString(); - switch(typePropertyValue) + switch (typePropertyValue) { default: return o.ToObject(ElasticContractResolver.Empty); } } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); } } diff --git a/src/Nest/Analysis/Normalizers/Normalizers.cs b/src/Nest/Analysis/Normalizers/Normalizers.cs index 5d4740c0563..41a1fc557a4 100644 --- a/src/Nest/Analysis/Normalizers/Normalizers.cs +++ b/src/Nest/Analysis/Normalizers/Normalizers.cs @@ -10,11 +10,12 @@ public interface INormalizers : IIsADictionary { } public class Normalizers : IsADictionaryBase, INormalizers { - public Normalizers() {} + public Normalizers() { } + public Normalizers(IDictionary container) : base(container) { } + public Normalizers(Dictionary container) - : base(container.ToDictionary(kv => kv.Key, kv => kv.Value)) - { } + : base(container.ToDictionary(kv => kv.Key, kv => kv.Value)) { } public void Add(string name, INormalizer analyzer) => BackingDictionary.Add(name, analyzer); } diff --git a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationAlternate.cs b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationAlternate.cs index a9fcf0e4924..5a9911aac36 100644 --- a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationAlternate.cs +++ b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationAlternate.cs @@ -11,7 +11,7 @@ namespace Nest [JsonConverter(typeof(StringEnumConverter))] public enum IcuCollationAlternate { - [EnumMember(Value="shifted")] Shifted, - [EnumMember(Value="non-ignorable")] NonIgnorable + [EnumMember(Value = "shifted")] Shifted, + [EnumMember(Value = "non-ignorable")] NonIgnorable } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationCaseFirst.cs b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationCaseFirst.cs index 218bf231ade..6139a977296 100644 --- a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationCaseFirst.cs +++ b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationCaseFirst.cs @@ -11,7 +11,7 @@ namespace Nest [JsonConverter(typeof(StringEnumConverter))] public enum IcuCollationCaseFirst { - [EnumMember(Value="lower")] Lower, - [EnumMember(Value="upper")] Upper + [EnumMember(Value = "lower")] Lower, + [EnumMember(Value = "upper")] Upper } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationDecomposition.cs b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationDecomposition.cs index c7059697728..0d3ca4aed30 100644 --- a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationDecomposition.cs +++ b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationDecomposition.cs @@ -16,7 +16,7 @@ namespace Nest [JsonConverter(typeof(StringEnumConverter))] public enum IcuCollationDecomposition { - [EnumMember(Value="no")] No, - [EnumMember(Value="identical")] Canonical + [EnumMember(Value = "no")] No, + [EnumMember(Value = "identical")] Canonical } } diff --git a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationStrength.cs b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationStrength.cs index bd1139c11dc..f3068c91324 100644 --- a/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationStrength.cs +++ b/src/Nest/Analysis/Plugins/Icu/Collation/IcuCollationStrength.cs @@ -17,14 +17,16 @@ public enum IcuCollationStrength /// It is the strongest difference. For example, dictionaries are divided into different sections by /// base character. /// - [EnumMember(Value="primary")] Primary, + [EnumMember(Value = "primary")] Primary, + /// /// Accents in the characters are considered secondary differences (for example, "as" < "às" < "at"). /// Other differences between letters can also be considered secondary differences, depending on /// the language. A secondary difference is ignored when there is a primary difference anywhere /// in the strings. /// - [EnumMember(Value="secondary")] Secondary, + [EnumMember(Value = "secondary")] Secondary, + /// /// Upper and lower case differences in characters are distinguished at tertiary strength /// (for example, "ao" < "Ao" < "aò"). In addition, a variant of a letter differs from the base @@ -32,7 +34,8 @@ public enum IcuCollationStrength /// large and small Kana. A tertiary difference is ignored when there is a primary or secondary /// difference anywhere in the strings. /// - [EnumMember(Value="tertiary")] Tertiary, + [EnumMember(Value = "tertiary")] Tertiary, + /// /// When punctuation is ignored (see Ignoring Punctuations in the User Guide) at PRIMARY to /// TERTIARY strength, an additional strength level can be used to distinguish words with @@ -40,7 +43,8 @@ public enum IcuCollationStrength /// when there is a PRIMARY, SECONDARY or TERTIARY difference. The QUATERNARY strength should /// only be used if ignoring punctuation is required. /// - [EnumMember(Value="quaternary")] Quaternary, + [EnumMember(Value = "quaternary")] Quaternary, + /// /// When all other strengths are equal, the IDENTICAL strength is used as a tiebreaker. /// The Unicode code point values of the NFD form of each string are compared, just in @@ -50,6 +54,6 @@ public enum IcuCollationStrength /// this strength substantially decreases the performance for both comparison and collation key /// generation APIs. This strength also increases the size of the collation key. /// - [EnumMember(Value="identical")] Indentical, + [EnumMember(Value = "identical")] Indentical, } } diff --git a/src/Nest/Analysis/Plugins/Icu/IcuCollationTokenFilter.cs b/src/Nest/Analysis/Plugins/Icu/IcuCollationTokenFilter.cs index d83fcdfc68f..921170ae2b1 100644 --- a/src/Nest/Analysis/Plugins/Icu/IcuCollationTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Icu/IcuCollationTokenFilter.cs @@ -1,29 +1,36 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { /// - /// Collations are used for sorting documents in a language-specific word order. The icu_collation token filter is available to all indices and defaults to using the DUCET collation, which is a best-effort attempt at language-neutral sorting. + /// Collations are used for sorting documents in a language-specific word order. The icu_collation token filter is available to all indices and + /// defaults to using the DUCET collation, which is a best-effort attempt at language-neutral sorting. /// Part of the `analysis-icu` plugin: https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu.html /// public interface IIcuCollationTokenFilter : ITokenFilter { - [JsonProperty("language")] - string Language { get; set; } - - [JsonProperty("country")] - string Country { get; set; } + /// + /// Sets the alternate handling for strength quaternary to be either shifted or non-ignorable. + /// Which boils down to ignoring punctuation and whitespace. + /// + [JsonProperty("alternate")] + IcuCollationAlternate? Alternate { get; set; } - [JsonProperty("variant")] - string Variant { get; set; } + /// + /// Useful to control which case is sorted first when case is not ignored for strength tertiary. + /// The default depends on the collation. + /// + [JsonProperty("caseFirst")] + IcuCollationCaseFirst? CaseFirst { get; set; } /// - /// The strength property determines the minimum level of difference considered significant during comparison. + /// Whether case level sorting is required. When strength is set to primary this will ignore accent differences /// - [JsonProperty("strength")] - IcuCollationStrength? Strength { get; set; } + [JsonProperty("caseLevel")] + bool? CaseLevel { get; set; } + + [JsonProperty("country")] + string Country { get; set; } /// /// Setting this decomposition property to canonical allows the Collator to handle unnormalized text properly, @@ -37,24 +44,13 @@ public interface IIcuCollationTokenFilter : ITokenFilter IcuCollationDecomposition? Decomposition { get; set; } /// - /// Sets the alternate handling for strength quaternary to be either shifted or non-ignorable. - /// Which boils down to ignoring punctuation and whitespace. - /// - [JsonProperty("alternate")] - IcuCollationAlternate? Alternate { get; set; } - - /// - /// Whether case level sorting is required. When strength is set to primary this will ignore accent differences + /// Distinguishing between Katakana and Hiragana characters in quaternary strength. /// - [JsonProperty("caseLevel")] - bool? CaseLevel { get; set; } + [JsonProperty("hiraganaQuaternaryMode")] + bool? HiraganaQuaternaryMode { get; set; } - /// - /// Useful to control which case is sorted first when case is not ignored for strength tertiary. - /// The default depends on the collation. - /// - [JsonProperty("caseFirst")] - IcuCollationCaseFirst? CaseFirst { get; set; } + [JsonProperty("language")] + string Language { get; set; } /// /// Whether digits are sorted according to their numeric representation. @@ -64,87 +60,110 @@ public interface IIcuCollationTokenFilter : ITokenFilter bool? Numeric { get; set; } /// - /// Single character or contraction. Controls what is variable for . + /// The strength property determines the minimum level of difference considered significant during comparison. /// - [JsonProperty("variableTop")] - string VariableTop { get; set; } + [JsonProperty("strength")] + IcuCollationStrength? Strength { get; set; } /// - /// Distinguishing between Katakana and Hiragana characters in quaternary strength. + /// Single character or contraction. Controls what is variable for . /// - [JsonProperty("hiraganaQuaternaryMode")] - bool? HiraganaQuaternaryMode { get; set; } + [JsonProperty("variableTop")] + string VariableTop { get; set; } + + [JsonProperty("variant")] + string Variant { get; set; } } - /// + /// public class IcuCollationTokenFilter : TokenFilterBase, IIcuCollationTokenFilter { public IcuCollationTokenFilter() : base("icu_collation") { } - /// - public string Language { get; set; } - /// - public string Country { get; set; } - /// - public string Variant { get; set; } - /// - public IcuCollationStrength? Strength { get; set; } - /// - public IcuCollationDecomposition? Decomposition { get; set; } - /// + /// public IcuCollationAlternate? Alternate { get; set; } - /// - public bool? CaseLevel { get; set; } - /// + + /// public IcuCollationCaseFirst? CaseFirst { get; set; } - /// + + /// + public bool? CaseLevel { get; set; } + + /// + public string Country { get; set; } + + /// + public IcuCollationDecomposition? Decomposition { get; set; } + + /// + public bool? HiraganaQuaternaryMode { get; set; } + + /// + public string Language { get; set; } + + /// public bool? Numeric { get; set; } - /// + + /// + public IcuCollationStrength? Strength { get; set; } + + /// public string VariableTop { get; set; } - /// - public bool? HiraganaQuaternaryMode { get; set; } + + /// + public string Variant { get; set; } } - /// + /// public class IcuCollationTokenFilterDescriptor : TokenFilterDescriptorBase, IIcuCollationTokenFilter { protected override string Type => "icu_collation"; - - string IIcuCollationTokenFilter.Language { get; set; } - string IIcuCollationTokenFilter.Country { get; set; } - string IIcuCollationTokenFilter.Variant { get; set; } - IcuCollationStrength? IIcuCollationTokenFilter.Strength { get; set; } - IcuCollationDecomposition? IIcuCollationTokenFilter.Decomposition { get; set; } IcuCollationAlternate? IIcuCollationTokenFilter.Alternate { get; set; } - bool? IIcuCollationTokenFilter.CaseLevel { get; set; } IcuCollationCaseFirst? IIcuCollationTokenFilter.CaseFirst { get; set; } + bool? IIcuCollationTokenFilter.CaseLevel { get; set; } + string IIcuCollationTokenFilter.Country { get; set; } + IcuCollationDecomposition? IIcuCollationTokenFilter.Decomposition { get; set; } + bool? IIcuCollationTokenFilter.HiraganaQuaternaryMode { get; set; } + + string IIcuCollationTokenFilter.Language { get; set; } bool? IIcuCollationTokenFilter.Numeric { get; set; } + IcuCollationStrength? IIcuCollationTokenFilter.Strength { get; set; } string IIcuCollationTokenFilter.VariableTop { get; set; } - bool? IIcuCollationTokenFilter.HiraganaQuaternaryMode { get; set; } + string IIcuCollationTokenFilter.Variant { get; set; } - /// + /// public IcuCollationTokenFilterDescriptor Language(string language) => Assign(a => a.Language = language); - /// + + /// public IcuCollationTokenFilterDescriptor Country(string country) => Assign(a => a.Country = country); - /// + + /// public IcuCollationTokenFilterDescriptor Variant(string variant) => Assign(a => a.Variant = variant); - /// + + /// public IcuCollationTokenFilterDescriptor Strength(IcuCollationStrength? strength) => Assign(a => a.Strength = strength); - /// - public IcuCollationTokenFilterDescriptor Decomposition(IcuCollationDecomposition? decomposition) => Assign(a => a.Decomposition = decomposition); - /// + + /// + public IcuCollationTokenFilterDescriptor Decomposition(IcuCollationDecomposition? decomposition) => + Assign(a => a.Decomposition = decomposition); + + /// public IcuCollationTokenFilterDescriptor Alternate(IcuCollationAlternate? alternate) => Assign(a => a.Alternate = alternate); - /// + + /// public IcuCollationTokenFilterDescriptor CaseFirst(IcuCollationCaseFirst? caseFirst) => Assign(a => a.CaseFirst = caseFirst); - /// + + /// public IcuCollationTokenFilterDescriptor CaseLevel(bool? caseLevel = true) => Assign(a => a.CaseLevel = caseLevel); - /// + + /// public IcuCollationTokenFilterDescriptor Numeric(bool? numeric = true) => Assign(a => a.Numeric = numeric); - /// + + /// public IcuCollationTokenFilterDescriptor HiraganaQuaternaryMode(bool? mode = true) => Assign(a => a.HiraganaQuaternaryMode = mode); - /// - public IcuCollationTokenFilterDescriptor VariableTop(string variableTop) => Assign(a => a.VariableTop = variableTop); + /// + public IcuCollationTokenFilterDescriptor VariableTop(string variableTop) => Assign(a => a.VariableTop = variableTop); } } diff --git a/src/Nest/Analysis/Plugins/Icu/IcuFoldingTokenFilter.cs b/src/Nest/Analysis/Plugins/Icu/IcuFoldingTokenFilter.cs index 139e16d3204..ce699f31c26 100644 --- a/src/Nest/Analysis/Plugins/Icu/IcuFoldingTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Icu/IcuFoldingTokenFilter.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -17,16 +15,16 @@ public interface IIcuFoldingTokenFilter : ITokenFilter string UnicodeSetFilter { get; set; } } - /// + /// public class IcuFoldingTokenFilter : TokenFilterBase, IIcuFoldingTokenFilter { public IcuFoldingTokenFilter() : base("icu_folding") { } - /// + /// public string UnicodeSetFilter { get; set; } } - /// + /// public class IcuFoldingTokenFilterDescriptor : TokenFilterDescriptorBase, IIcuFoldingTokenFilter { @@ -34,7 +32,7 @@ public class IcuFoldingTokenFilterDescriptor string IIcuFoldingTokenFilter.UnicodeSetFilter { get; set; } - /// + /// public IcuFoldingTokenFilterDescriptor UnicodeSetFilter(string filter) => Assign(a => a.UnicodeSetFilter = filter); } diff --git a/src/Nest/Analysis/Plugins/Icu/IcuNormalizationCharFilter.cs b/src/Nest/Analysis/Plugins/Icu/IcuNormalizationCharFilter.cs index 24d4dc3e5e9..057cc091744 100644 --- a/src/Nest/Analysis/Plugins/Icu/IcuNormalizationCharFilter.cs +++ b/src/Nest/Analysis/Plugins/Icu/IcuNormalizationCharFilter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -9,45 +8,45 @@ namespace Nest /// public interface IIcuNormalizationCharFilter : ICharFilter { - /// - /// The type of normalization - /// - [JsonProperty("name")] - IcuNormalizationType? Name { get; set; } - /// /// Set the mode parameter to decompose to convert nfc to nfd or nfkc to nfkd respectively /// [JsonProperty("mode")] IcuNormalizationMode? Mode { get; set; } + + /// + /// The type of normalization + /// + [JsonProperty("name")] + IcuNormalizationType? Name { get; set; } } - /// + + /// public class IcuNormalizationCharFilter : CharFilterBase, IIcuNormalizationCharFilter { public IcuNormalizationCharFilter() : base("icu_normalizer") { } - /// - public IcuNormalizationType? Name { get; set; } - - /// + /// public IcuNormalizationMode? Mode { get; set; } + + /// + public IcuNormalizationType? Name { get; set; } } - /// + /// public class IcuNormalizationCharFilterDescriptor : CharFilterDescriptorBase, IIcuNormalizationCharFilter { protected override string Type => "icu_normalizer"; - IcuNormalizationType? IIcuNormalizationCharFilter.Name { get; set; } IcuNormalizationMode? IIcuNormalizationCharFilter.Mode { get; set; } + IcuNormalizationType? IIcuNormalizationCharFilter.Name { get; set; } - /// + /// public IcuNormalizationCharFilterDescriptor Name(IcuNormalizationType? name = null) => Assign(a => a.Name = name); - /// + /// public IcuNormalizationCharFilterDescriptor Mode(IcuNormalizationMode? mode = null) => Assign(a => a.Mode = mode); - } } diff --git a/src/Nest/Analysis/Plugins/Icu/IcuNormalizationTokenFilter.cs b/src/Nest/Analysis/Plugins/Icu/IcuNormalizationTokenFilter.cs index 0d21393e121..06c0a02b198 100644 --- a/src/Nest/Analysis/Plugins/Icu/IcuNormalizationTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Icu/IcuNormalizationTokenFilter.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -17,16 +15,16 @@ public interface IIcuNormalizationTokenFilter : ITokenFilter IcuNormalizationType? Name { get; set; } } - /// + /// public class IcuNormalizationTokenFilter : TokenFilterBase, IIcuNormalizationTokenFilter { public IcuNormalizationTokenFilter() : base("icu_normalizer") { } - /// + /// public IcuNormalizationType? Name { get; set; } } - /// + /// public class IcuNormalizationTokenFilterDescriptor : TokenFilterDescriptorBase, IIcuNormalizationTokenFilter { @@ -34,7 +32,7 @@ public class IcuNormalizationTokenFilterDescriptor IcuNormalizationType? IIcuNormalizationTokenFilter.Name { get; set; } - /// + /// public IcuNormalizationTokenFilterDescriptor Name(IcuNormalizationType? name) => Assign(a => a.Name = name); } } diff --git a/src/Nest/Analysis/Plugins/Icu/IcuTokenizer.cs b/src/Nest/Analysis/Plugins/Icu/IcuTokenizer.cs index 288f69af4a7..1bd9e6c1025 100644 --- a/src/Nest/Analysis/Plugins/Icu/IcuTokenizer.cs +++ b/src/Nest/Analysis/Plugins/Icu/IcuTokenizer.cs @@ -19,16 +19,16 @@ public interface IIcuTokenizer : ITokenizer string RuleFiles { get; set; } } - /// + /// public class IcuTokenizer : TokenizerBase, IIcuTokenizer - { - public IcuTokenizer() { Type = "icu_tokenizer"; } + { + public IcuTokenizer() => Type = "icu_tokenizer"; - /// + /// public string RuleFiles { get; set; } - } + } - /// + /// public class IcuTokenizerDescriptor : TokenizerDescriptorBase, IIcuTokenizer { @@ -36,7 +36,7 @@ public class IcuTokenizerDescriptor string IIcuTokenizer.RuleFiles { get; set; } - /// + /// public IcuTokenizerDescriptor RuleFiles(string ruleFiles) => Assign(a => a.RuleFiles = ruleFiles); } } diff --git a/src/Nest/Analysis/Plugins/Icu/IcuTransformTokenFilter.cs b/src/Nest/Analysis/Plugins/Icu/IcuTransformTokenFilter.cs index ae5eb02f1bb..0542d372f06 100644 --- a/src/Nest/Analysis/Plugins/Icu/IcuTransformTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Icu/IcuTransformTokenFilter.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -21,18 +19,18 @@ public interface IIcuTransformTokenFilter : ITokenFilter string Id { get; set; } } - /// + /// public class IcuTransformTokenFilter : TokenFilterBase, IIcuTransformTokenFilter { public IcuTransformTokenFilter() : base("icu_transform") { } - /// + /// public IcuTransformDirection? Direction { get; set; } public string Id { get; set; } } - /// + /// public class IcuTransformTokenFilterDescriptor : TokenFilterDescriptorBase, IIcuTransformTokenFilter { @@ -41,10 +39,10 @@ public class IcuTransformTokenFilterDescriptor IcuTransformDirection? IIcuTransformTokenFilter.Direction { get; set; } string IIcuTransformTokenFilter.Id { get; set; } - /// + /// public IcuTransformTokenFilterDescriptor Direction(IcuTransformDirection? direction) => Assign(a => a.Direction = direction); - /// + /// public IcuTransformTokenFilterDescriptor Id(string id) => Assign(a => a.Id = id); } } diff --git a/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationMode.cs b/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationMode.cs index 1efca53c301..7164c22c1f5 100644 --- a/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationMode.cs +++ b/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationMode.cs @@ -13,13 +13,14 @@ public enum IcuNormalizationMode /// /// Switch normalization type to decompose /// - [EnumMember(Value="decompose")] + [EnumMember(Value = "decompose")] Decompose, + /// /// Switch normalization type to compose, which is the default so you'd never need to set this /// Included here for completeness sake because the Java API has it. /// - [EnumMember(Value="compose")] + [EnumMember(Value = "compose")] Compose } } diff --git a/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationType.cs b/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationType.cs index 982061934c4..0824674906d 100644 --- a/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationType.cs +++ b/src/Nest/Analysis/Plugins/Icu/Normalization/IcuNormalizationType.cs @@ -13,17 +13,19 @@ public enum IcuNormalizationType /// /// Characters are decomposed and then recomposed by canonical equivalence. /// - [EnumMember(Value="nfc")] + [EnumMember(Value = "nfc")] Canonical, + /// /// Characters are decomposed by compatibility, then recomposed by canonical equivalence. /// - [EnumMember(Value="nfkc")] + [EnumMember(Value = "nfkc")] Compatibility, + /// /// Characters are decomposed by compatibility, then recomposed by canonical equivalence with case folding /// - [EnumMember(Value="nfkc_cf")] + [EnumMember(Value = "nfkc_cf")] CompatibilityCaseFold } } diff --git a/src/Nest/Analysis/Plugins/Icu/Transform/IcuNormalizationType.cs b/src/Nest/Analysis/Plugins/Icu/Transform/IcuNormalizationType.cs index f251c8c8ede..08670cc0de8 100644 --- a/src/Nest/Analysis/Plugins/Icu/Transform/IcuNormalizationType.cs +++ b/src/Nest/Analysis/Plugins/Icu/Transform/IcuNormalizationType.cs @@ -11,10 +11,11 @@ namespace Nest public enum IcuTransformDirection { /// LTR - [EnumMember(Value="forward")] + [EnumMember(Value = "forward")] Forward, + /// RTL - [EnumMember(Value="reverse")] + [EnumMember(Value = "reverse")] Reverse, } } diff --git a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiAnalyzer.cs b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiAnalyzer.cs index d99140f0ce6..200a2382162 100644 --- a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiAnalyzer.cs +++ b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiAnalyzer.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -16,19 +15,18 @@ public interface IKuromojiAnalyzer : IAnalyzer string UserDictionary { get; set; } } - /// + /// public class KuromojiAnalyzer : AnalyzerBase, IKuromojiAnalyzer { - public KuromojiAnalyzer() : base("kuromoji") {} + public KuromojiAnalyzer() : base("kuromoji") { } public KuromojiTokenizationMode? Mode { get; set; } public string UserDictionary { get; set; } } - /// - public class KuromojiAnalyzerDescriptor : - AnalyzerDescriptorBase, IKuromojiAnalyzer + /// + public class KuromojiAnalyzerDescriptor : AnalyzerDescriptorBase, IKuromojiAnalyzer { protected override string Type => "kuromoji"; @@ -38,6 +36,5 @@ public class KuromojiAnalyzerDescriptor : public KuromojiAnalyzerDescriptor Mode(KuromojiTokenizationMode? mode) => Assign(a => a.Mode = mode); public KuromojiAnalyzerDescriptor UserDictionary(string userDictionary) => Assign(a => a.UserDictionary = userDictionary); - } } diff --git a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiIterationMarkCharFilter.cs b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiIterationMarkCharFilter.cs index 9f30fc52c79..b2caf4fa203 100644 --- a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiIterationMarkCharFilter.cs +++ b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiIterationMarkCharFilter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -9,39 +8,39 @@ namespace Nest /// public interface IKuromojiIterationMarkCharFilter : ICharFilter { - [JsonProperty("normalize_kanji")] - bool? NormalizeKanji { get; set; } - [JsonProperty("normalize_kana")] bool? NormalizeKana { get; set; } + + [JsonProperty("normalize_kanji")] + bool? NormalizeKanji { get; set; } } - /// + + /// public class KuromojiIterationMarkCharFilter : CharFilterBase, IKuromojiIterationMarkCharFilter { public KuromojiIterationMarkCharFilter() : base("kuromoji_iteration_mark") { } - /// - public bool? NormalizeKanji { get; set; } - - /// + /// public bool? NormalizeKana { get; set; } + + /// + public bool? NormalizeKanji { get; set; } } - /// + /// public class KuromojiIterationMarkCharFilterDescriptor : CharFilterDescriptorBase, IKuromojiIterationMarkCharFilter { protected override string Type => "kuromoji_iteration_mark"; - bool? IKuromojiIterationMarkCharFilter.NormalizeKanji { get; set; } bool? IKuromojiIterationMarkCharFilter.NormalizeKana { get; set; } + bool? IKuromojiIterationMarkCharFilter.NormalizeKanji { get; set; } - /// + /// public KuromojiIterationMarkCharFilterDescriptor NormalizeKanji(bool? normalize = true) => Assign(a => a.NormalizeKanji = normalize); - /// + /// public KuromojiIterationMarkCharFilterDescriptor NormalizeKana(bool? normalize = true) => Assign(a => a.NormalizeKana = normalize); - } } diff --git a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiPartOfSpeechTokenFilter.cs b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiPartOfSpeechTokenFilter.cs index b244f976973..2b7a6c9dabb 100644 --- a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiPartOfSpeechTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiPartOfSpeechTokenFilter.cs @@ -17,16 +17,16 @@ public interface IKuromojiPartOfSpeechTokenFilter : ITokenFilter IEnumerable StopTags { get; set; } } - /// + /// public class KuromojiPartOfSpeechTokenFilter : TokenFilterBase, IKuromojiPartOfSpeechTokenFilter { public KuromojiPartOfSpeechTokenFilter() : base("kuromoji_part_of_speech") { } - /// + /// public IEnumerable StopTags { get; set; } } - /// + /// public class KuromojiPartOfSpeechTokenFilterDescriptor : TokenFilterDescriptorBase, IKuromojiPartOfSpeechTokenFilter { @@ -34,12 +34,10 @@ public class KuromojiPartOfSpeechTokenFilterDescriptor IEnumerable IKuromojiPartOfSpeechTokenFilter.StopTags { get; set; } - /// + /// public KuromojiPartOfSpeechTokenFilterDescriptor StopTags(IEnumerable stopTags) => Assign(a => a.StopTags = stopTags); - /// + /// public KuromojiPartOfSpeechTokenFilterDescriptor StopTags(params string[] stopTags) => Assign(a => a.StopTags = stopTags); - } - } diff --git a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiReadingFormTokenFilter.cs b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiReadingFormTokenFilter.cs index 4a3d21f53f6..1a5254dedd0 100644 --- a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiReadingFormTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiReadingFormTokenFilter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -16,16 +15,16 @@ public interface IKuromojiReadingFormTokenFilter : ITokenFilter bool? UseRomaji { get; set; } } - /// + /// public class KuromojiReadingFormTokenFilter : TokenFilterBase, IKuromojiReadingFormTokenFilter { public KuromojiReadingFormTokenFilter() : base("kuromoji_readingform") { } - /// + /// public bool? UseRomaji { get; set; } } - /// + /// public class KuromojiReadingFormTokenFilterDescriptor : TokenFilterDescriptorBase, IKuromojiReadingFormTokenFilter { @@ -33,10 +32,7 @@ public class KuromojiReadingFormTokenFilterDescriptor bool? IKuromojiReadingFormTokenFilter.UseRomaji { get; set; } - /// + /// public KuromojiReadingFormTokenFilterDescriptor UseRomaji(bool? useRomaji = true) => Assign(a => a.UseRomaji = useRomaji); - - } - } diff --git a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiStemmerTokenFilter.cs b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiStemmerTokenFilter.cs index 503923d2724..d0bd41330c3 100644 --- a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiStemmerTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiStemmerTokenFilter.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -18,16 +16,16 @@ public interface IKuromojiStemmerTokenFilter : ITokenFilter int? MinimumLength { get; set; } } - /// + /// public class KuromojiStemmerTokenFilter : TokenFilterBase, IKuromojiStemmerTokenFilter { public KuromojiStemmerTokenFilter() : base("kuromoji_stemmer") { } - /// + /// public int? MinimumLength { get; set; } } - /// + /// public class KuromojiStemmerTokenFilterDescriptor : TokenFilterDescriptorBase, IKuromojiStemmerTokenFilter { @@ -35,7 +33,7 @@ public class KuromojiStemmerTokenFilterDescriptor int? IKuromojiStemmerTokenFilter.MinimumLength { get; set; } - /// + /// public KuromojiStemmerTokenFilterDescriptor MinimumLength(int? minimumLength) => Assign(a => a.MinimumLength = minimumLength); } } diff --git a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizationMode.cs b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizationMode.cs index b66b54429f2..c54073a1d85 100644 --- a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizationMode.cs +++ b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizationMode.cs @@ -16,17 +16,18 @@ public enum KuromojiTokenizationMode /// [EnumMember(Value = "normal")] Normal, + /// /// Segmentation geared towards search. This includes a decompounding process for long nouns, /// also including the full compound token as a synonym. /// [EnumMember(Value = "search")] Search, + /// /// Extended mode outputs unigrams for unknown words. /// [EnumMember(Value = "extended")] Extended - } } diff --git a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizer.cs b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizer.cs index 7c1eafe9487..a6530100500 100644 --- a/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizer.cs +++ b/src/Nest/Analysis/Plugins/Kuromoji/KuromojiTokenizer.cs @@ -8,12 +8,6 @@ namespace Nest /// public interface IKuromojiTokenizer : ITokenizer { - /// - /// The tokenization mode determines how the tokenizer handles compound and unknown words. - /// - [JsonProperty("mode")] - KuromojiTokenizationMode? Mode { get; set; } - /// /// Whether punctuation should be discarded from the output. Defaults to true. /// @@ -21,74 +15,80 @@ public interface IKuromojiTokenizer : ITokenizer bool? DiscardPunctuation { get; set; } /// - /// The Kuromoji tokenizer uses the MeCab-IPADIC dictionary by default. A user_dictionary may be - /// appended to the default dictionary. + /// The tokenization mode determines how the tokenizer handles compound and unknown words. /// - [JsonProperty("user_dictionary")] - string UserDictionary { get; set; } + [JsonProperty("mode")] + KuromojiTokenizationMode? Mode { get; set; } /// - ///The nbest_examples can be used to find a nbest_cost value based on examples. For example, - /// a value of /箱根山-箱根/成田空港-成田/ indicates that in the texts, 箱根山 (Mt. Hakone) and 成田空港 (Narita Airport) - /// we’d like a cost that gives is us 箱根 (Hakone) and 成田 (Narita). + /// The nbest_cost parameter specifies an additional Viterbi cost. The KuromojiTokenizer will include all tokens in + /// Viterbi paths that are within the nbest_cost value of the best path. + /// + [JsonProperty("nbest_cost")] + int? NBestCost { get; set; } + + /// + /// The nbest_examples can be used to find a nbest_cost value based on examples. For example, + /// a value of /箱根山-箱根/成田空港-成田/ indicates that in the texts, 箱根山 (Mt. Hakone) and 成田空港 (Narita Airport) + /// we’d like a cost that gives is us 箱根 (Hakone) and 成田 (Narita). /// [JsonProperty("nbest_examples")] string NBestExamples { get; set; } /// - /// The nbest_cost parameter specifies an additional Viterbi cost. The KuromojiTokenizer will include all tokens in - /// Viterbi paths that are within the nbest_cost value of the best path. + /// The Kuromoji tokenizer uses the MeCab-IPADIC dictionary by default. A user_dictionary may be + /// appended to the default dictionary. /// - [JsonProperty("nbest_cost")] - int? NBestCost { get; set; } + [JsonProperty("user_dictionary")] + string UserDictionary { get; set; } } - /// + /// public class KuromojiTokenizer : TokenizerBase, IKuromojiTokenizer - { - public KuromojiTokenizer() { Type = "kuromoji_tokenizer"; } - - /// - public KuromojiTokenizationMode? Mode { get; set; } + { + public KuromojiTokenizer() => Type = "kuromoji_tokenizer"; - /// + /// public bool? DiscardPunctuation { get; set; } - /// - public string UserDictionary { get; set; } + /// + public KuromojiTokenizationMode? Mode { get; set; } - /// + /// + public int? NBestCost { get; set; } + + /// public string NBestExamples { get; set; } - /// - public int? NBestCost { get; set; } - } + /// + public string UserDictionary { get; set; } + } - /// + /// public class KuromojiTokenizerDescriptor : TokenizerDescriptorBase, IKuromojiTokenizer { protected override string Type => "kuromoji_tokenizer"; + bool? IKuromojiTokenizer.DiscardPunctuation { get; set; } KuromojiTokenizationMode? IKuromojiTokenizer.Mode { get; set; } - bool? IKuromojiTokenizer.DiscardPunctuation { get; set; } - string IKuromojiTokenizer.UserDictionary { get; set; } - string IKuromojiTokenizer.NBestExamples { get; set; } int? IKuromojiTokenizer.NBestCost { get; set; } + string IKuromojiTokenizer.NBestExamples { get; set; } + string IKuromojiTokenizer.UserDictionary { get; set; } - /// + /// public KuromojiTokenizerDescriptor Mode(KuromojiTokenizationMode? mode) => Assign(a => a.Mode = mode); - /// + /// public KuromojiTokenizerDescriptor DiscardPunctuation(bool? discard = true) => Assign(a => a.DiscardPunctuation = discard); - /// + /// public KuromojiTokenizerDescriptor UserDictionary(string userDictionary) => Assign(a => a.UserDictionary = userDictionary); - /// + /// public KuromojiTokenizerDescriptor NBestExamples(string examples) => Assign(a => a.NBestExamples = examples); - /// + /// public KuromojiTokenizerDescriptor NBestCost(int? cost) => Assign(a => a.NBestCost = cost); } } diff --git a/src/Nest/Analysis/Plugins/Phonetic/PhoneticEncoder.cs b/src/Nest/Analysis/Plugins/Phonetic/PhoneticEncoder.cs index f63aac80e5b..7bf44c11fe7 100644 --- a/src/Nest/Analysis/Plugins/Phonetic/PhoneticEncoder.cs +++ b/src/Nest/Analysis/Plugins/Phonetic/PhoneticEncoder.cs @@ -9,26 +9,37 @@ public enum PhoneticEncoder { [EnumMember(Value = "metaphone")] Metaphone, + [EnumMember(Value = "double_metaphone")] DoubleMetaphone, + [EnumMember(Value = "soundex")] Soundex, + [EnumMember(Value = "refined_soundex")] RefinedSoundex, + [EnumMember(Value = "caverphone1")] Caverphone1, + [EnumMember(Value = "caverphone2")] Caverphone2, + [EnumMember(Value = "cologne")] Cologne, + [EnumMember(Value = "nysiis")] Nysiis, + [EnumMember(Value = "koelnerphonetik")] KoelnerPhonetik, + [EnumMember(Value = "haasephonetik")] HaasePhonetik, + [EnumMember(Value = "beider_morse")] Beidermorse, + [EnumMember(Value = "daitch_mokotoff")] DaitchMokotoff } diff --git a/src/Nest/Analysis/Plugins/Phonetic/PhoneticLanguage.cs b/src/Nest/Analysis/Plugins/Phonetic/PhoneticLanguage.cs index 7f6732228b9..893ded4c559 100644 --- a/src/Nest/Analysis/Plugins/Phonetic/PhoneticLanguage.cs +++ b/src/Nest/Analysis/Plugins/Phonetic/PhoneticLanguage.cs @@ -43,4 +43,4 @@ public enum PhoneticLanguage [EnumMember(Value = "spanish")] Spanish, } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Plugins/Phonetic/PhoneticNameType.cs b/src/Nest/Analysis/Plugins/Phonetic/PhoneticNameType.cs index 54dfd7dd9ef..6aec77c132a 100644 --- a/src/Nest/Analysis/Plugins/Phonetic/PhoneticNameType.cs +++ b/src/Nest/Analysis/Plugins/Phonetic/PhoneticNameType.cs @@ -16,4 +16,4 @@ public enum PhoneticNameType [EnumMember(Value = "sephardic")] Sephardic } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Plugins/Phonetic/PhoneticRuleType.cs b/src/Nest/Analysis/Plugins/Phonetic/PhoneticRuleType.cs index d5ba7190274..ef0674b6074 100644 --- a/src/Nest/Analysis/Plugins/Phonetic/PhoneticRuleType.cs +++ b/src/Nest/Analysis/Plugins/Phonetic/PhoneticRuleType.cs @@ -13,4 +13,4 @@ public enum PhoneticRuleType [EnumMember(Value = "exact")] Exact } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Plugins/Phonetic/PhoneticTokenFilter.cs b/src/Nest/Analysis/Plugins/Phonetic/PhoneticTokenFilter.cs index 63eed861f94..946c80b899f 100644 --- a/src/Nest/Analysis/Plugins/Phonetic/PhoneticTokenFilter.cs +++ b/src/Nest/Analysis/Plugins/Phonetic/PhoneticTokenFilter.cs @@ -19,47 +19,47 @@ public interface IPhoneticTokenFilter : ITokenFilter PhoneticEncoder? Encoder { get; set; } /// - ///The replace parameter (defaults to true) controls if the token processed should be replaced - /// with the encoded one (set it to true), or added (set it to false). + /// An array of languages to check. If not specified, then the language will be guessed /// - [JsonProperty("replace")] - bool? Replace { get; set; } + /// + /// Valid for only + /// + [JsonProperty("languageset")] + IEnumerable LanguageSet { get; set; } /// /// The maximum length of the emitted metaphone token. Defaults to 4 /// /// - /// Valid for only + /// Valid for only /// [JsonProperty("max_code_len")] int? MaxCodeLength { get; set; } - /// - /// Whether matching should be exact or approximate. Defaults to approximate - /// - /// - /// Valid for only - /// - [JsonProperty("rule_type")] - PhoneticRuleType? RuleType { get; set; } - /// /// Whether names are ashkenazi, sephardic, or generic. Defaults to generic /// /// - /// Valid for only + /// Valid for only /// [JsonProperty("name_type")] PhoneticNameType? NameType { get; set; } /// - /// An array of languages to check. If not specified, then the language will be guessed + /// The replace parameter (defaults to true) controls if the token processed should be replaced + /// with the encoded one (set it to true), or added (set it to false). + /// + [JsonProperty("replace")] + bool? Replace { get; set; } + + /// + /// Whether matching should be exact or approximate. Defaults to approximate /// /// - /// Valid for only + /// Valid for only /// - [JsonProperty("languageset")] - IEnumerable LanguageSet { get; set; } + [JsonProperty("rule_type")] + PhoneticRuleType? RuleType { get; set; } } /// @@ -67,23 +67,23 @@ public class PhoneticTokenFilter : TokenFilterBase, IPhoneticTokenFilter { public PhoneticTokenFilter() : base("phonetic") { } - /// + /// public PhoneticEncoder? Encoder { get; set; } - /// - public bool? Replace { get; set; } + /// + public IEnumerable LanguageSet { get; set; } - /// + /// public int? MaxCodeLength { get; set; } - /// - public PhoneticRuleType? RuleType { get; set; } - - /// + /// public PhoneticNameType? NameType { get; set; } - /// - public IEnumerable LanguageSet { get; set; } + /// + public bool? Replace { get; set; } + + /// + public PhoneticRuleType? RuleType { get; set; } } /// @@ -91,13 +91,13 @@ public class PhoneticTokenFilterDescriptor : TokenFilterDescriptorBase, IPhoneticTokenFilter { protected override string Type => "phonetic"; - - bool? IPhoneticTokenFilter.Replace { get; set; } PhoneticEncoder? IPhoneticTokenFilter.Encoder { get; set; } + IEnumerable IPhoneticTokenFilter.LanguageSet { get; set; } int? IPhoneticTokenFilter.MaxCodeLength { get; set; } - PhoneticRuleType? IPhoneticTokenFilter.RuleType { get; set; } PhoneticNameType? IPhoneticTokenFilter.NameType { get; set; } - IEnumerable IPhoneticTokenFilter.LanguageSet { get; set; } + + bool? IPhoneticTokenFilter.Replace { get; set; } + PhoneticRuleType? IPhoneticTokenFilter.RuleType { get; set; } /// public PhoneticTokenFilterDescriptor Replace(bool? replace = true) => Assign(a => a.Replace = replace); diff --git a/src/Nest/Analysis/StopWords.cs b/src/Nest/Analysis/StopWords.cs index fdb94d6d653..b9c0f3e105c 100644 --- a/src/Nest/Analysis/StopWords.cs +++ b/src/Nest/Analysis/StopWords.cs @@ -8,33 +8,33 @@ namespace Nest public class StopWords : Union> { public StopWords(string item) : base(item) { } + public StopWords(IEnumerable item) : base(item) { } public static implicit operator StopWords(string first) => new StopWords(first); + public static implicit operator StopWords(List second) => new StopWords(second); + public static implicit operator StopWords(string[] second) => new StopWords(second); } - internal class StopWordsJsonConverter :JsonConverter + internal class StopWordsJsonConverter : JsonConverter { + public static UnionJsonConverter> Unionconverter = new UnionJsonConverter>(); public override bool CanRead => true; public override bool CanWrite => true; - public static UnionJsonConverter> Unionconverter = new UnionJsonConverter>(); - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var union = Unionconverter.ReadJson(reader, objectType, existingValue, serializer) as Union>; if (union.Item1 != null) return new StopWords(union.Item1); + return new StopWords(union.Item2); } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => Unionconverter.WriteJson(writer, value, serializer); - } public override bool CanConvert(Type objectType) => true; } - } diff --git a/src/Nest/Analysis/TokenFilters/AsciiFoldingTokenFilter.cs b/src/Nest/Analysis/TokenFilters/AsciiFoldingTokenFilter.cs index ed97554e41c..22f7f4786cb 100644 --- a/src/Nest/Analysis/TokenFilters/AsciiFoldingTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/AsciiFoldingTokenFilter.cs @@ -2,7 +2,6 @@ namespace Nest { - /// /// A token filter of type asciifolding that converts alphabetic, numeric, and symbolic Unicode characters which are /// not in the first 127 ASCII characters (the “Basic Latin” Unicode block) into their ASCII equivalents, if one exists. @@ -13,7 +12,7 @@ public interface IAsciiFoldingTokenFilter : ITokenFilter bool? PreserveOriginal { get; set; } } - /// + /// public class AsciiFoldingTokenFilter : TokenFilterBase, IAsciiFoldingTokenFilter { public AsciiFoldingTokenFilter() : base("asciifolding") { } @@ -21,7 +20,7 @@ public AsciiFoldingTokenFilter() : base("asciifolding") { } public bool? PreserveOriginal { get; set; } } - /// + /// public class AsciiFoldingTokenFilterDescriptor : TokenFilterDescriptorBase, IAsciiFoldingTokenFilter { @@ -29,8 +28,7 @@ public class AsciiFoldingTokenFilterDescriptor bool? IAsciiFoldingTokenFilter.PreserveOriginal { get; set; } - /// + /// public AsciiFoldingTokenFilterDescriptor PreserveOriginal(bool? preserve = true) => Assign(a => a.PreserveOriginal = preserve); } - } diff --git a/src/Nest/Analysis/TokenFilters/CommonGramsTokenFilter.cs b/src/Nest/Analysis/TokenFilters/CommonGramsTokenFilter.cs index 78f427ff2c4..7b9ec0b7ad4 100644 --- a/src/Nest/Analysis/TokenFilters/CommonGramsTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/CommonGramsTokenFilter.cs @@ -4,8 +4,8 @@ namespace Nest { /// - /// Token filter that generates bigrams for frequently occuring terms. Single terms are still indexed. - ///Note, common_words or common_words_path field is required. + /// Token filter that generates bigrams for frequently occuring terms. Single terms are still indexed. + /// Note, common_words or common_words_path field is required. /// public interface ICommonGramsTokenFilter : ITokenFilter { @@ -35,27 +35,26 @@ public interface ICommonGramsTokenFilter : ITokenFilter bool? QueryMode { get; set; } } - /// + /// public class CommonGramsTokenFilter : TokenFilterBase, ICommonGramsTokenFilter { public CommonGramsTokenFilter() : base("common_grams") { } - /// + /// public IEnumerable CommonWords { get; set; } - /// + /// public string CommonWordsPath { get; set; } - /// + /// public bool? IgnoreCase { get; set; } - /// + /// public bool? QueryMode { get; set; } - } - /// - public class CommonGramsTokenFilterDescriptor + /// + public class CommonGramsTokenFilterDescriptor : TokenFilterDescriptorBase, ICommonGramsTokenFilter { protected override string Type => "common_grams"; @@ -65,21 +64,19 @@ public class CommonGramsTokenFilterDescriptor bool? ICommonGramsTokenFilter.IgnoreCase { get; set; } bool? ICommonGramsTokenFilter.QueryMode { get; set; } - /// + /// public CommonGramsTokenFilterDescriptor QueryMode(bool? queryMode = true) => Assign(a => a.QueryMode = queryMode); - /// + /// public CommonGramsTokenFilterDescriptor IgnoreCase(bool? ignoreCase = true) => Assign(a => a.IgnoreCase = ignoreCase); - /// + /// public CommonGramsTokenFilterDescriptor CommonWordsPath(string path) => Assign(a => a.CommonWordsPath = path); - /// + /// public CommonGramsTokenFilterDescriptor CommonWords(IEnumerable commonWords) => Assign(a => a.CommonWords = commonWords); - /// + /// public CommonGramsTokenFilterDescriptor CommonWords(params string[] commonWords) => Assign(a => a.CommonWords = commonWords); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/CompoundWord/CompoundWordTokenFilterBase.cs b/src/Nest/Analysis/TokenFilters/CompoundWord/CompoundWordTokenFilterBase.cs index 9f602b0f367..30ef879cdbf 100644 --- a/src/Nest/Analysis/TokenFilters/CompoundWord/CompoundWordTokenFilterBase.cs +++ b/src/Nest/Analysis/TokenFilters/CompoundWord/CompoundWordTokenFilterBase.cs @@ -8,18 +8,6 @@ namespace Nest /// public interface ICompoundWordTokenFilter : ITokenFilter { - /// - /// A list of words to use. - /// - [JsonProperty("word_list")] - IEnumerable WordList { get; set; } - - /// - /// A path (either relative to config location, or absolute) to a list of words. - /// - [JsonProperty("word_list_path")] - string WordListPath { get; set; } - /// /// A path (either relative to config location, or absolute) to a FOP XML hyphenation pattern file. /// @@ -27,10 +15,10 @@ public interface ICompoundWordTokenFilter : ITokenFilter string HyphenationPatternsPath { get; set; } /// - /// Minimum word size. + /// Maximum subword size. /// - [JsonProperty("min_word_size")] - int? MinWordSize { get; set; } + [JsonProperty("max_subword_size")] + int? MaxSubwordSize { get; set; } /// /// Minimum subword size. @@ -39,80 +27,91 @@ public interface ICompoundWordTokenFilter : ITokenFilter int? MinSubwordSize { get; set; } /// - /// Maximum subword size. + /// Minimum word size. /// - [JsonProperty("max_subword_size")] - int? MaxSubwordSize { get; set; } + [JsonProperty("min_word_size")] + int? MinWordSize { get; set; } /// /// Only matching the longest. /// [JsonProperty("only_longest_match")] bool? OnlyLongestMatch { get; set; } + + /// + /// A list of words to use. + /// + [JsonProperty("word_list")] + IEnumerable WordList { get; set; } + + /// + /// A path (either relative to config location, or absolute) to a list of words. + /// + [JsonProperty("word_list_path")] + string WordListPath { get; set; } } public abstract class CompoundWordTokenFilterBase : TokenFilterBase, ICompoundWordTokenFilter { protected CompoundWordTokenFilterBase(string type) : base(type) { } - /// - public IEnumerable WordList { get; set; } - - /// - public string WordListPath { get; set; } + public string HyphenationPatternsPath { get; set; } - /// - public int? MinWordSize { get; set; } + /// + public int? MaxSubwordSize { get; set; } - /// + /// public int? MinSubwordSize { get; set; } - /// - public int? MaxSubwordSize { get; set; } + /// + public int? MinWordSize { get; set; } - /// + /// public bool? OnlyLongestMatch { get; set; } - public string HyphenationPatternsPath { get; set; } + /// + public IEnumerable WordList { get; set; } + + /// + public string WordListPath { get; set; } } - /// + /// public abstract class CompoundWordTokenFilterDescriptorBase : TokenFilterDescriptorBase, ICompoundWordTokenFilter where TCompound : CompoundWordTokenFilterDescriptorBase, TCompoundInterface where TCompoundInterface : class, ICompoundWordTokenFilter { - IEnumerable ICompoundWordTokenFilter.WordList { get; set; } - string ICompoundWordTokenFilter.WordListPath { get; set; } - int? ICompoundWordTokenFilter.MinWordSize { get; set; } - int? ICompoundWordTokenFilter.MinSubwordSize { get; set; } + string ICompoundWordTokenFilter.HyphenationPatternsPath { get; set; } int? ICompoundWordTokenFilter.MaxSubwordSize { get; set; } + int? ICompoundWordTokenFilter.MinSubwordSize { get; set; } + int? ICompoundWordTokenFilter.MinWordSize { get; set; } bool? ICompoundWordTokenFilter.OnlyLongestMatch { get; set; } - string ICompoundWordTokenFilter.HyphenationPatternsPath { get; set; } + IEnumerable ICompoundWordTokenFilter.WordList { get; set; } + string ICompoundWordTokenFilter.WordListPath { get; set; } - /// + /// public TCompound WordList(IEnumerable wordList) => Assign(a => a.WordList = wordList); - /// + /// public TCompound WordList(params string[] wordList) => Assign(a => a.WordList = wordList); - /// + /// public TCompound WordListPath(string path) => Assign(a => a.WordListPath = path); - /// + /// public TCompound HyphenationPatternsPath(string path) => Assign(a => a.HyphenationPatternsPath = path); - /// + /// public TCompound MinWordSize(int? minWordSize) => Assign(a => a.MinWordSize = minWordSize); - /// + /// public TCompound MinSubwordSize(int? minSubwordSize) => Assign(a => a.MinSubwordSize = minSubwordSize); - /// + /// public TCompound MaxSubwordSize(int? maxSubwordSize) => Assign(a => a.MaxSubwordSize = maxSubwordSize); - /// + /// public TCompound OnlyLongestMatch(bool? onlyLongest = true) => Assign(a => a.OnlyLongestMatch = onlyLongest); - } } diff --git a/src/Nest/Analysis/TokenFilters/CompoundWord/DictionaryDecompounderTokenFilter.cs b/src/Nest/Analysis/TokenFilters/CompoundWord/DictionaryDecompounderTokenFilter.cs index 0d435cdc7ad..cb6f83b2449 100644 --- a/src/Nest/Analysis/TokenFilters/CompoundWord/DictionaryDecompounderTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/CompoundWord/DictionaryDecompounderTokenFilter.cs @@ -1,16 +1,18 @@ namespace Nest { public interface IDictionaryDecompounderTokenFilter : ICompoundWordTokenFilter { } - /// + + /// public class DictionaryDecompounderTokenFilter : CompoundWordTokenFilterBase, IDictionaryDecompounderTokenFilter { public DictionaryDecompounderTokenFilter() : base("dictionary_decompounder") { } } - /// + + /// public class DictionaryDecompounderTokenFilterDescriptor : CompoundWordTokenFilterDescriptorBase - , IDictionaryDecompounderTokenFilter + , IDictionaryDecompounderTokenFilter { protected override string Type => "dictionary_decompounder"; } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/CompoundWord/HyphenationDecompounderTokenFilter.cs b/src/Nest/Analysis/TokenFilters/CompoundWord/HyphenationDecompounderTokenFilter.cs index c67796afac4..9d31838c66d 100644 --- a/src/Nest/Analysis/TokenFilters/CompoundWord/HyphenationDecompounderTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/CompoundWord/HyphenationDecompounderTokenFilter.cs @@ -4,17 +4,18 @@ namespace Nest /// Token filters that allow to decompose compound words. /// public interface IHyphenationDecompounderTokenFilter : ICompoundWordTokenFilter { } - /// + + /// public class HyphenationDecompounderTokenFilter : CompoundWordTokenFilterBase, IHyphenationDecompounderTokenFilter { public HyphenationDecompounderTokenFilter() : base("hyphenation_decompounder") { } } - /// - public class HyphenationDecompounderTokenFilterDescriptor + + /// + public class HyphenationDecompounderTokenFilterDescriptor : CompoundWordTokenFilterDescriptorBase - , IHyphenationDecompounderTokenFilter + , IHyphenationDecompounderTokenFilter { protected override string Type => "hyphenation_decompounder"; } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadEncoding.cs b/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadEncoding.cs index a45bf0a96e3..a6fde9852b2 100644 --- a/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadEncoding.cs +++ b/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadEncoding.cs @@ -9,9 +9,11 @@ public enum DelimitedPayloadEncoding { [EnumMember(Value = "int")] Integer, + [EnumMember(Value = "float")] Float, + [EnumMember(Value = "identity")] Identity, } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadTokenFilter.cs b/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadTokenFilter.cs index 3420962794e..1b3c3bc5d3c 100644 --- a/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/DelimitedPayload/DelimitedPayloadTokenFilter.cs @@ -18,23 +18,21 @@ public interface IDelimitedPayloadTokenFilter : ITokenFilter /// [JsonProperty("encoding")] DelimitedPayloadEncoding? Encoding { get; set; } - } - /// + /// public class DelimitedPayloadTokenFilter : TokenFilterBase, IDelimitedPayloadTokenFilter { public DelimitedPayloadTokenFilter() : base("delimited_payload_filter") { } - /// + /// public char? Delimiter { get; set; } - /// + /// public DelimitedPayloadEncoding? Encoding { get; set; } - } - /// + /// public class DelimitedPayloadTokenFilterDescriptor : TokenFilterDescriptorBase, IDelimitedPayloadTokenFilter { @@ -43,12 +41,10 @@ public class DelimitedPayloadTokenFilterDescriptor char? IDelimitedPayloadTokenFilter.Delimiter { get; set; } DelimitedPayloadEncoding? IDelimitedPayloadTokenFilter.Encoding { get; set; } - /// + /// public DelimitedPayloadTokenFilterDescriptor Delimiter(char? delimiter) => Assign(a => a.Delimiter = delimiter); - /// + /// public DelimitedPayloadTokenFilterDescriptor Encoding(DelimitedPayloadEncoding? encoding) => Assign(a => a.Encoding = encoding); - } - } diff --git a/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramSide.cs b/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramSide.cs index 3b4e1ce8c4b..9d86f8f9035 100644 --- a/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramSide.cs +++ b/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramSide.cs @@ -9,7 +9,8 @@ public enum EdgeNGramSide { [EnumMember(Value = "front")] Front, + [EnumMember(Value = "back")] Back, } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramTokenFilter.cs b/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramTokenFilter.cs index 04c5cfa87d3..1700b356d9c 100644 --- a/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/EdgeNGram/EdgeNGramTokenFilter.cs @@ -8,57 +8,56 @@ namespace Nest public interface IEdgeNGramTokenFilter : ITokenFilter { /// - ///Defaults to 1. + /// Defaults to 2. /// - [JsonProperty("min_gram")] - int? MinGram { get; set; } + [JsonProperty("max_gram")] + int? MaxGram { get; set; } /// - ///Defaults to 2. + /// Defaults to 1. /// - [JsonProperty("max_gram")] - int? MaxGram { get; set; } + [JsonProperty("min_gram")] + int? MinGram { get; set; } /// /// Either front or back. Defaults to front. /// [JsonProperty("side")] EdgeNGramSide? Side { get; set; } - } - /// + + /// public class EdgeNGramTokenFilter : TokenFilterBase, IEdgeNGramTokenFilter { public EdgeNGramTokenFilter() : base("edge_ngram") { } - /// - public int? MinGram { get; set; } - - /// + /// public int? MaxGram { get; set; } - /// + /// + public int? MinGram { get; set; } + + /// public EdgeNGramSide? Side { get; set; } } - /// - public class EdgeNGramTokenFilterDescriptor + + /// + public class EdgeNGramTokenFilterDescriptor : TokenFilterDescriptorBase, IEdgeNGramTokenFilter { protected override string Type => "edge_ngram"; + int? IEdgeNGramTokenFilter.MaxGram { get; set; } int? IEdgeNGramTokenFilter.MinGram { get; set; } - int? IEdgeNGramTokenFilter.MaxGram { get; set; } EdgeNGramSide? IEdgeNGramTokenFilter.Side { get; set; } - /// + /// public EdgeNGramTokenFilterDescriptor MinGram(int? minGram) => Assign(a => a.MinGram = minGram); - /// + /// public EdgeNGramTokenFilterDescriptor MaxGram(int? maxGram) => Assign(a => a.MaxGram = maxGram); - /// + /// public EdgeNGramTokenFilterDescriptor Side(EdgeNGramSide? side) => Assign(a => a.Side = side); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/ElisionTokenFilter.cs b/src/Nest/Analysis/TokenFilters/ElisionTokenFilter.cs index 731abb6353a..b6bf95f9221 100644 --- a/src/Nest/Analysis/TokenFilters/ElisionTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/ElisionTokenFilter.cs @@ -15,28 +15,27 @@ public interface IElisionTokenFilter : ITokenFilter IEnumerable Articles { get; set; } } - /// + /// public class ElisionTokenFilter : TokenFilterBase, IElisionTokenFilter { public ElisionTokenFilter() : base("elision") { } - /// + /// public IEnumerable Articles { get; set; } } - /// - public class ElisionTokenFilterDescriptor + + /// + public class ElisionTokenFilterDescriptor : TokenFilterDescriptorBase, IElisionTokenFilter { protected override string Type => "elision"; IEnumerable IElisionTokenFilter.Articles { get; set; } - /// + /// public ElisionTokenFilterDescriptor Articles(IEnumerable articles) => Assign(a => a.Articles = articles); - /// + /// public ElisionTokenFilterDescriptor Articles(params string[] articles) => Assign(a => a.Articles = articles); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/FingerprintTokenFilter.cs b/src/Nest/Analysis/TokenFilters/FingerprintTokenFilter.cs index 6139252ae78..12872c30c64 100644 --- a/src/Nest/Analysis/TokenFilters/FingerprintTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/FingerprintTokenFilter.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -15,44 +10,45 @@ namespace Nest /// public interface IFingerprintTokenFilter : ITokenFilter { + /// + /// The maximum token size to emit. Defaults to 255. + /// + [JsonProperty("max_output_size")] + int? MaxOutputSize { get; set; } + /// /// The character that separates the tokens after concatenation. /// Defaults to a space. /// [JsonProperty("separator")] string Separator { get; set; } - - /// - /// The maximum token size to emit. Defaults to 255. - /// - [JsonProperty("max_output_size")] - int? MaxOutputSize { get; set; } } - /// + /// public class FingerprintTokenFilter : TokenFilterBase, IFingerprintTokenFilter { public FingerprintTokenFilter() : base("fingerprint") { } /// - /// The character that separates the tokens after concatenation. - /// Defaults to a space. + /// The maximum token size to emit. Defaults to 255. /// - public string Separator { get; set; } + public int? MaxOutputSize { get; set; } /// - /// The maximum token size to emit. Defaults to 255. + /// The character that separates the tokens after concatenation. + /// Defaults to a space. /// - public int? MaxOutputSize { get; set; } + public string Separator { get; set; } } - /// + + /// public class FingerprintTokenFilterDescriptor : TokenFilterDescriptorBase, IFingerprintTokenFilter { protected override string Type => "fingerprint"; + int? IFingerprintTokenFilter.MaxOutputSize { get; set; } string IFingerprintTokenFilter.Separator { get; set; } - int? IFingerprintTokenFilter.MaxOutputSize { get; set; } public FingerprintTokenFilterDescriptor Separator(string separator) => Assign(a => a.Separator = separator); diff --git a/src/Nest/Analysis/TokenFilters/HunspellTokenFilter.cs b/src/Nest/Analysis/TokenFilters/HunspellTokenFilter.cs index 5c4355befac..feeaf819a22 100644 --- a/src/Nest/Analysis/TokenFilters/HunspellTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/HunspellTokenFilter.cs @@ -1,19 +1,18 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { /// - /// Basic support for hunspell stemming. - /// Hunspell dictionaries will be picked up from a dedicated hunspell directory on the filesystem. + /// Basic support for hunspell stemming. + /// Hunspell dictionaries will be picked up from a dedicated hunspell directory on the filesystem. /// public interface IHunspellTokenFilter : ITokenFilter { /// - /// A locale for this filter. If this is unset, the lang or language are used instead - so one of these has to be set. + /// If only unique terms should be returned, this needs to be set to true. /// - [JsonProperty("locale")] - string Locale { get; set; } + [JsonProperty("dedup")] + bool? Dedup { get; set; } /// /// The name of a dictionary.The path to your hunspell dictionaries should be configured via @@ -23,62 +22,57 @@ public interface IHunspellTokenFilter : ITokenFilter string Dictionary { get; set; } /// - /// If only unique terms should be returned, this needs to be set to true. + /// A locale for this filter. If this is unset, the lang or language are used instead - so one of these has to be set. /// - [JsonProperty("dedup")] - bool? Dedup { get; set; } + [JsonProperty("locale")] + string Locale { get; set; } /// /// If only the longest term should be returned, set this to true. /// [JsonProperty("longest_only")] bool? LongestOnly { get; set; } - } - /// + /// public class HunspellTokenFilter : TokenFilterBase, IHunspellTokenFilter { public HunspellTokenFilter() : base("hunspell") { } - /// - public string Locale { get; set; } + /// + public bool? Dedup { get; set; } - /// + /// public string Dictionary { get; set; } - /// - public bool? Dedup { get; set; } + /// + public string Locale { get; set; } - /// + /// public bool? LongestOnly { get; set; } - - } - /// + /// public class HunspellTokenFilterDescriptor : TokenFilterDescriptorBase, IHunspellTokenFilter { protected override string Type => "hunspell"; - - bool? IHunspellTokenFilter.LongestOnly { get; set; } bool? IHunspellTokenFilter.Dedup { get; set; } - string IHunspellTokenFilter.Locale { get; set; } string IHunspellTokenFilter.Dictionary { get; set; } + string IHunspellTokenFilter.Locale { get; set; } + + bool? IHunspellTokenFilter.LongestOnly { get; set; } - /// + /// public HunspellTokenFilterDescriptor LongestOnly(bool? longestOnly = true) => Assign(a => a.LongestOnly = longestOnly); - /// + /// public HunspellTokenFilterDescriptor Dedup(bool? dedup = true) => Assign(a => a.Dedup = dedup); - /// + /// public HunspellTokenFilterDescriptor Locale(string locale) => Assign(a => a.Locale = locale); - /// + /// public HunspellTokenFilterDescriptor Dictionary(string dictionary) => Assign(a => a.Dictionary = dictionary); - } - } diff --git a/src/Nest/Analysis/TokenFilters/KStemTokenFilter.cs b/src/Nest/Analysis/TokenFilters/KStemTokenFilter.cs index def2a0913be..aec25078e27 100644 --- a/src/Nest/Analysis/TokenFilters/KStemTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/KStemTokenFilter.cs @@ -1,20 +1,21 @@ namespace Nest { /// - ///The kstem token filter is a high performance filter for english. - /// All terms must already be lowercased (use lowercase filter) for this filter to work correctly. + /// The kstem token filter is a high performance filter for english. + /// All terms must already be lowercased (use lowercase filter) for this filter to work correctly. /// public interface IKStemTokenFilter : ITokenFilter { } - /// + + /// public class KStemTokenFilter : TokenFilterBase, IKStemTokenFilter { public KStemTokenFilter() : base("kstem") { } } - /// - public class KStemTokenFilterDescriptor + + /// + public class KStemTokenFilterDescriptor : TokenFilterDescriptorBase, IKStemTokenFilter { protected override string Type => "kstem"; } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/KeepTypesTokenFilter.cs b/src/Nest/Analysis/TokenFilters/KeepTypesTokenFilter.cs index 70b88d679f6..7d34ee5b268 100644 --- a/src/Nest/Analysis/TokenFilters/KeepTypesTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/KeepTypesTokenFilter.cs @@ -8,8 +8,9 @@ namespace Nest [JsonConverter(typeof(StringEnumConverter))] public enum KeepTypesMode { - [EnumMember(Value="include")] + [EnumMember(Value = "include")] Include, + [EnumMember(Value = "exclude")] Exclude } @@ -19,45 +20,43 @@ public enum KeepTypesMode /// public interface IKeepTypesTokenFilter : ITokenFilter { + /// Whether to include or exclude the types provided on + [JsonProperty("mode")] + KeepTypesMode? Mode { get; set; } + /// A list of types to keep. [JsonProperty("types")] IEnumerable Types { get; set; } - - /// Whether to include or exclude the types provided on - [JsonProperty("mode")] - KeepTypesMode? Mode { get; set; } } - /// + + /// public class KeepTypesTokenFilter : TokenFilterBase { public KeepTypesTokenFilter() : base("keep_types") { } - /// - public IEnumerable Types { get; set; } - - /// + /// public KeepTypesMode? Mode { get; set; } + /// + public IEnumerable Types { get; set; } } - /// + + /// public class KeepTypesTokenFilterDescriptor : TokenFilterDescriptorBase, IKeepTypesTokenFilter { protected override string Type => "keep_types"; + KeepTypesMode? IKeepTypesTokenFilter.Mode { get; set; } IEnumerable IKeepTypesTokenFilter.Types { get; set; } - KeepTypesMode? IKeepTypesTokenFilter.Mode { get; set; } - /// + /// public KeepTypesTokenFilterDescriptor Types(IEnumerable types) => Assign(a => a.Types = types); - /// + /// public KeepTypesTokenFilterDescriptor Types(params string[] types) => Assign(a => a.Types = types); - /// + /// public KeepTypesTokenFilterDescriptor Mode(KeepTypesMode? mode) => Assign(a => a.Mode = mode); - - } - } diff --git a/src/Nest/Analysis/TokenFilters/KeepWordsTokenFilter.cs b/src/Nest/Analysis/TokenFilters/KeepWordsTokenFilter.cs index b2549fad0c8..3e9e11572d0 100644 --- a/src/Nest/Analysis/TokenFilters/KeepWordsTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/KeepWordsTokenFilter.cs @@ -14,56 +14,54 @@ public interface IKeepWordsTokenFilter : ITokenFilter [JsonProperty("keep_words")] IEnumerable KeepWords { get; set; } - /// - /// A path to a words file. - /// - [JsonProperty("keep_words_path")] - string KeepWordsPath { get; set; } - /// /// A boolean indicating whether to lower case the words. /// [JsonProperty("keep_words_case")] bool? KeepWordsCase { get; set; } + /// + /// A path to a words file. + /// + [JsonProperty("keep_words_path")] + string KeepWordsPath { get; set; } } - /// + + /// public class KeepWordsTokenFilter : TokenFilterBase, IKeepWordsTokenFilter { public KeepWordsTokenFilter() : base("keep") { } - /// + /// public IEnumerable KeepWords { get; set; } - /// - public string KeepWordsPath { get; set; } - - /// + /// public bool? KeepWordsCase { get; set; } + /// + public string KeepWordsPath { get; set; } } - /// - public class KeepWordsTokenFilterDescriptor + + /// + public class KeepWordsTokenFilterDescriptor : TokenFilterDescriptorBase, IKeepWordsTokenFilter { protected override string Type => "keep"; + IEnumerable IKeepWordsTokenFilter.KeepWords { get; set; } bool? IKeepWordsTokenFilter.KeepWordsCase { get; set; } string IKeepWordsTokenFilter.KeepWordsPath { get; set; } - IEnumerable IKeepWordsTokenFilter.KeepWords { get; set; } - /// + /// public KeepWordsTokenFilterDescriptor KeepWordsCase(bool? keepCase = true) => Assign(a => a.KeepWordsCase = keepCase); - /// + /// public KeepWordsTokenFilterDescriptor KeepWordsPath(string path) => Assign(a => a.KeepWordsPath = path); - /// + /// public KeepWordsTokenFilterDescriptor KeepWords(IEnumerable keepWords) => Assign(a => a.KeepWords = keepWords); - /// + /// public KeepWordsTokenFilterDescriptor KeepWords(params string[] keepWords) => Assign(a => a.KeepWords = keepWords); - } - } diff --git a/src/Nest/Analysis/TokenFilters/KeywordMarkerTokenFilter.cs b/src/Nest/Analysis/TokenFilters/KeywordMarkerTokenFilter.cs index eea9e3d078e..c58b6a11049 100644 --- a/src/Nest/Analysis/TokenFilters/KeywordMarkerTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/KeywordMarkerTokenFilter.cs @@ -6,8 +6,14 @@ namespace Nest /// /// Protects words from being modified by stemmers. Must be placed before any stemming filters. /// - public interface IKeywordMarkerTokenFilter: ITokenFilter + public interface IKeywordMarkerTokenFilter : ITokenFilter { + /// + /// Set to true to lower case all words first. Defaults to false. + /// + [JsonProperty("ignore_case")] + bool? IgnoreCase { get; set; } + /// /// A list of words to use. /// @@ -19,48 +25,43 @@ public interface IKeywordMarkerTokenFilter: ITokenFilter /// [JsonProperty("keywords_path")] string KeywordsPath { get; set; } - - /// - /// Set to true to lower case all words first. Defaults to false. - /// - [JsonProperty("ignore_case")] - bool? IgnoreCase { get; set; } } - /// + /// public class KeywordMarkerTokenFilter : TokenFilterBase, IKeywordMarkerTokenFilter { public KeywordMarkerTokenFilter() : base("keyword_marker") { } - /// + /// + public bool? IgnoreCase { get; set; } + + /// public IEnumerable Keywords { get; set; } - /// + /// public string KeywordsPath { get; set; } - - /// - public bool? IgnoreCase { get; set; } } - /// - public class KeywordMarkerTokenFilterDescriptor + + /// + public class KeywordMarkerTokenFilterDescriptor : TokenFilterDescriptorBase, IKeywordMarkerTokenFilter { protected override string Type => "keyword_marker"; + bool? IKeywordMarkerTokenFilter.IgnoreCase { get; set; } IEnumerable IKeywordMarkerTokenFilter.Keywords { get; set; } string IKeywordMarkerTokenFilter.KeywordsPath { get; set; } - bool? IKeywordMarkerTokenFilter.IgnoreCase { get; set; } - /// + /// public KeywordMarkerTokenFilterDescriptor IgnoreCase(bool? ignoreCase = true) => Assign(a => a.IgnoreCase = ignoreCase); - /// + /// public KeywordMarkerTokenFilterDescriptor KeywordsPath(string path) => Assign(a => a.KeywordsPath = path); - /// + /// public KeywordMarkerTokenFilterDescriptor Keywords(IEnumerable keywords) => Assign(a => a.Keywords = keywords); - /// + /// public KeywordMarkerTokenFilterDescriptor Keywords(params string[] keywords) => Assign(a => a.Keywords = keywords); } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/LengthTokenFilter.cs b/src/Nest/Analysis/TokenFilters/LengthTokenFilter.cs index 949f77cc78d..2a5b4ce4364 100644 --- a/src/Nest/Analysis/TokenFilters/LengthTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/LengthTokenFilter.cs @@ -7,44 +7,44 @@ namespace Nest /// public interface ILengthTokenFilter : ITokenFilter { - /// - /// The minimum number. Defaults to 0. - /// - [JsonProperty("min")] - int? Min { get; set; } - /// /// The maximum number. Defaults to Integer.MAX_VALUE. /// [JsonProperty("max")] int? Max { get; set; } + + /// + /// The minimum number. Defaults to 0. + /// + [JsonProperty("min")] + int? Min { get; set; } } - /// + + /// public class LengthTokenFilter : TokenFilterBase, ILengthTokenFilter { public LengthTokenFilter() : base("length") { } - /// - public int? Min { get; set; } - - /// + /// public int? Max { get; set; } + + /// + public int? Min { get; set; } } - /// - public class LengthTokenFilterDescriptor + + /// + public class LengthTokenFilterDescriptor : TokenFilterDescriptorBase, ILengthTokenFilter { protected override string Type => "length"; + int? ILengthTokenFilter.Max { get; set; } int? ILengthTokenFilter.Min { get; set; } - int? ILengthTokenFilter.Max { get; set; } - /// + /// public LengthTokenFilterDescriptor Min(int? minimum) => Assign(a => a.Min = minimum); - /// + /// public LengthTokenFilterDescriptor Max(int? maximum) => Assign(a => a.Max = maximum); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/LimitTokenCountTokenFilter.cs b/src/Nest/Analysis/TokenFilters/LimitTokenCountTokenFilter.cs index 218fd31dc1d..9deb845c5d5 100644 --- a/src/Nest/Analysis/TokenFilters/LimitTokenCountTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/LimitTokenCountTokenFilter.cs @@ -7,44 +7,45 @@ namespace Nest /// public interface ILimitTokenCountTokenFilter : ITokenFilter { - /// - /// The maximum number of tokens that should be indexed per document and field. - /// - [JsonProperty("max_token_count")] - int? MaxTokenCount { get; set; } - /// /// If set to true the filter exhaust the stream even if max_token_count tokens have been consumed already. /// [JsonProperty("consume_all_tokens")] bool? ConsumeAllTokens { get; set; } + + /// + /// The maximum number of tokens that should be indexed per document and field. + /// + [JsonProperty("max_token_count")] + int? MaxTokenCount { get; set; } } - /// + + /// public class LimitTokenCountTokenFilter : TokenFilterBase, ILimitTokenCountTokenFilter { public LimitTokenCountTokenFilter() : base("limit") { } - /// - public int? MaxTokenCount { get; set; } - - /// + /// public bool? ConsumeAllTokens { get; set; } + + /// + public int? MaxTokenCount { get; set; } } - /// - public class LimitTokenCountTokenFilterDescriptor + + /// + public class LimitTokenCountTokenFilterDescriptor : TokenFilterDescriptorBase, ILimitTokenCountTokenFilter { protected override string Type => "limit"; + bool? ILimitTokenCountTokenFilter.ConsumeAllTokens { get; set; } int? ILimitTokenCountTokenFilter.MaxTokenCount { get; set; } - bool? ILimitTokenCountTokenFilter.ConsumeAllTokens { get; set; } - /// - public LimitTokenCountTokenFilterDescriptor ConsumeAllToken(bool? consumeAllTokens = true) => Assign(a => a.ConsumeAllTokens = consumeAllTokens); + /// + public LimitTokenCountTokenFilterDescriptor ConsumeAllToken(bool? consumeAllTokens = true) => + Assign(a => a.ConsumeAllTokens = consumeAllTokens); - /// + /// public LimitTokenCountTokenFilterDescriptor MaxTokenCount(int? maxTokenCount) => Assign(a => a.MaxTokenCount = maxTokenCount); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/LowercaseTokenFilter.cs b/src/Nest/Analysis/TokenFilters/LowercaseTokenFilter.cs index a28a5d9f988..3d6fa4f85e6 100644 --- a/src/Nest/Analysis/TokenFilters/LowercaseTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/LowercaseTokenFilter.cs @@ -3,8 +3,8 @@ namespace Nest { /// - /// A token filter of type lowercase that normalizes token text to lower case. - /// Lowercase token filter supports Greek and Turkish lowercase token filters through the language parameter. + /// A token filter of type lowercase that normalizes token text to lower case. + /// Lowercase token filter supports Greek and Turkish lowercase token filters through the language parameter. /// public interface ILowercaseTokenFilter : ITokenFilter { @@ -14,24 +14,25 @@ public interface ILowercaseTokenFilter : ITokenFilter [JsonProperty("language")] string Language { get; set; } } - /// + + /// public class LowercaseTokenFilter : TokenFilterBase, ILowercaseTokenFilter { public LowercaseTokenFilter() : base("lowercase") { } - /// + /// public string Language { get; set; } } - /// - public class LowercaseTokenFilterDescriptor + + /// + public class LowercaseTokenFilterDescriptor : TokenFilterDescriptorBase, ILowercaseTokenFilter { protected override string Type => "lowercase"; string ILowercaseTokenFilter.Language { get; set; } - /// + /// public LowercaseTokenFilterDescriptor Language(string language) => Assign(a => a.Language = language); } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/MultiplexerTokenFilter.cs b/src/Nest/Analysis/TokenFilters/MultiplexerTokenFilter.cs index 9454b6ad78a..d1d1ef56eee 100644 --- a/src/Nest/Analysis/TokenFilters/MultiplexerTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/MultiplexerTokenFilter.cs @@ -1,5 +1,4 @@ -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; namespace Nest @@ -16,19 +15,21 @@ public interface IMultiplexerTokenFilter : ITokenFilter [JsonProperty("preserve_original")] bool? PreserveOriginal { get; set; } } + public class MultiplexerTokenFilter : TokenFilterBase, IMultiplexerTokenFilter { internal const string TokenType = "multiplexer"; + public MultiplexerTokenFilter() : base(TokenType) { } - /// + /// public IEnumerable Filters { get; set; } - /// + /// public bool? PreserveOriginal { get; set; } - } - /// + + /// public class MultiplexerTokenFilterDescriptor : TokenFilterDescriptorBase, IMultiplexerTokenFilter { @@ -37,14 +38,13 @@ public class MultiplexerTokenFilterDescriptor IEnumerable IMultiplexerTokenFilter.Filters { get; set; } bool? IMultiplexerTokenFilter.PreserveOriginal { get; set; } - /// + /// public MultiplexerTokenFilterDescriptor Filters(IEnumerable filters) => Assign(a => a.Filters = filters); - /// + /// public MultiplexerTokenFilterDescriptor Filters(params string[] filters) => Assign(a => a.Filters = filters); - /// + /// public MultiplexerTokenFilterDescriptor PreserveOriginal(bool? preserve = true) => Assign(a => a.PreserveOriginal = preserve); } - } diff --git a/src/Nest/Analysis/TokenFilters/NgramTokenFilter.cs b/src/Nest/Analysis/TokenFilters/NgramTokenFilter.cs index 65204840b0a..8d168fa0056 100644 --- a/src/Nest/Analysis/TokenFilters/NgramTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/NgramTokenFilter.cs @@ -8,44 +8,43 @@ namespace Nest public interface INGramTokenFilter : ITokenFilter { /// - /// Defaults to 1. + /// Defaults to 2 /// - [JsonProperty("min_gram")] - int? MinGram { get; set; } + [JsonProperty("max_gram")] + int? MaxGram { get; set; } /// - /// Defaults to 2 + /// Defaults to 1. /// - [JsonProperty("max_gram")] - int? MaxGram { get; set; } + [JsonProperty("min_gram")] + int? MinGram { get; set; } } - /// + /// public class NGramTokenFilter : TokenFilterBase, INGramTokenFilter { public NGramTokenFilter() : base("ngram") { } - /// - public int? MinGram { get; set; } - - /// + /// public int? MaxGram { get; set; } + + /// + public int? MinGram { get; set; } } - /// - public class NGramTokenFilterDescriptor + + /// + public class NGramTokenFilterDescriptor : TokenFilterDescriptorBase, INGramTokenFilter { protected override string Type => "ngram"; + int? INGramTokenFilter.MaxGram { get; set; } int? INGramTokenFilter.MinGram { get; set; } - int? INGramTokenFilter.MaxGram { get; set; } - /// + /// public NGramTokenFilterDescriptor MinGram(int? minGram) => Assign(a => a.MinGram = minGram); - /// + /// public NGramTokenFilterDescriptor MaxGram(int? maxGram) => Assign(a => a.MaxGram = maxGram); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/NoriPartOfSpeechTokenFilter.cs b/src/Nest/Analysis/TokenFilters/NoriPartOfSpeechTokenFilter.cs index 93870344550..0c41ffecfa6 100644 --- a/src/Nest/Analysis/TokenFilters/NoriPartOfSpeechTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/NoriPartOfSpeechTokenFilter.cs @@ -11,7 +11,7 @@ public interface INoriPartOfSpeechTokenFilter : ITokenFilter IEnumerable StopTags { get; set; } } - /// + /// public class NoriPartOfSpeechTokenFilter : TokenFilterBase, INoriPartOfSpeechTokenFilter { public NoriPartOfSpeechTokenFilter() : base("nori_part_of_speech") { } @@ -19,7 +19,8 @@ public NoriPartOfSpeechTokenFilter() : base("nori_part_of_speech") { } /// public IEnumerable StopTags { get; set; } } - /// + + /// public class NoriPartOfSpeechTokenFilterDescriptor : TokenFilterDescriptorBase, INoriPartOfSpeechTokenFilter { @@ -32,7 +33,5 @@ public class NoriPartOfSpeechTokenFilterDescriptor /// public NoriPartOfSpeechTokenFilterDescriptor StopTags(params string[] stopTags) => Assign(a => a.StopTags = stopTags); - } - } diff --git a/src/Nest/Analysis/TokenFilters/PatternCaptureTokenFilter.cs b/src/Nest/Analysis/TokenFilters/PatternCaptureTokenFilter.cs index 5d6c895f481..ae87470e440 100644 --- a/src/Nest/Analysis/TokenFilters/PatternCaptureTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/PatternCaptureTokenFilter.cs @@ -20,35 +20,35 @@ public interface IPatternCaptureTokenFilter : ITokenFilter [JsonProperty("preserve_original")] bool? PreserveOriginal { get; set; } } - /// + + /// public class PatternCaptureTokenFilter : TokenFilterBase, IPatternCaptureTokenFilter { public PatternCaptureTokenFilter() : base("pattern_capture") { } - /// + /// public IEnumerable Patterns { get; set; } - /// + /// public bool? PreserveOriginal { get; set; } } - /// - public class PatternCaptureTokenFilterDescriptor + + /// + public class PatternCaptureTokenFilterDescriptor : TokenFilterDescriptorBase, IPatternCaptureTokenFilter { protected override string Type => "pattern_capture"; + IEnumerable IPatternCaptureTokenFilter.Patterns { get; set; } bool? IPatternCaptureTokenFilter.PreserveOriginal { get; set; } - IEnumerable IPatternCaptureTokenFilter.Patterns { get; set; } - /// + /// public PatternCaptureTokenFilterDescriptor PreserveOriginal(bool? preserve = true) => Assign(a => a.PreserveOriginal = preserve); - /// + /// public PatternCaptureTokenFilterDescriptor Patterns(IEnumerable patterns) => Assign(a => a.Patterns = patterns); - /// + /// public PatternCaptureTokenFilterDescriptor Patterns(params string[] patterns) => Assign(a => a.Patterns = patterns); - } - } diff --git a/src/Nest/Analysis/TokenFilters/PatternReplaceTokenFilter.cs b/src/Nest/Analysis/TokenFilters/PatternReplaceTokenFilter.cs index 2029142c7ce..84d4d6bc5ac 100644 --- a/src/Nest/Analysis/TokenFilters/PatternReplaceTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/PatternReplaceTokenFilter.cs @@ -3,7 +3,7 @@ namespace Nest { /// - /// The pattern_replace token filter allows to easily handle string replacements based on a regular expression. + /// The pattern_replace token filter allows to easily handle string replacements based on a regular expression. /// public interface IPatternReplaceTokenFilter : ITokenFilter { @@ -19,19 +19,21 @@ public interface IPatternReplaceTokenFilter : ITokenFilter [JsonProperty("replacement")] string Replacement { get; set; } } - /// + + /// public class PatternReplaceTokenFilter : TokenFilterBase, IPatternReplaceTokenFilter { public PatternReplaceTokenFilter() : base("pattern_replace") { } - /// + /// public string Pattern { get; set; } - /// + /// public string Replacement { get; set; } } - /// - public class PatternReplaceTokenFilterDescriptor + + /// + public class PatternReplaceTokenFilterDescriptor : TokenFilterDescriptorBase, IPatternReplaceTokenFilter { protected override string Type => "pattern_replace"; @@ -40,12 +42,10 @@ public class PatternReplaceTokenFilterDescriptor string IPatternReplaceTokenFilter.Replacement { get; set; } - /// + /// public PatternReplaceTokenFilterDescriptor Pattern(string pattern) => Assign(a => a.Pattern = pattern); - /// + /// public PatternReplaceTokenFilterDescriptor Replacement(string replacement) => Assign(a => a.Replacement = replacement); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/PorterStemTokenFilter.cs b/src/Nest/Analysis/TokenFilters/PorterStemTokenFilter.cs index 74accd94eb2..50a6a2568e8 100644 --- a/src/Nest/Analysis/TokenFilters/PorterStemTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/PorterStemTokenFilter.cs @@ -4,16 +4,17 @@ /// A token filter of type porterStem that transforms the token stream as per the Porter stemming algorithm. /// public interface IPorterStemTokenFilter : ITokenFilter { } - /// + + /// public class PorterStemTokenFilter : TokenFilterBase, IPorterStemTokenFilter { public PorterStemTokenFilter() : base("porter_stem") { } } - /// - public class PorterStemTokenFilterDescriptor + + /// + public class PorterStemTokenFilterDescriptor : TokenFilterDescriptorBase, IPorterStemTokenFilter { protected override string Type => "porter_stem"; } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/RemoveDuplicatesTokenFilter.cs b/src/Nest/Analysis/TokenFilters/RemoveDuplicatesTokenFilter.cs index 8916cd1490b..3e59dd5da15 100644 --- a/src/Nest/Analysis/TokenFilters/RemoveDuplicatesTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/RemoveDuplicatesTokenFilter.cs @@ -1,22 +1,19 @@ -using System.Collections; -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace Nest +namespace Nest { /// /// A token filter that drops identical tokens at the same position /// public interface IRemoveDuplicatesTokenFilter : ITokenFilter { } - /// + /// public class RemoveDuplicatesTokenFilter : TokenFilterBase, IRemoveDuplicatesTokenFilter { internal const string TokenType = "remove_duplicates"; + public RemoveDuplicatesTokenFilter() : base(TokenType) { } } - /// + /// public class RemoveDuplicatesTokenFilterDescriptor : TokenFilterDescriptorBase, IRemoveDuplicatesTokenFilter { diff --git a/src/Nest/Analysis/TokenFilters/ReverseTokenFilter.cs b/src/Nest/Analysis/TokenFilters/ReverseTokenFilter.cs index 469bb867155..32a2a4f2b0b 100644 --- a/src/Nest/Analysis/TokenFilters/ReverseTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/ReverseTokenFilter.cs @@ -4,16 +4,17 @@ /// A token filter of type reverse that simply reverses the tokens. /// public interface IReverseTokenFilter : ITokenFilter { } - /// + + /// public class ReverseTokenFilter : TokenFilterBase, IReverseTokenFilter { public ReverseTokenFilter() : base("reverse") { } } - /// - public class ReverseTokenFilterDescriptor + + /// + public class ReverseTokenFilterDescriptor : TokenFilterDescriptorBase, IReverseTokenFilter { protected override string Type => "reverse"; } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/Shingle/ShingleTokenFilter.cs b/src/Nest/Analysis/TokenFilters/Shingle/ShingleTokenFilter.cs index 47b72bc8a98..f61d4e0a5b2 100644 --- a/src/Nest/Analysis/TokenFilters/Shingle/ShingleTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/Shingle/ShingleTokenFilter.cs @@ -3,16 +3,17 @@ namespace Nest { /// - /// A token filter of type shingle that constructs shingles (token n-grams) from a token stream. + /// A token filter of type shingle that constructs shingles (token n-grams) from a token stream. /// In other words, it creates combinations of tokens as a single token. /// public interface IShingleTokenFilter : ITokenFilter { /// - /// The minimum shingle size. Defaults to 2. + /// The string to use as a replacement for each position at which there is no actual token in the stream. For instance this string is used if + /// the position increment is greater than one when a stop filter is used together with the shingle filter. Defaults to "_" /// - [JsonProperty("min_shingle_size")] - int? MinShingleSize { get; set; } + [JsonProperty("filler_token")] + string FillerToken { get; set; } /// /// The maximum shingle size. Defaults to 2. @@ -20,6 +21,12 @@ public interface IShingleTokenFilter : ITokenFilter [JsonProperty("max_shingle_size")] int? MaxShingleSize { get; set; } + /// + /// The minimum shingle size. Defaults to 2. + /// + [JsonProperty("min_shingle_size")] + int? MinShingleSize { get; set; } + /// /// If true the output will contain the input tokens (unigrams) as well as the shingles. Defaults to true. /// @@ -27,7 +34,7 @@ public interface IShingleTokenFilter : ITokenFilter bool? OutputUnigrams { get; set; } /// - /// If output_unigrams is false the output will contain the input tokens (unigrams) if no shingles are available. + /// If output_unigrams is false the output will contain the input tokens (unigrams) if no shingles are available. /// Note if output_unigrams is set to true this setting has no effect. Defaults to false. /// [JsonProperty("output_unigrams_if_no_shingles")] @@ -38,68 +45,62 @@ public interface IShingleTokenFilter : ITokenFilter /// [JsonProperty("token_separator")] string TokenSeparator { get; set; } - - /// - /// The string to use as a replacement for each position at which there is no actual token in the stream. For instance this string is used if the position increment is greater than one when a stop filter is used together with the shingle filter. Defaults to "_" - /// - [JsonProperty("filler_token")] - string FillerToken { get; set; } } - /// + /// public class ShingleTokenFilter : TokenFilterBase, IShingleTokenFilter { public ShingleTokenFilter() : base("shingle") { } - /// - public int? MinShingleSize { get; set; } + /// + public string FillerToken { get; set; } - /// + /// public int? MaxShingleSize { get; set; } - /// + /// + public int? MinShingleSize { get; set; } + + /// public bool? OutputUnigrams { get; set; } - /// + /// public bool? OutputUnigramsIfNoShingles { get; set; } - /// + /// public string TokenSeparator { get; set; } - - /// - public string FillerToken { get; set; } } - /// - public class ShingleTokenFilterDescriptor + + /// + public class ShingleTokenFilterDescriptor : TokenFilterDescriptorBase, IShingleTokenFilter { protected override string Type => "shingle"; + string IShingleTokenFilter.FillerToken { get; set; } + int? IShingleTokenFilter.MaxShingleSize { get; set; } + int? IShingleTokenFilter.MinShingleSize { get; set; } bool? IShingleTokenFilter.OutputUnigrams { get; set; } bool? IShingleTokenFilter.OutputUnigramsIfNoShingles { get; set; } - int? IShingleTokenFilter.MinShingleSize { get; set; } - int? IShingleTokenFilter.MaxShingleSize { get; set; } string IShingleTokenFilter.TokenSeparator { get; set; } - string IShingleTokenFilter.FillerToken { get; set; } - /// + /// public ShingleTokenFilterDescriptor OutputUnigrams(bool? output = true) => Assign(a => a.OutputUnigrams = output); - /// - public ShingleTokenFilterDescriptor OutputUnigramsIfNoShingles(bool? outputIfNo = true) => Assign(a => a.OutputUnigramsIfNoShingles = outputIfNo); + /// + public ShingleTokenFilterDescriptor OutputUnigramsIfNoShingles(bool? outputIfNo = true) => + Assign(a => a.OutputUnigramsIfNoShingles = outputIfNo); - /// + /// public ShingleTokenFilterDescriptor MinShingleSize(int? minShingleSize) => Assign(a => a.MinShingleSize = minShingleSize); - /// + /// public ShingleTokenFilterDescriptor MaxShingleSize(int? maxShingleSize) => Assign(a => a.MaxShingleSize = maxShingleSize); - /// + /// public ShingleTokenFilterDescriptor TokenSeparator(string separator) => Assign(a => a.TokenSeparator = separator); - /// + /// public ShingleTokenFilterDescriptor FillerToken(string filler) => Assign(a => a.FillerToken = filler); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/SnowballTokenFilter.cs b/src/Nest/Analysis/TokenFilters/SnowballTokenFilter.cs index 79c4f77e0e9..30dab4e1439 100644 --- a/src/Nest/Analysis/TokenFilters/SnowballTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/SnowballTokenFilter.cs @@ -11,26 +11,25 @@ public interface ISnowballTokenFilter : ITokenFilter SnowballLanguage? Language { get; set; } } - /// + /// public class SnowballTokenFilter : TokenFilterBase, ISnowballTokenFilter { public SnowballTokenFilter() : base("snowball") { } - /// + /// [JsonProperty("language")] public SnowballLanguage? Language { get; set; } - } - /// - public class SnowballTokenFilterDescriptor + + /// + public class SnowballTokenFilterDescriptor : TokenFilterDescriptorBase, ISnowballTokenFilter { protected override string Type => "snowball"; SnowballLanguage? ISnowballTokenFilter.Language { get; set; } - /// + /// public SnowballTokenFilterDescriptor Language(SnowballLanguage? language) => Assign(a => a.Language = language); } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/StandardTokenFilter.cs b/src/Nest/Analysis/TokenFilters/StandardTokenFilter.cs index e92f0007707..1b9aef0c122 100644 --- a/src/Nest/Analysis/TokenFilters/StandardTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/StandardTokenFilter.cs @@ -4,17 +4,17 @@ /// A token filter of type standard that normalizes tokens extracted with the Standard Tokenizer. /// public interface IStandardTokenFilter : ITokenFilter { } - /// + + /// public class StandardTokenFilter : TokenFilterBase, IStandardTokenFilter { public StandardTokenFilter() : base("standard") { } } - /// - public class StandardTokenFilterDescriptor + /// + public class StandardTokenFilterDescriptor : TokenFilterDescriptorBase, IStandardTokenFilter { protected override string Type => "standard"; } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/StemmerOverrideTokenFilter.cs b/src/Nest/Analysis/TokenFilters/StemmerOverrideTokenFilter.cs index 4bf2b231c54..7f1c5871a44 100644 --- a/src/Nest/Analysis/TokenFilters/StemmerOverrideTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/StemmerOverrideTokenFilter.cs @@ -4,7 +4,8 @@ namespace Nest { /// - /// Overrides stemming algorithms, by applying a custom mapping, then protecting these terms from being modified by stemmers. Must be placed before any stemming filters. + /// Overrides stemming algorithms, by applying a custom mapping, then protecting these terms from being modified by stemmers. Must be placed + /// before any stemming filters. /// public interface IStemmerOverrideTokenFilter : ITokenFilter { @@ -20,20 +21,21 @@ public interface IStemmerOverrideTokenFilter : ITokenFilter [JsonProperty("rules_path")] string RulesPath { get; set; } } - /// + + /// public class StemmerOverrideTokenFilter : TokenFilterBase, IStemmerOverrideTokenFilter { public StemmerOverrideTokenFilter() : base("stemmer_override") { } - /// + /// public IEnumerable Rules { get; set; } - /// + /// public string RulesPath { get; set; } - } - /// - public class StemmerOverrideTokenFilterDescriptor + + /// + public class StemmerOverrideTokenFilterDescriptor : TokenFilterDescriptorBase, IStemmerOverrideTokenFilter { protected override string Type => "stemmer_override"; @@ -41,15 +43,13 @@ public class StemmerOverrideTokenFilterDescriptor IEnumerable IStemmerOverrideTokenFilter.Rules { get; set; } string IStemmerOverrideTokenFilter.RulesPath { get; set; } - /// + /// public StemmerOverrideTokenFilterDescriptor Rules(IEnumerable rules) => Assign(a => a.Rules = rules); - /// + /// public StemmerOverrideTokenFilterDescriptor Rules(params string[] rules) => Assign(a => a.Rules = rules); - /// + /// public StemmerOverrideTokenFilterDescriptor RulesPath(string path) => Assign(a => a.RulesPath = path); - } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/StemmerTokenFilter.cs b/src/Nest/Analysis/TokenFilters/StemmerTokenFilter.cs index 9133292f316..8e4552fb0af 100644 --- a/src/Nest/Analysis/TokenFilters/StemmerTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/StemmerTokenFilter.cs @@ -10,23 +10,23 @@ public interface IStemmerTokenFilter : ITokenFilter [JsonProperty("language")] string Language { get; set; } } + public class StemmerTokenFilter : TokenFilterBase, IStemmerTokenFilter { public StemmerTokenFilter() : base("stemmer") { } public string Language { get; set; } - } - /// - public class StemmerTokenFilterDescriptor + + /// + public class StemmerTokenFilterDescriptor : TokenFilterDescriptorBase, IStemmerTokenFilter { protected override string Type => "stemmer"; string IStemmerTokenFilter.Language { get; set; } - /// + /// public StemmerTokenFilterDescriptor Language(string language) => Assign(a => a.Language = language); } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/Stop/StopTokenFilter.cs b/src/Nest/Analysis/TokenFilters/Stop/StopTokenFilter.cs index 21a24c19142..a7187f03057 100644 --- a/src/Nest/Analysis/TokenFilters/Stop/StopTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/Stop/StopTokenFilter.cs @@ -8,6 +8,20 @@ namespace Nest /// public interface IStopTokenFilter : ITokenFilter { + /// + /// Set to true to lower case all words first. Defaults to false. + /// + [JsonProperty("ignore_case")] + bool? IgnoreCase { get; set; } + + /// + /// Set to false in order to not ignore the last term of a search if it is a stop word. + /// This is very useful for the completion suggester as a query like green a can + /// be extended to green apple even though you remove stop words in general. Defaults to true. + /// + [JsonProperty("remove_trailing")] + bool? RemoveTrailing { get; set; } + /// /// A list of stop words to use. Defaults to `_english_` stop words. /// @@ -15,12 +29,6 @@ public interface IStopTokenFilter : ITokenFilter [JsonConverter(typeof(StopWordsJsonConverter))] StopWords StopWords { get; set; } - /// - /// Set to true to lower case all words first. Defaults to false. - /// - [JsonProperty("ignore_case")] - bool? IgnoreCase { get; set; } - /// /// A path (either relative to config location, or absolute) to a stopwords /// file configuration. Each stop word should be in its own "line" @@ -28,34 +36,27 @@ public interface IStopTokenFilter : ITokenFilter /// [JsonProperty("stopwords_path")] string StopWordsPath { get; set; } - - /// - /// Set to false in order to not ignore the last term of a search if it is a stop word. - /// This is very useful for the completion suggester as a query like green a can - /// be extended to green apple even though you remove stop words in general. Defaults to true. - /// - [JsonProperty("remove_trailing")] - bool? RemoveTrailing { get; set; } } - /// + /// public class StopTokenFilter : TokenFilterBase, IStopTokenFilter { public StopTokenFilter() : base("stop") { } - /// - public StopWords StopWords { get; set; } - - /// + /// public bool? IgnoreCase { get; set; } - /// - public string StopWordsPath { get; set; } - - /// + /// public bool? RemoveTrailing { get; set; } + + /// + public StopWords StopWords { get; set; } + + /// + public string StopWordsPath { get; set; } } - /// + + /// public class StopTokenFilterDescriptor : TokenFilterDescriptorBase, IStopTokenFilter { @@ -66,24 +67,22 @@ public class StopTokenFilterDescriptor StopWords IStopTokenFilter.StopWords { get; set; } string IStopTokenFilter.StopWordsPath { get; set; } - /// + /// public StopTokenFilterDescriptor IgnoreCase(bool? ignoreCase = true) => Assign(a => a.IgnoreCase = ignoreCase); - /// + /// public StopTokenFilterDescriptor RemoveTrailing(bool? removeTrailing = true) => Assign(a => a.RemoveTrailing = removeTrailing); - /// + /// public StopTokenFilterDescriptor StopWords(StopWords stopWords) => Assign(a => a.StopWords = stopWords); - /// + /// public StopTokenFilterDescriptor StopWords(IEnumerable stopWords) => Assign(a => a.StopWords = stopWords.ToListOrNullIfEmpty()); - /// + /// public StopTokenFilterDescriptor StopWords(params string[] stopWords) => Assign(a => a.StopWords = stopWords); - /// + /// public StopTokenFilterDescriptor StopWordsPath(string path) => Assign(a => a.StopWordsPath = path); - } - } diff --git a/src/Nest/Analysis/TokenFilters/Synonym/SynonymFormat.cs b/src/Nest/Analysis/TokenFilters/Synonym/SynonymFormat.cs index 11e226b5da8..5d1de75e498 100644 --- a/src/Nest/Analysis/TokenFilters/Synonym/SynonymFormat.cs +++ b/src/Nest/Analysis/TokenFilters/Synonym/SynonymFormat.cs @@ -9,7 +9,8 @@ public enum SynonymFormat { [EnumMember(Value = "solr")] Solr, + [EnumMember(Value = "wordnet")] WordNet } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/Synonym/SynonymGraphTokenFilter.cs b/src/Nest/Analysis/TokenFilters/Synonym/SynonymGraphTokenFilter.cs index db2ab8bc889..d8bf3e45d0f 100644 --- a/src/Nest/Analysis/TokenFilters/Synonym/SynonymGraphTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/Synonym/SynonymGraphTokenFilter.cs @@ -10,101 +10,100 @@ namespace Nest /// public interface ISynonymGraphTokenFilter : ITokenFilter { - /// - /// a path a synonyms file relative to the node's `config` location. - /// - [JsonProperty("synonyms_path")] - string SynonymsPath { get; set; } + [JsonProperty("expand")] + bool? Expand { get; set; } [JsonProperty("format")] SynonymFormat? Format { get; set; } - [JsonProperty("synonyms")] - IEnumerable Synonyms { get; set; } - [JsonProperty("ignore_case")] [Obsolete("Will be removed in Elasticsearch 7.x, if you need to ignore case add a lowercase filter before this synonym filter")] bool? IgnoreCase { get; set; } - [JsonProperty("expand")] - bool? Expand { get; set; } + /// + [JsonProperty("lenient")] + bool? Lenient { get; set; } + + [JsonProperty("synonyms")] + IEnumerable Synonyms { get; set; } + + /// + /// a path a synonyms file relative to the node's `config` location. + /// + [JsonProperty("synonyms_path")] + string SynonymsPath { get; set; } [JsonProperty("tokenizer")] string Tokenizer { get; set; } - - /// - [JsonProperty("lenient")] - bool? Lenient { get; set; } } - /// + /// public class SynonymGraphTokenFilter : TokenFilterBase, ISynonymGraphTokenFilter { public SynonymGraphTokenFilter() : base("synonym_graph") { } - /// - public string SynonymsPath { get; set; } + /// + public bool? Expand { get; set; } - /// + /// public SynonymFormat? Format { get; set; } - /// - public IEnumerable Synonyms { get; set; } - - /// + /// [Obsolete("Will be removed in Elasticsearch 7.x, if you need to ignore case add a lowercase filter before this synonym filter")] public bool? IgnoreCase { get; set; } - /// - public bool? Expand { get; set; } - - /// + /// public bool? Lenient { get; set; } - /// + /// + public IEnumerable Synonyms { get; set; } + + /// + public string SynonymsPath { get; set; } + + /// public string Tokenizer { get; set; } } - /// + + /// public class SynonymGraphTokenFilterDescriptor : TokenFilterDescriptorBase, ISynonymGraphTokenFilter { protected override string Type => "synonym_graph"; + bool? ISynonymGraphTokenFilter.Expand { get; set; } + SynonymFormat? ISynonymGraphTokenFilter.Format { get; set; } bool? ISynonymGraphTokenFilter.IgnoreCase { get; set; } - bool? ISynonymGraphTokenFilter.Expand { get; set; } bool? ISynonymGraphTokenFilter.Lenient { get; set; } - string ISynonymGraphTokenFilter.Tokenizer { get; set; } - string ISynonymGraphTokenFilter.SynonymsPath { get; set; } - SynonymFormat? ISynonymGraphTokenFilter.Format{ get; set; } IEnumerable ISynonymGraphTokenFilter.Synonyms { get; set; } + string ISynonymGraphTokenFilter.SynonymsPath { get; set; } + string ISynonymGraphTokenFilter.Tokenizer { get; set; } - /// + /// [Obsolete("Will be removed in Elasticsearch 7.x, if you need to ignore case add a lowercase filter before this synonym filter")] public SynonymGraphTokenFilterDescriptor IgnoreCase(bool? ignoreCase = true) => Assign(a => a.IgnoreCase = ignoreCase); - /// + /// public SynonymGraphTokenFilterDescriptor Expand(bool? expand = true) => Assign(a => a.Expand = expand); - /// + /// public SynonymGraphTokenFilterDescriptor Lenient(bool? lenient = true) => Assign(a => a.Lenient = lenient); - /// + /// public SynonymGraphTokenFilterDescriptor Tokenizer(string tokenizer) => Assign(a => a.Tokenizer = tokenizer); - /// + /// public SynonymGraphTokenFilterDescriptor SynonymsPath(string path) => Assign(a => a.SynonymsPath = path); - /// + /// public SynonymGraphTokenFilterDescriptor Format(SynonymFormat? format) => Assign(a => a.Format = format); - /// + /// public SynonymGraphTokenFilterDescriptor Synonyms(IEnumerable synonymGraphs) => Assign(a => a.Synonyms = synonymGraphs); - /// + /// public SynonymGraphTokenFilterDescriptor Synonyms(params string[] synonymGraphs) => Assign(a => a.Synonyms = synonymGraphs); - } - } diff --git a/src/Nest/Analysis/TokenFilters/Synonym/SynonymTokenFilter.cs b/src/Nest/Analysis/TokenFilters/Synonym/SynonymTokenFilter.cs index fbdb7f153f7..06182640cc2 100644 --- a/src/Nest/Analysis/TokenFilters/Synonym/SynonymTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/Synonym/SynonymTokenFilter.cs @@ -9,102 +9,101 @@ namespace Nest /// public interface ISynonymTokenFilter : ITokenFilter { - /// - /// a path a synonyms file relative to the node's `config` location. - /// - [JsonProperty("synonyms_path")] - string SynonymsPath { get; set; } + [JsonProperty("expand")] + bool? Expand { get; set; } [JsonProperty("format")] SynonymFormat? Format { get; set; } - [JsonProperty("synonyms")] - IEnumerable Synonyms { get; set; } - [JsonProperty("ignore_case")] [Obsolete("Will be removed in Elasticsearch 7.x, if you need to ignore case add a lowercase filter before this synonym filter")] bool? IgnoreCase { get; set; } - [JsonProperty("expand")] - bool? Expand { get; set; } - - [JsonProperty("tokenizer")] - string Tokenizer { get; set; } - /// /// If `true` ignores exceptions while parsing the synonym configuration. It is important // to note that only those synonym rules which cannot get parsed are ignored. /// [JsonProperty("lenient")] bool? Lenient { get; set; } + + [JsonProperty("synonyms")] + IEnumerable Synonyms { get; set; } + + /// + /// a path a synonyms file relative to the node's `config` location. + /// + [JsonProperty("synonyms_path")] + string SynonymsPath { get; set; } + + [JsonProperty("tokenizer")] + string Tokenizer { get; set; } } - /// + /// public class SynonymTokenFilter : TokenFilterBase, ISynonymTokenFilter { public SynonymTokenFilter() : base("synonym") { } - /// - public string SynonymsPath { get; set; } + /// + public bool? Expand { get; set; } - /// + /// public SynonymFormat? Format { get; set; } - /// - public IEnumerable Synonyms { get; set; } - - /// + /// [Obsolete("Will be removed in Elasticsearch 7.x, if you need to ignore case add a lowercase filter before this synonym filter")] public bool? IgnoreCase { get; set; } - /// - public bool? Expand { get; set; } - - /// + /// public bool? Lenient { get; set; } - /// + /// + public IEnumerable Synonyms { get; set; } + + /// + public string SynonymsPath { get; set; } + + /// public string Tokenizer { get; set; } } - /// + + /// public class SynonymTokenFilterDescriptor : TokenFilterDescriptorBase, ISynonymTokenFilter { protected override string Type => "synonym"; + bool? ISynonymTokenFilter.Expand { get; set; } + SynonymFormat? ISynonymTokenFilter.Format { get; set; } bool? ISynonymTokenFilter.IgnoreCase { get; set; } - bool? ISynonymTokenFilter.Expand { get; set; } bool? ISynonymTokenFilter.Lenient { get; set; } - string ISynonymTokenFilter.Tokenizer { get; set; } - string ISynonymTokenFilter.SynonymsPath { get; set; } - SynonymFormat? ISynonymTokenFilter.Format { get; set; } IEnumerable ISynonymTokenFilter.Synonyms { get; set; } + string ISynonymTokenFilter.SynonymsPath { get; set; } + string ISynonymTokenFilter.Tokenizer { get; set; } - /// + /// [Obsolete("Will be removed in Elasticsearch 7.x, if you need to ignore case add a lowercase filter before this synonym filter")] public SynonymTokenFilterDescriptor IgnoreCase(bool? ignoreCase = true) => Assign(a => a.IgnoreCase = ignoreCase); - /// + /// public SynonymTokenFilterDescriptor Expand(bool? expand = true) => Assign(a => a.Expand = expand); - /// + /// public SynonymTokenFilterDescriptor Lenient(bool? lenient = true) => Assign(a => a.Lenient = lenient); - /// + /// public SynonymTokenFilterDescriptor Tokenizer(string tokenizer) => Assign(a => a.Tokenizer = tokenizer); - /// + /// public SynonymTokenFilterDescriptor SynonymsPath(string path) => Assign(a => a.SynonymsPath = path); - /// + /// public SynonymTokenFilterDescriptor Format(SynonymFormat? format) => Assign(a => a.Format = format); - /// + /// public SynonymTokenFilterDescriptor Synonyms(IEnumerable synonyms) => Assign(a => a.Synonyms = synonyms); - /// + /// public SynonymTokenFilterDescriptor Synonyms(params string[] synonyms) => Assign(a => a.Synonyms = synonyms); - } - } diff --git a/src/Nest/Analysis/TokenFilters/TokenFilterBase.cs b/src/Nest/Analysis/TokenFilters/TokenFilterBase.cs index a13fe3a58a1..155a50233bb 100644 --- a/src/Nest/Analysis/TokenFilters/TokenFilterBase.cs +++ b/src/Nest/Analysis/TokenFilters/TokenFilterBase.cs @@ -5,38 +5,33 @@ namespace Nest [ContractJsonConverter(typeof(TokenFilterJsonConverter))] public interface ITokenFilter { - [JsonProperty("version")] - string Version { get; set; } - [JsonProperty("type")] string Type { get; } + [JsonProperty("version")] + string Version { get; set; } } public abstract class TokenFilterBase : ITokenFilter { - protected TokenFilterBase(string type) - { - this.Type = type; - } - - [JsonProperty("version")] - public string Version { get; set; } + protected TokenFilterBase(string type) => Type = type; [JsonProperty("type")] public string Type { get; protected set; } + + [JsonProperty("version")] + public string Version { get; set; } } - public abstract class TokenFilterDescriptorBase + public abstract class TokenFilterDescriptorBase : DescriptorBase, ITokenFilter where TTokenFilter : TokenFilterDescriptorBase, TTokenFilterInterface where TTokenFilterInterface : class, ITokenFilter { - string ITokenFilter.Version { get; set; } - string ITokenFilter.Type => this.Type; protected abstract string Type { get; } + string ITokenFilter.Type => Type; + string ITokenFilter.Version { get; set; } public TTokenFilter Version(string version) => Assign(a => a.Version = version); } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/TokenFilterJsonConverter.cs b/src/Nest/Analysis/TokenFilters/TokenFilterJsonConverter.cs index fc36dae5144..ab43f823164 100644 --- a/src/Nest/Analysis/TokenFilters/TokenFilterJsonConverter.cs +++ b/src/Nest/Analysis/TokenFilters/TokenFilterJsonConverter.cs @@ -6,19 +6,20 @@ namespace Nest { internal class TokenFilterJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) => true; - public override bool CanWrite => false; public override bool CanRead => true; + public override bool CanWrite => false; + + public override bool CanConvert(Type objectType) => true; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - JObject o = JObject.Load(reader); + var o = JObject.Load(reader); - JProperty typeProperty = o.Property("type"); + var typeProperty = o.Property("type"); if (typeProperty == null) return null; var typePropertyValue = typeProperty.Value.ToString(); - switch(typePropertyValue.ToLowerInvariant()) + switch (typePropertyValue.ToLowerInvariant()) { case "asciifolding": return o.ToObject(ElasticContractResolver.Empty); case "common_grams": return o.ToObject(ElasticContractResolver.Empty); @@ -67,9 +68,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return null; } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); } } diff --git a/src/Nest/Analysis/TokenFilters/TokenFilters.cs b/src/Nest/Analysis/TokenFilters/TokenFilters.cs index a0bc22e0c02..55a04c40424 100644 --- a/src/Nest/Analysis/TokenFilters/TokenFilters.cs +++ b/src/Nest/Analysis/TokenFilters/TokenFilters.cs @@ -6,33 +6,23 @@ namespace Nest { [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] - public interface ITokenFilters : IIsADictionary - { - } + public interface ITokenFilters : IIsADictionary { } public class TokenFilters : IsADictionaryBase, ITokenFilters { - public TokenFilters() - { - } + public TokenFilters() { } - public TokenFilters(IDictionary container) : base(container) - { - } + public TokenFilters(IDictionary container) : base(container) { } public TokenFilters(Dictionary container) - : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) - { - } + : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) { } public void Add(string name, ITokenFilter analyzer) => BackingDictionary.Add(name, analyzer); } public class TokenFiltersDescriptor : IsADictionaryDescriptorBase { - public TokenFiltersDescriptor() : base(new TokenFilters()) - { - } + public TokenFiltersDescriptor() : base(new TokenFilters()) { } public TokenFiltersDescriptor UserDefined(string name, ITokenFilter analyzer) => Assign(name, analyzer); @@ -40,14 +30,16 @@ public TokenFiltersDescriptor() : base(new TokenFilters()) /// Token filters that allow to decompose compound words using a dictionary /// public TokenFiltersDescriptor DictionaryDecompounder(string name, - Func selector) => + Func selector + ) => Assign(name, selector?.Invoke(new DictionaryDecompounderTokenFilterDescriptor())); /// /// Token filters that allow to decompose compound words using FOP XML /// public TokenFiltersDescriptor HyphenationDecompounder(string name, - Func selector) => + Func selector + ) => Assign(name, selector?.Invoke(new HyphenationDecompounderTokenFilterDescriptor())); /// @@ -99,7 +91,9 @@ public TokenFiltersDescriptor WordDelimiter(string name, Func not in the first 127 ASCII characters (the “Basic Latin” Unicode block) into their ASCII equivalents, if one exists. /// - public TokenFiltersDescriptor WordDelimiterGraph(string name, Func selector) => + public TokenFiltersDescriptor WordDelimiterGraph(string name, + Func selector + ) => Assign(name, selector?.Invoke(new WordDelimiterGraphTokenFilterDescriptor())); /// @@ -110,8 +104,8 @@ public TokenFiltersDescriptor AsciiFolding(string name, Func - /// Token filter that generates bigrams for frequently occuring terms. Single terms are still indexed. - ///Note, common_words or common_words_path field is required. + /// Token filter that generates bigrams for frequently occuring terms. Single terms are still indexed. + /// Note, common_words or common_words_path field is required. /// public TokenFiltersDescriptor CommonGrams(string name, Func selector) => Assign(name, selector?.Invoke(new CommonGramsTokenFilterDescriptor())); @@ -119,7 +113,8 @@ public TokenFiltersDescriptor CommonGrams(string name, Func /// Splits tokens into tokens and payload whenever a delimiter character is found. /// - public TokenFiltersDescriptor DelimitedPayload(string name, Func selector) => + public TokenFiltersDescriptor DelimitedPayload(string name, Func selector + ) => Assign(name, selector?.Invoke(new DelimitedPayloadTokenFilterDescriptor())); /// @@ -129,8 +124,8 @@ public TokenFiltersDescriptor Elision(string name, Func - /// Basic support for hunspell stemming. - /// Hunspell dictionaries will be picked up from a dedicated hunspell directory on the filesystem. + /// Basic support for hunspell stemming. + /// Hunspell dictionaries will be picked up from a dedicated hunspell directory on the filesystem. /// public TokenFiltersDescriptor Hunspell(string name, Func selector) => Assign(name, selector?.Invoke(new HunspellTokenFilterDescriptor())); @@ -154,8 +149,8 @@ public TokenFiltersDescriptor KeywordMarker(string name, Func - ///The kstem token filter is a high performance filter for english. - /// All terms must already be lowercased (use lowercase filter) for this filter to work correctly. + /// The kstem token filter is a high performance filter for english. + /// All terms must already be lowercased (use lowercase filter) for this filter to work correctly. /// public TokenFiltersDescriptor KStem(string name, Func selector = null) => Assign(name, selector.InvokeOrDefault(new KStemTokenFilterDescriptor())); @@ -169,12 +164,13 @@ public TokenFiltersDescriptor Length(string name, Func /// Limits the number of tokens that are indexed per document and field. /// - public TokenFiltersDescriptor LimitTokenCount(string name, Func selector) => + public TokenFiltersDescriptor LimitTokenCount(string name, Func selector + ) => Assign(name, selector?.Invoke(new LimitTokenCountTokenFilterDescriptor())); /// - /// A token filter of type lowercase that normalizes token text to lower case. - /// Lowercase token filter supports Greek and Turkish lowercase token filters through the language parameter. + /// A token filter of type lowercase that normalizes token text to lower case. + /// Lowercase token filter supports Greek and Turkish lowercase token filters through the language parameter. /// public TokenFiltersDescriptor Lowercase(string name, Func selector = null) => Assign(name, selector.InvokeOrDefault(new LowercaseTokenFilterDescriptor())); @@ -228,9 +224,11 @@ public TokenFiltersDescriptor Stemmer(string name, Func - /// Overrides stemming algorithms, by applying a custom mapping, then protecting these terms from being modified by stemmers. Must be placed before any stemming filters. + /// Overrides stemming algorithms, by applying a custom mapping, then protecting these terms from being modified by stemmers. Must be placed + /// before any stemming filters. /// - public TokenFiltersDescriptor StemmerOverride(string name, Func selector) => + public TokenFiltersDescriptor StemmerOverride(string name, Func selector + ) => Assign(name, selector?.Invoke(new StemmerOverrideTokenFilterDescriptor())); /// @@ -271,26 +269,33 @@ public TokenFiltersDescriptor Fingerprint(string name, Func - public TokenFiltersDescriptor KuromojiStemmer(string name, Func selector = null) => + public TokenFiltersDescriptor KuromojiStemmer(string name, + Func selector = null + ) => Assign(name, selector.InvokeOrDefault(new KuromojiStemmerTokenFilterDescriptor())); /// /// The kuromoji_readingform token filter replaces the token with its reading form in either katakana or romaji. /// Part of the `analysis-kuromoji` plugin: https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-kuromoji.html /// - public TokenFiltersDescriptor KuromojiReadingForm(string name, Func selector) => + public TokenFiltersDescriptor KuromojiReadingForm(string name, + Func selector + ) => Assign(name, selector.Invoke(new KuromojiReadingFormTokenFilterDescriptor())); /// /// The kuromoji_part_of_speech token filter removes tokens that match a set of part-of-speech tags. /// Part of the `analysis-kuromoji` plugin: https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-kuromoji.html /// - public TokenFiltersDescriptor KuromojiPartOfSpeech(string name, Func selector) => + public TokenFiltersDescriptor KuromojiPartOfSpeech(string name, + Func selector + ) => Assign(name, selector.Invoke(new KuromojiPartOfSpeechTokenFilterDescriptor())); /// - /// Collations are used for sorting documents in a language-specific word order. The icu_collation token filter is available to all indices and defaults to using the DUCET collation, which is a best-effort attempt at language-neutral sorting. + /// Collations are used for sorting documents in a language-specific word order. The icu_collation token filter is available to all indices and + /// defaults to using the DUCET collation, which is a best-effort attempt at language-neutral sorting. /// Part of the `analysis-icu` plugin: https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu.html /// public TokenFiltersDescriptor IcuCollation(string name, Func selector) => @@ -307,7 +312,8 @@ public TokenFiltersDescriptor IcuFolding(string name, Func - public TokenFiltersDescriptor IcuNormalization(string name, Func selector) => + public TokenFiltersDescriptor IcuNormalization(string name, Func selector + ) => Assign(name, selector.Invoke(new IcuNormalizationTokenFilterDescriptor())); /// @@ -318,8 +324,9 @@ public TokenFiltersDescriptor IcuNormalization(string name, Func selector) => Assign(name, selector.Invoke(new IcuTransformTokenFilterDescriptor())); - /// - public TokenFiltersDescriptor NoriPartOfSpeech(string name, Func selector) => + /// + public TokenFiltersDescriptor NoriPartOfSpeech(string name, Func selector + ) => Assign(name, selector.Invoke(new NoriPartOfSpeechTokenFilterDescriptor())); /// @@ -330,7 +337,9 @@ public TokenFiltersDescriptor Multiplexer(string name, Func A token filter of type remove_duplicates that drops identical tokens at the same position. - public TokenFiltersDescriptor RemoveDuplicates(string name, Func selector = null) => + public TokenFiltersDescriptor RemoveDuplicates(string name, + Func selector = null + ) => Assign(name, selector.InvokeOrDefault(new RemoveDuplicatesTokenFilterDescriptor())); } } diff --git a/src/Nest/Analysis/TokenFilters/TrimTokenFilter.cs b/src/Nest/Analysis/TokenFilters/TrimTokenFilter.cs index e204728eae2..313b5636f45 100644 --- a/src/Nest/Analysis/TokenFilters/TrimTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/TrimTokenFilter.cs @@ -5,15 +5,16 @@ /// public interface ITrimTokenFilter : ITokenFilter { } - /// + /// public class TrimTokenFilter : TokenFilterBase, ITrimTokenFilter { public TrimTokenFilter() : base("trim") { } } - /// - public class TrimTokenFilterDescriptor + + /// + public class TrimTokenFilterDescriptor : TokenFilterDescriptorBase, ITrimTokenFilter { protected override string Type => "trim"; } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/TruncateTokenFilter.cs b/src/Nest/Analysis/TokenFilters/TruncateTokenFilter.cs index 117bf514dea..d5a310c4f0f 100644 --- a/src/Nest/Analysis/TokenFilters/TruncateTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/TruncateTokenFilter.cs @@ -3,7 +3,7 @@ namespace Nest { /// - /// The truncate token filter can be used to truncate tokens into a specific length. This can come in handy with keyword (single token) + /// The truncate token filter can be used to truncate tokens into a specific length. This can come in handy with keyword (single token) /// based mapped fields that are used for sorting in order to reduce memory usage. /// public interface ITruncateTokenFilter : ITokenFilter @@ -13,26 +13,26 @@ public interface ITruncateTokenFilter : ITokenFilter /// [JsonProperty("length")] int? Length { get; set; } - } + } - /// + /// public class TruncateTokenFilter : TokenFilterBase, ITruncateTokenFilter { public TruncateTokenFilter() : base("truncate") { } - /// + /// public int? Length { get; set; } } - /// - public class TruncateTokenFilterDescriptor + + /// + public class TruncateTokenFilterDescriptor : TokenFilterDescriptorBase, ITruncateTokenFilter { protected override string Type => "truncate"; int? ITruncateTokenFilter.Length { get; set; } - /// + /// public TruncateTokenFilterDescriptor Length(int? length) => Assign(a => a.Length = length); } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/UniqueTokenFilter.cs b/src/Nest/Analysis/TokenFilters/UniqueTokenFilter.cs index 4495357da5b..dcdc44cec41 100644 --- a/src/Nest/Analysis/TokenFilters/UniqueTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/UniqueTokenFilter.cs @@ -14,25 +14,24 @@ public interface IUniqueTokenFilter : ITokenFilter bool? OnlyOnSamePosition { get; set; } } - /// + /// public class UniqueTokenFilter : TokenFilterBase, IUniqueTokenFilter { public UniqueTokenFilter() : base("unique") { } - /// + /// public bool? OnlyOnSamePosition { get; set; } } - /// - public class UniqueTokenFilterDescriptor + /// + public class UniqueTokenFilterDescriptor : TokenFilterDescriptorBase, IUniqueTokenFilter { protected override string Type => "unique"; bool? IUniqueTokenFilter.OnlyOnSamePosition { get; set; } - /// + /// public UniqueTokenFilterDescriptor OnlyOnSamePosition(bool? samePositionOnly = true) => Assign(a => a.OnlyOnSamePosition = samePositionOnly); } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/UppercaseTokenFilter.cs b/src/Nest/Analysis/TokenFilters/UppercaseTokenFilter.cs index dc3ace155b3..832e8282078 100644 --- a/src/Nest/Analysis/TokenFilters/UppercaseTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/UppercaseTokenFilter.cs @@ -5,17 +5,16 @@ /// public interface IUppercaseTokenFilter : ITokenFilter { } - /// + /// public class UppercaseTokenFilter : TokenFilterBase, IUppercaseTokenFilter { public UppercaseTokenFilter() : base("uppercase") { } } - /// - public class UppercaseTokenFilterDescriptor + /// + public class UppercaseTokenFilterDescriptor : TokenFilterDescriptorBase, IUppercaseTokenFilter { protected override string Type => "uppercase"; } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/TokenFilters/WordDelimiter/WordDelimiterTokenFilter.cs b/src/Nest/Analysis/TokenFilters/WordDelimiter/WordDelimiterTokenFilter.cs index 56e104d3fcf..1bd832fd798 100644 --- a/src/Nest/Analysis/TokenFilters/WordDelimiter/WordDelimiterTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/WordDelimiter/WordDelimiterTokenFilter.cs @@ -9,16 +9,16 @@ namespace Nest public interface IWordDelimiterTokenFilter : ITokenFilter { /// - /// If true causes parts of words to be generated: "PowerShot" ⇒ "Power" "Shot". Defaults to true. + /// If true causes all subword parts to be catenated: "wi-fi-4000" ⇒ "wifi4000". Defaults to false. /// - [JsonProperty("generate_word_parts")] - bool? GenerateWordParts { get; set; } + [JsonProperty("catenate_all")] + bool? CatenateAll { get; set; } /// - /// If true causes number subwords to be generated: "500-42" ⇒ "500" "42". Defaults to true. + /// If true causes maximum runs of number parts to be catenated: "500-42" ⇒ "50042". Defaults to false. /// - [JsonProperty("generate_number_parts")] - bool? GenerateNumberParts { get; set; } + [JsonProperty("catenate_numbers")] + bool? CatenateNumbers { get; set; } /// /// If true causes maximum runs of word parts to be catenated: "wi-fi" ⇒ "wifi". Defaults to false. @@ -27,22 +27,16 @@ public interface IWordDelimiterTokenFilter : ITokenFilter bool? CatenateWords { get; set; } /// - /// If true causes maximum runs of number parts to be catenated: "500-42" ⇒ "50042". Defaults to false. - /// - [JsonProperty("catenate_numbers")] - bool? CatenateNumbers { get; set; } - - /// - /// If true causes all subword parts to be catenated: "wi-fi-4000" ⇒ "wifi4000". Defaults to false. + /// If true causes number subwords to be generated: "500-42" ⇒ "500" "42". Defaults to true. /// - [JsonProperty("catenate_all")] - bool? CatenateAll { get; set; } + [JsonProperty("generate_number_parts")] + bool? GenerateNumberParts { get; set; } /// - /// If true causes "PowerShot" to be two tokens; ("Power-Shot" remains two parts regards). Defaults to true. + /// If true causes parts of words to be generated: "PowerShot" ⇒ "Power" "Shot". Defaults to true. /// - [JsonProperty("split_on_case_change")] - bool? SplitOnCaseChange { get; set; } + [JsonProperty("generate_word_parts")] + bool? GenerateWordParts { get; set; } /// /// If true includes original words in subwords: "500-42" ⇒ "500-42" "500" "42". Defaults to false. @@ -51,29 +45,35 @@ public interface IWordDelimiterTokenFilter : ITokenFilter bool? PreserveOriginal { get; set; } /// - /// If true causes "j2se" to be three tokens; "j" "2" "se". Defaults to true. + /// A list of protected words from being delimiter. /// - [JsonProperty("split_on_numerics")] - bool? SplitOnNumerics { get; set; } + [JsonProperty("protected_words")] + IEnumerable ProtectedWords { get; set; } /// - /// If true causes trailing "'s" to be removed for each subword: "O’Neil’s" ⇒ "O", "Neil". Defaults to true. + /// protected_words_path which resolved to a file configured with protected words (one on each line). + /// Automatically resolves to config/ based location if exists. /// - [JsonProperty("stem_english_possessive")] - bool? StemEnglishPossessive { get; set; } + [JsonProperty("protected_words_path ")] + string ProtectedWordsPath { get; set; } /// - /// A list of protected words from being delimiter. + /// If true causes "PowerShot" to be two tokens; ("Power-Shot" remains two parts regards). Defaults to true. /// - [JsonProperty("protected_words")] - IEnumerable ProtectedWords { get; set; } + [JsonProperty("split_on_case_change")] + bool? SplitOnCaseChange { get; set; } /// - ///protected_words_path which resolved to a file configured with protected words (one on each line). - /// Automatically resolves to config/ based location if exists. + /// If true causes "j2se" to be three tokens; "j" "2" "se". Defaults to true. /// - [JsonProperty("protected_words_path ")] - string ProtectedWordsPath { get; set; } + [JsonProperty("split_on_numerics")] + bool? SplitOnNumerics { get; set; } + + /// + /// If true causes trailing "'s" to be removed for each subword: "O’Neil’s" ⇒ "O", "Neil". Defaults to true. + /// + [JsonProperty("stem_english_possessive")] + bool? StemEnglishPossessive { get; set; } /// /// A custom type mapping table @@ -86,119 +86,119 @@ public interface IWordDelimiterTokenFilter : ITokenFilter /// [JsonProperty("type_table_path")] string TypeTablePath { get; set; } - } - /// + /// public class WordDelimiterTokenFilter : TokenFilterBase, IWordDelimiterTokenFilter { public WordDelimiterTokenFilter() : base("word_delimiter") { } - /// - public bool? GenerateWordParts { get; set; } + /// + public bool? CatenateAll { get; set; } - /// - public bool? GenerateNumberParts { get; set; } + /// + public bool? CatenateNumbers { get; set; } - /// + /// public bool? CatenateWords { get; set; } - /// - public bool? CatenateNumbers { get; set; } - - /// - public bool? CatenateAll { get; set; } + /// + public bool? GenerateNumberParts { get; set; } - /// - public bool? SplitOnCaseChange { get; set; } + /// + public bool? GenerateWordParts { get; set; } - /// + /// public bool? PreserveOriginal { get; set; } - /// - public bool? SplitOnNumerics { get; set; } - - /// - public bool? StemEnglishPossessive { get; set; } - - /// + /// public IEnumerable ProtectedWords { get; set; } - /// + /// public string ProtectedWordsPath { get; set; } - /// + /// + public bool? SplitOnCaseChange { get; set; } + + /// + public bool? SplitOnNumerics { get; set; } + + /// + public bool? StemEnglishPossessive { get; set; } + + /// public IEnumerable TypeTable { get; set; } - /// + /// public string TypeTablePath { get; set; } } - /// - public class WordDelimiterTokenFilterDescriptor + /// + public class WordDelimiterTokenFilterDescriptor : TokenFilterDescriptorBase, IWordDelimiterTokenFilter { protected override string Type => "word_delimiter"; + bool? IWordDelimiterTokenFilter.CatenateAll { get; set; } + bool? IWordDelimiterTokenFilter.CatenateNumbers { get; set; } + bool? IWordDelimiterTokenFilter.CatenateWords { get; set; } + bool? IWordDelimiterTokenFilter.GenerateNumberParts { get; set; } + bool? IWordDelimiterTokenFilter.GenerateWordParts { get; set; } + bool? IWordDelimiterTokenFilter.PreserveOriginal { get; set; } IEnumerable IWordDelimiterTokenFilter.ProtectedWords { get; set; } string IWordDelimiterTokenFilter.ProtectedWordsPath { get; set; } - IEnumerable IWordDelimiterTokenFilter.TypeTable { get; set; } - string IWordDelimiterTokenFilter.TypeTablePath { get; set; } - bool? IWordDelimiterTokenFilter.GenerateWordParts { get; set; } - bool? IWordDelimiterTokenFilter.GenerateNumberParts { get; set; } - bool? IWordDelimiterTokenFilter.CatenateWords { get; set; } - bool? IWordDelimiterTokenFilter.CatenateNumbers { get; set; } - bool? IWordDelimiterTokenFilter.CatenateAll { get; set; } bool? IWordDelimiterTokenFilter.SplitOnCaseChange { get; set; } - bool? IWordDelimiterTokenFilter.PreserveOriginal { get; set; } bool? IWordDelimiterTokenFilter.SplitOnNumerics { get; set; } bool? IWordDelimiterTokenFilter.StemEnglishPossessive { get; set; } + IEnumerable IWordDelimiterTokenFilter.TypeTable { get; set; } + string IWordDelimiterTokenFilter.TypeTablePath { get; set; } - /// - public WordDelimiterTokenFilterDescriptor GenerateWordParts(bool? generateWordParts = true) => Assign(a => a.GenerateWordParts = generateWordParts); + /// + public WordDelimiterTokenFilterDescriptor GenerateWordParts(bool? generateWordParts = true) => + Assign(a => a.GenerateWordParts = generateWordParts); - /// - public WordDelimiterTokenFilterDescriptor GenerateNumberParts(bool? generateNumberParts = true) => Assign(a => a.GenerateNumberParts = generateNumberParts); + /// + public WordDelimiterTokenFilterDescriptor GenerateNumberParts(bool? generateNumberParts = true) => + Assign(a => a.GenerateNumberParts = generateNumberParts); - /// + /// public WordDelimiterTokenFilterDescriptor CatenateWords(bool? catenateWords = true) => Assign(a => a.CatenateWords = catenateWords); - /// + /// public WordDelimiterTokenFilterDescriptor CatenateNumbers(bool? catenateNumbers = true) => Assign(a => a.CatenateNumbers = catenateNumbers); - /// + /// public WordDelimiterTokenFilterDescriptor CatenateAll(bool? catenateAll = true) => Assign(a => a.CatenateAll = catenateAll); - /// + /// public WordDelimiterTokenFilterDescriptor SplitOnCaseChange(bool? split = true) => Assign(a => a.SplitOnCaseChange = split); - /// + /// public WordDelimiterTokenFilterDescriptor SplitOnNumerics(bool? split = true) => Assign(a => a.SplitOnNumerics = split); - /// + /// public WordDelimiterTokenFilterDescriptor PreserveOriginal(bool? preserve = true) => Assign(a => a.PreserveOriginal = preserve); - /// + /// public WordDelimiterTokenFilterDescriptor StemEnglishPossessive(bool? stem = true) => Assign(a => a.StemEnglishPossessive = stem); - /// - public WordDelimiterTokenFilterDescriptor ProtectedWords(IEnumerable protectedWords) => Assign(a => a.ProtectedWords = protectedWords); + /// + public WordDelimiterTokenFilterDescriptor ProtectedWords(IEnumerable protectedWords) => + Assign(a => a.ProtectedWords = protectedWords); - /// + /// public WordDelimiterTokenFilterDescriptor ProtectedWords(params string[] protectedWords) => Assign(a => a.ProtectedWords = protectedWords); - /// + /// public WordDelimiterTokenFilterDescriptor ProtectedWordsPath(string path) => Assign(a => a.ProtectedWordsPath = path); - /// + /// public WordDelimiterTokenFilterDescriptor TypeTable(IEnumerable typeTable) => Assign(a => a.TypeTable = typeTable); - /// + /// public WordDelimiterTokenFilterDescriptor TypeTable(params string[] typeTable) => Assign(a => a.TypeTable = typeTable); - /// + /// public WordDelimiterTokenFilterDescriptor TypeTablePath(string path) => Assign(a => a.TypeTablePath = path); - } - } diff --git a/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs b/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs index 12e84aa707c..15dba2f4ae9 100644 --- a/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs +++ b/src/Nest/Analysis/TokenFilters/WordDelimiterGraph/WordDelimiterGraphTokenFilter.cs @@ -10,16 +10,16 @@ namespace Nest public interface IWordDelimiterGraphTokenFilter : ITokenFilter { /// - /// If true causes parts of words to be generated: "PowerShot" ⇒ "Power" "Shot". Defaults to true. + /// If true causes all subword parts to be catenated: "wi-fi-4000" ⇒ "wifi4000". Defaults to false. /// - [JsonProperty("generate_word_parts")] - bool? GenerateWordParts { get; set; } + [JsonProperty("catenate_all")] + bool? CatenateAll { get; set; } /// - /// If true causes number subwords to be generated: "500-42" ⇒ "500" "42". Defaults to true. + /// If true causes maximum runs of number parts to be catenated: "500-42" ⇒ "50042". Defaults to false. /// - [JsonProperty("generate_number_parts")] - bool? GenerateNumberParts { get; set; } + [JsonProperty("catenate_numbers")] + bool? CatenateNumbers { get; set; } /// /// If true causes maximum runs of word parts to be catenated: "wi-fi" ⇒ "wifi". Defaults to false. @@ -28,22 +28,16 @@ public interface IWordDelimiterGraphTokenFilter : ITokenFilter bool? CatenateWords { get; set; } /// - /// If true causes maximum runs of number parts to be catenated: "500-42" ⇒ "50042". Defaults to false. - /// - [JsonProperty("catenate_numbers")] - bool? CatenateNumbers { get; set; } - - /// - /// If true causes all subword parts to be catenated: "wi-fi-4000" ⇒ "wifi4000". Defaults to false. + /// If true causes number subwords to be generated: "500-42" ⇒ "500" "42". Defaults to true. /// - [JsonProperty("catenate_all")] - bool? CatenateAll { get; set; } + [JsonProperty("generate_number_parts")] + bool? GenerateNumberParts { get; set; } /// - /// If true causes "PowerShot" to be two tokens; ("Power-Shot" remains two parts regards). Defaults to true. + /// If true causes parts of words to be generated: "PowerShot" ⇒ "Power" "Shot". Defaults to true. /// - [JsonProperty("split_on_case_change")] - bool? SplitOnCaseChange { get; set; } + [JsonProperty("generate_word_parts")] + bool? GenerateWordParts { get; set; } /// /// If true includes original words in subwords: "500-42" ⇒ "500-42" "500" "42". Defaults to false. @@ -52,29 +46,35 @@ public interface IWordDelimiterGraphTokenFilter : ITokenFilter bool? PreserveOriginal { get; set; } /// - /// If true causes "j2se" to be three tokens; "j" "2" "se". Defaults to true. + /// A list of protected words from being delimiter. /// - [JsonProperty("split_on_numerics")] - bool? SplitOnNumerics { get; set; } + [JsonProperty("protected_words")] + IEnumerable ProtectedWords { get; set; } /// - /// If true causes trailing "'s" to be removed for each subword: "O’Neil’s" ⇒ "O", "Neil". Defaults to true. + /// protected_words_path which resolved to a file configured with protected words (one on each line). + /// Automatically resolves to config/ based location if exists. /// - [JsonProperty("stem_english_possessive")] - bool? StemEnglishPossessive { get; set; } + [JsonProperty("protected_words_path ")] + string ProtectedWordsPath { get; set; } /// - /// A list of protected words from being delimiter. + /// If true causes "PowerShot" to be two tokens; ("Power-Shot" remains two parts regards). Defaults to true. /// - [JsonProperty("protected_words")] - IEnumerable ProtectedWords { get; set; } + [JsonProperty("split_on_case_change")] + bool? SplitOnCaseChange { get; set; } /// - ///protected_words_path which resolved to a file configured with protected words (one on each line). - /// Automatically resolves to config/ based location if exists. + /// If true causes "j2se" to be three tokens; "j" "2" "se". Defaults to true. /// - [JsonProperty("protected_words_path ")] - string ProtectedWordsPath { get; set; } + [JsonProperty("split_on_numerics")] + bool? SplitOnNumerics { get; set; } + + /// + /// If true causes trailing "'s" to be removed for each subword: "O’Neil’s" ⇒ "O", "Neil". Defaults to true. + /// + [JsonProperty("stem_english_possessive")] + bool? StemEnglishPossessive { get; set; } /// /// A custom type mapping table @@ -87,119 +87,121 @@ public interface IWordDelimiterGraphTokenFilter : ITokenFilter /// [JsonProperty("type_table_path")] string TypeTablePath { get; set; } - } - /// + /// public class WordDelimiterGraphTokenFilter : TokenFilterBase, IWordDelimiterGraphTokenFilter { public WordDelimiterGraphTokenFilter() : base("word_delimiter_graph") { } - /// - public bool? GenerateWordParts { get; set; } + /// + public bool? CatenateAll { get; set; } - /// - public bool? GenerateNumberParts { get; set; } + /// + public bool? CatenateNumbers { get; set; } - /// + /// public bool? CatenateWords { get; set; } - /// - public bool? CatenateNumbers { get; set; } - - /// - public bool? CatenateAll { get; set; } + /// + public bool? GenerateNumberParts { get; set; } - /// - public bool? SplitOnCaseChange { get; set; } + /// + public bool? GenerateWordParts { get; set; } - /// + /// public bool? PreserveOriginal { get; set; } - /// - public bool? SplitOnNumerics { get; set; } - - /// - public bool? StemEnglishPossessive { get; set; } - - /// + /// public IEnumerable ProtectedWords { get; set; } - /// + /// public string ProtectedWordsPath { get; set; } - /// + /// + public bool? SplitOnCaseChange { get; set; } + + /// + public bool? SplitOnNumerics { get; set; } + + /// + public bool? StemEnglishPossessive { get; set; } + + /// public IEnumerable TypeTable { get; set; } - /// + /// public string TypeTablePath { get; set; } } - /// + /// public class WordDelimiterGraphTokenFilterDescriptor : TokenFilterDescriptorBase, IWordDelimiterGraphTokenFilter { protected override string Type => "word_delimiter_graph"; + bool? IWordDelimiterGraphTokenFilter.CatenateAll { get; set; } + bool? IWordDelimiterGraphTokenFilter.CatenateNumbers { get; set; } + bool? IWordDelimiterGraphTokenFilter.CatenateWords { get; set; } + bool? IWordDelimiterGraphTokenFilter.GenerateNumberParts { get; set; } + bool? IWordDelimiterGraphTokenFilter.GenerateWordParts { get; set; } + bool? IWordDelimiterGraphTokenFilter.PreserveOriginal { get; set; } IEnumerable IWordDelimiterGraphTokenFilter.ProtectedWords { get; set; } string IWordDelimiterGraphTokenFilter.ProtectedWordsPath { get; set; } - IEnumerable IWordDelimiterGraphTokenFilter.TypeTable { get; set; } - string IWordDelimiterGraphTokenFilter.TypeTablePath { get; set; } - bool? IWordDelimiterGraphTokenFilter.GenerateWordParts { get; set; } - bool? IWordDelimiterGraphTokenFilter.GenerateNumberParts { get; set; } - bool? IWordDelimiterGraphTokenFilter.CatenateWords { get; set; } - bool? IWordDelimiterGraphTokenFilter.CatenateNumbers { get; set; } - bool? IWordDelimiterGraphTokenFilter.CatenateAll { get; set; } bool? IWordDelimiterGraphTokenFilter.SplitOnCaseChange { get; set; } - bool? IWordDelimiterGraphTokenFilter.PreserveOriginal { get; set; } bool? IWordDelimiterGraphTokenFilter.SplitOnNumerics { get; set; } bool? IWordDelimiterGraphTokenFilter.StemEnglishPossessive { get; set; } + IEnumerable IWordDelimiterGraphTokenFilter.TypeTable { get; set; } + string IWordDelimiterGraphTokenFilter.TypeTablePath { get; set; } - /// - public WordDelimiterGraphTokenFilterDescriptor GenerateWordParts(bool? generateWordParts = true) => Assign(a => a.GenerateWordParts = generateWordParts); + /// + public WordDelimiterGraphTokenFilterDescriptor GenerateWordParts(bool? generateWordParts = true) => + Assign(a => a.GenerateWordParts = generateWordParts); - /// - public WordDelimiterGraphTokenFilterDescriptor GenerateNumberParts(bool? generateNumberParts = true) => Assign(a => a.GenerateNumberParts = generateNumberParts); + /// + public WordDelimiterGraphTokenFilterDescriptor GenerateNumberParts(bool? generateNumberParts = true) => + Assign(a => a.GenerateNumberParts = generateNumberParts); - /// + /// public WordDelimiterGraphTokenFilterDescriptor CatenateWords(bool? catenateWords = true) => Assign(a => a.CatenateWords = catenateWords); - /// - public WordDelimiterGraphTokenFilterDescriptor CatenateNumbers(bool? catenateNumbers = true) => Assign(a => a.CatenateNumbers = catenateNumbers); + /// + public WordDelimiterGraphTokenFilterDescriptor CatenateNumbers(bool? catenateNumbers = true) => + Assign(a => a.CatenateNumbers = catenateNumbers); - /// + /// public WordDelimiterGraphTokenFilterDescriptor CatenateAll(bool? catenateAll = true) => Assign(a => a.CatenateAll = catenateAll); - /// + /// public WordDelimiterGraphTokenFilterDescriptor SplitOnCaseChange(bool? split = true) => Assign(a => a.SplitOnCaseChange = split); - /// + /// public WordDelimiterGraphTokenFilterDescriptor SplitOnNumerics(bool? split = true) => Assign(a => a.SplitOnNumerics = split); - /// + /// public WordDelimiterGraphTokenFilterDescriptor PreserveOriginal(bool? preserve = true) => Assign(a => a.PreserveOriginal = preserve); - /// + /// public WordDelimiterGraphTokenFilterDescriptor StemEnglishPossessive(bool? stem = true) => Assign(a => a.StemEnglishPossessive = stem); - /// - public WordDelimiterGraphTokenFilterDescriptor ProtectedWords(IEnumerable protectedWords) => Assign(a => a.ProtectedWords = protectedWords); + /// + public WordDelimiterGraphTokenFilterDescriptor ProtectedWords(IEnumerable protectedWords) => + Assign(a => a.ProtectedWords = protectedWords); - /// - public WordDelimiterGraphTokenFilterDescriptor ProtectedWords(params string[] protectedWords) => Assign(a => a.ProtectedWords = protectedWords); + /// + public WordDelimiterGraphTokenFilterDescriptor ProtectedWords(params string[] protectedWords) => + Assign(a => a.ProtectedWords = protectedWords); - /// + /// public WordDelimiterGraphTokenFilterDescriptor ProtectedWordsPath(string path) => Assign(a => a.ProtectedWordsPath = path); - /// + /// public WordDelimiterGraphTokenFilterDescriptor TypeTable(IEnumerable typeTable) => Assign(a => a.TypeTable = typeTable); - /// + /// public WordDelimiterGraphTokenFilterDescriptor TypeTable(params string[] typeTable) => Assign(a => a.TypeTable = typeTable); - /// + /// public WordDelimiterGraphTokenFilterDescriptor TypeTablePath(string path) => Assign(a => a.TypeTablePath = path); - } - } diff --git a/src/Nest/Analysis/Tokenizers/CharGroupTokenizer.cs b/src/Nest/Analysis/Tokenizers/CharGroupTokenizer.cs index 3996824fc8a..1f7d2611155 100644 --- a/src/Nest/Analysis/Tokenizers/CharGroupTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/CharGroupTokenizer.cs @@ -5,7 +5,7 @@ namespace Nest { /// /// A tokenizer that breaks text into terms whenever it encounters a character which is in a defined set. It is mostly useful - /// for cases where a simple custom tokenization is desired, and the overhead of use of is not acceptable. + /// for cases where a simple custom tokenization is desired, and the overhead of use of is not acceptable. /// public interface ICharGroupTokenizer : ITokenizer { @@ -18,18 +18,18 @@ public interface ICharGroupTokenizer : ITokenizer IEnumerable TokenizeOnCharacters { get; set; } } - /// + /// public class CharGroupTokenizer : TokenizerBase, ICharGroupTokenizer - { - internal const string TokenizerType = "char_group"; + { + internal const string TokenizerType = "char_group"; - public CharGroupTokenizer() => this.Type = TokenizerType; + public CharGroupTokenizer() => Type = TokenizerType; - /// + /// public IEnumerable TokenizeOnCharacters { get; set; } - } + } - /// + /// public class CharGroupTokenizerDescriptor : TokenizerDescriptorBase, ICharGroupTokenizer { @@ -37,12 +37,12 @@ public class CharGroupTokenizerDescriptor IEnumerable ICharGroupTokenizer.TokenizeOnCharacters { get; set; } - /// + /// public CharGroupTokenizerDescriptor TokenizeOnCharacters(params string[] characters) => - Assign(a => a.TokenizeOnCharacters = characters); + Assign(a => a.TokenizeOnCharacters = characters); - /// + /// public CharGroupTokenizerDescriptor TokenizeOnCharacters(IEnumerable characters) => - Assign(a => a.TokenizeOnCharacters = characters); + Assign(a => a.TokenizeOnCharacters = characters); } } diff --git a/src/Nest/Analysis/Tokenizers/KeywordTokenizer.cs b/src/Nest/Analysis/Tokenizers/KeywordTokenizer.cs index a348195238c..c7605018e52 100644 --- a/src/Nest/Analysis/Tokenizers/KeywordTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/KeywordTokenizer.cs @@ -13,23 +13,25 @@ public interface IKeywordTokenizer : ITokenizer [JsonProperty("buffer_size")] int? BufferSize { get; set; } } - /// + + /// public class KeywordTokenizer : TokenizerBase, IKeywordTokenizer - { - public KeywordTokenizer() { Type = "keyword"; } + { + public KeywordTokenizer() => Type = "keyword"; - /// + /// public int? BufferSize { get; set; } - } - /// - public class KeywordTokenizerDescriptor + } + + /// + public class KeywordTokenizerDescriptor : TokenizerDescriptorBase, IKeywordTokenizer { protected override string Type => "keyword"; int? IKeywordTokenizer.BufferSize { get; set; } - /// + /// public KeywordTokenizerDescriptor BufferSize(int? size) => Assign(a => a.BufferSize = size); } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/LetterTokenizer.cs b/src/Nest/Analysis/Tokenizers/LetterTokenizer.cs index 9fc074fbffa..b838134f230 100644 --- a/src/Nest/Analysis/Tokenizers/LetterTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/LetterTokenizer.cs @@ -1,19 +1,24 @@ namespace Nest { /// - /// A tokenizer of type letter that divides text at non-letters. That’s to say, it defines tokens as maximal strings of adjacent letters. - /// Note, this does a decent job for most European languages, but does a terrible job for some Asian languages, where words are not separated by spaces. + /// A tokenizer of type letter that divides text at non-letters. That’s to say, it defines tokens as maximal strings of adjacent letters. + /// + /// Note, this does a decent job for most European languages, but does a terrible job for some Asian languages, where words are not + /// separated by spaces. + /// /// public interface ILetterTokenizer : ITokenizer { } - /// + + /// public class LetterTokenizer : TokenizerBase, ILetterTokenizer - { - public LetterTokenizer() { Type = "letter"; } - } - /// - public class LetterTokenizerDescriptor + { + public LetterTokenizer() => Type = "letter"; + } + + /// + public class LetterTokenizerDescriptor : TokenizerDescriptorBase, ILetterTokenizer { protected override string Type => "letter"; } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/LowercaseTokenizer.cs b/src/Nest/Analysis/Tokenizers/LowercaseTokenizer.cs index 253b39421f7..fe7c1ceda97 100644 --- a/src/Nest/Analysis/Tokenizers/LowercaseTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/LowercaseTokenizer.cs @@ -1,21 +1,23 @@ namespace Nest { /// - /// A tokenizer of type lowercase that performs the function of Letter Tokenizer and Lower Case Token Filter together. + /// A tokenizer of type lowercase that performs the function of Letter Tokenizer and Lower Case Token Filter together. /// It divides text at non-letters and converts them to lower case. /// While it is functionally equivalent to the combination of Letter Tokenizer and Lower Case Token Filter, /// there is a performance advantage to doing the two tasks at once, hence this (redundant) implementation. /// public interface ILowercaseTokenizer : ITokenizer { } - /// + + /// public class LowercaseTokenizer : TokenizerBase, ILowercaseTokenizer - { - public LowercaseTokenizer() { Type = "lowercase"; } + { + public LowercaseTokenizer() => Type = "lowercase"; } - /// - public class LowercaseTokenizerDescriptor + + /// + public class LowercaseTokenizerDescriptor : TokenizerDescriptorBase, ILowercaseTokenizer { protected override string Type => "lowercase"; } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/NGram/EdgeNGramTokenizer.cs b/src/Nest/Analysis/Tokenizers/NGram/EdgeNGramTokenizer.cs index c046bb53b2a..524eefc87d7 100644 --- a/src/Nest/Analysis/Tokenizers/NGram/EdgeNGramTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/NGram/EdgeNGramTokenizer.cs @@ -8,18 +8,18 @@ namespace Nest /// public interface IEdgeNGramTokenizer : ITokenizer { - /// - /// Minimum size in codepoints of a single n-gram - /// - [JsonProperty("min_gram")] - int? MinGram { get; set; } - /// /// Maximum size in codepoints of a single n-gram /// [JsonProperty("max_gram")] int? MaxGram { get; set; } + /// + /// Minimum size in codepoints of a single n-gram + /// + [JsonProperty("min_gram")] + int? MinGram { get; set; } + /// /// Characters classes to keep in the tokens, Elasticsearch /// will split on characters that don’t belong to any of these classes. @@ -27,43 +27,44 @@ public interface IEdgeNGramTokenizer : ITokenizer [JsonProperty("token_chars")] IEnumerable TokenChars { get; set; } } - /// + + /// public class EdgeNGramTokenizer : TokenizerBase, IEdgeNGramTokenizer { - public EdgeNGramTokenizer() { Type = "edge_ngram"; } + public EdgeNGramTokenizer() => Type = "edge_ngram"; - /// - public int? MinGram { get; set; } - - /// + /// public int? MaxGram { get; set; } - /// + /// + public int? MinGram { get; set; } + + /// public IEnumerable TokenChars { get; set; } } - /// - public class EdgeNGramTokenizerDescriptor + + /// + public class EdgeNGramTokenizerDescriptor : TokenizerDescriptorBase, IEdgeNGramTokenizer { protected override string Type => "edge_ngram"; + int? IEdgeNGramTokenizer.MaxGram { get; set; } int? IEdgeNGramTokenizer.MinGram { get; set; } - int? IEdgeNGramTokenizer.MaxGram { get; set; } IEnumerable IEdgeNGramTokenizer.TokenChars { get; set; } - /// + /// public EdgeNGramTokenizerDescriptor MinGram(int? minGram) => Assign(a => a.MinGram = minGram); - /// + /// public EdgeNGramTokenizerDescriptor MaxGram(int? maxGram) => Assign(a => a.MaxGram = maxGram); - /// - public EdgeNGramTokenizerDescriptor TokenChars(IEnumerable tokenChars) => + /// + public EdgeNGramTokenizerDescriptor TokenChars(IEnumerable tokenChars) => Assign(a => a.TokenChars = tokenChars); - /// - public EdgeNGramTokenizerDescriptor TokenChars(params TokenChar[] tokenChars) => + /// + public EdgeNGramTokenizerDescriptor TokenChars(params TokenChar[] tokenChars) => Assign(a => a.TokenChars = tokenChars); } - -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/NGram/NGramTokenizer.cs b/src/Nest/Analysis/Tokenizers/NGram/NGramTokenizer.cs index 0d34f26d791..5d287edcd50 100644 --- a/src/Nest/Analysis/Tokenizers/NGram/NGramTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/NGram/NGramTokenizer.cs @@ -8,62 +8,62 @@ namespace Nest /// public interface INGramTokenizer : ITokenizer { - /// - /// Minimum size in codepoints of a single n-gram, defaults to 1. - /// - [JsonProperty("min_gram")] - int? MinGram { get; set; } - /// /// Maximum size in codepoints of a single n-gram, defaults to 2. /// [JsonProperty("max_gram")] int? MaxGram { get; set; } + /// + /// Minimum size in codepoints of a single n-gram, defaults to 1. + /// + [JsonProperty("min_gram")] + int? MinGram { get; set; } + /// /// Characters classes to keep in the tokens, Elasticsearch will - /// split on characters that don’t belong to any of these classes. + /// split on characters that don’t belong to any of these classes. /// [JsonProperty("token_chars")] IEnumerable TokenChars { get; set; } } - /// + /// public class NGramTokenizer : TokenizerBase, INGramTokenizer { - public NGramTokenizer() { Type = "ngram"; } + public NGramTokenizer() => Type = "ngram"; - /// - public int? MinGram { get; set; } - - /// + /// public int? MaxGram { get; set; } - /// + /// + public int? MinGram { get; set; } + + /// public IEnumerable TokenChars { get; set; } } - /// - public class NGramTokenizerDescriptor + + /// + public class NGramTokenizerDescriptor : TokenizerDescriptorBase, INGramTokenizer { protected override string Type => "ngram"; + int? INGramTokenizer.MaxGram { get; set; } int? INGramTokenizer.MinGram { get; set; } - int? INGramTokenizer.MaxGram { get; set; } IEnumerable INGramTokenizer.TokenChars { get; set; } - /// + /// public NGramTokenizerDescriptor MinGram(int? minGram) => Assign(a => a.MinGram = minGram); - /// + /// public NGramTokenizerDescriptor MaxGram(int? minGram) => Assign(a => a.MaxGram = minGram); - /// - public NGramTokenizerDescriptor TokenChars(IEnumerable tokenChars) => + /// + public NGramTokenizerDescriptor TokenChars(IEnumerable tokenChars) => Assign(a => a.TokenChars = tokenChars); - /// + /// public NGramTokenizerDescriptor TokenChars(params TokenChar[] tokenChars) => Assign(a => a.TokenChars = tokenChars); - } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/NGram/TokenChar.cs b/src/Nest/Analysis/Tokenizers/NGram/TokenChar.cs index 81b1889b646..504b564f25c 100644 --- a/src/Nest/Analysis/Tokenizers/NGram/TokenChar.cs +++ b/src/Nest/Analysis/Tokenizers/NGram/TokenChar.cs @@ -9,13 +9,17 @@ public enum TokenChar { [EnumMember(Value = "letter")] Letter, + [EnumMember(Value = "digit")] Digit, + [EnumMember(Value = "whitespace")] Whitespace, + [EnumMember(Value = "punctuation")] Punctuation, + [EnumMember(Value = "symbol")] Symbol, } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/NoriTokenizer.cs b/src/Nest/Analysis/Tokenizers/NoriTokenizer.cs index 435d24f7117..761f4e3d8c4 100644 --- a/src/Nest/Analysis/Tokenizers/NoriTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/NoriTokenizer.cs @@ -9,13 +9,15 @@ namespace Nest public enum NoriDecompoundMode { /// Decomposes compounds and discards the original form (default). - [EnumMember(Value="discard")] + [EnumMember(Value = "discard")] Discard, + /// No decomposition for compounds - [EnumMember(Value="none")] + [EnumMember(Value = "none")] None, + /// Decomposes compounds and keeps the original form - [EnumMember(Value="mixed")] + [EnumMember(Value = "mixed")] Mixed } @@ -36,28 +38,31 @@ public interface INoriTokenizer : ITokenizer string UserDictionary { get; set; } } - /// + /// public class NoriTokenizer : TokenizerBase, INoriTokenizer - { - public NoriTokenizer() => this.Type = "nori_tokenizer"; - /// - public NoriDecompoundMode? DecompoundMode { get; set; } - /// - public string UserDictionary { get; set; } - } - /// + { + public NoriTokenizer() => Type = "nori_tokenizer"; + + /// + public NoriDecompoundMode? DecompoundMode { get; set; } + + /// + public string UserDictionary { get; set; } + } + + /// public class NoriTokenizerDescriptor : TokenizerDescriptorBase, INoriTokenizer { protected override string Type => "nori_tokenizer"; - NoriDecompoundMode? INoriTokenizer.DecompoundMode { get; set; } - string INoriTokenizer.UserDictionary { get; set; } + NoriDecompoundMode? INoriTokenizer.DecompoundMode { get; set; } + string INoriTokenizer.UserDictionary { get; set; } - /// + /// public NoriTokenizerDescriptor DecompoundMode(NoriDecompoundMode? mode) => Assign(a => a.DecompoundMode = mode); - /// + /// public NoriTokenizerDescriptor UserDictionary(string path) => Assign(a => a.UserDictionary = path); } } diff --git a/src/Nest/Analysis/Tokenizers/PathHierarchyTokenizer.cs b/src/Nest/Analysis/Tokenizers/PathHierarchyTokenizer.cs index 52b84e46fe5..319c3c73901 100644 --- a/src/Nest/Analysis/Tokenizers/PathHierarchyTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/PathHierarchyTokenizer.cs @@ -3,16 +3,22 @@ namespace Nest { /// - /// The path_hierarchy tokenizer takes something like this: - ////something/something/else - ///And produces tokens: - /// - ////something - ////something/something - ////something/something/else + /// The path_hierarchy tokenizer takes something like this: + /// /something/something/else + /// And produces tokens: + /// + /// /something + /// /something/something + /// /something/something/else /// public interface IPathHierarchyTokenizer : ITokenizer { + /// + /// The buffer size to use, defaults to 1024. + /// + [JsonProperty("buffer_size")] + int? BufferSize { get; set; } + /// /// The character delimiter to use, defaults to /. /// @@ -25,12 +31,6 @@ public interface IPathHierarchyTokenizer : ITokenizer [JsonProperty("replacement")] char? Replacement { get; set; } - /// - /// The buffer size to use, defaults to 1024. - /// - [JsonProperty("buffer_size")] - int? BufferSize { get; set; } - /// /// Generates tokens in reverse order, defaults to false. /// @@ -44,53 +44,53 @@ public interface IPathHierarchyTokenizer : ITokenizer int? Skip { get; set; } } - /// + /// public class PathHierarchyTokenizer : TokenizerBase, IPathHierarchyTokenizer { - public PathHierarchyTokenizer() { Type = "path_hierarchy"; } + public PathHierarchyTokenizer() => Type = "path_hierarchy"; + + /// + public int? BufferSize { get; set; } - /// + /// public char? Delimiter { get; set; } - /// + /// public char? Replacement { get; set; } - /// - public int? BufferSize { get; set; } - - /// + /// public bool? Reverse { get; set; } - /// + /// public int? Skip { get; set; } } - /// + + /// public class PathHierarchyTokenizerDescriptor : TokenizerDescriptorBase, IPathHierarchyTokenizer { protected override string Type => "path_hierarchy"; int? IPathHierarchyTokenizer.BufferSize { get; set; } - int? IPathHierarchyTokenizer.Skip { get; set; } - bool? IPathHierarchyTokenizer.Reverse { get; set; } char? IPathHierarchyTokenizer.Delimiter { get; set; } char? IPathHierarchyTokenizer.Replacement { get; set; } + bool? IPathHierarchyTokenizer.Reverse { get; set; } + int? IPathHierarchyTokenizer.Skip { get; set; } - /// + /// public PathHierarchyTokenizerDescriptor BufferSize(int? bufferSize) => Assign(a => a.BufferSize = bufferSize); - /// + /// public PathHierarchyTokenizerDescriptor Skip(int? skip) => Assign(a => a.Skip = skip); - /// + /// public PathHierarchyTokenizerDescriptor Reverse(bool? reverse = true) => Assign(a => a.Reverse = reverse); - /// + /// public PathHierarchyTokenizerDescriptor Delimiter(char? delimiter) => Assign(a => a.Delimiter = delimiter); - /// + /// public PathHierarchyTokenizerDescriptor Replacement(char? replacement) => Assign(a => a.Replacement = replacement); - } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/PatternTokenizer.cs b/src/Nest/Analysis/Tokenizers/PatternTokenizer.cs index 23df200c6c5..5ab367aad6b 100644 --- a/src/Nest/Analysis/Tokenizers/PatternTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/PatternTokenizer.cs @@ -7,12 +7,6 @@ namespace Nest /// public interface IPatternTokenizer : ITokenizer { - /// - /// The regular expression pattern, defaults to \W+. - /// - [JsonProperty("pattern")] - string Pattern { get; set; } - /// /// The regular expression flags. /// @@ -25,40 +19,45 @@ public interface IPatternTokenizer : ITokenizer [JsonProperty("group")] int? Group { get; set; } + /// + /// The regular expression pattern, defaults to \W+. + /// + [JsonProperty("pattern")] + string Pattern { get; set; } } - /// + /// public class PatternTokenizer : TokenizerBase, IPatternTokenizer - { - public PatternTokenizer() { Type = "pattern"; } - - /// - public string Pattern { get; set; } + { + public PatternTokenizer() => Type = "pattern"; - /// + /// public string Flags { get; set; } - /// + /// public int? Group { get; set; } - } - /// + + /// + public string Pattern { get; set; } + } + + /// public class PatternTokenizerDescriptor : TokenizerDescriptorBase, IPatternTokenizer { protected override string Type => "pattern"; + string IPatternTokenizer.Flags { get; set; } int? IPatternTokenizer.Group { get; set; } string IPatternTokenizer.Pattern { get; set; } - string IPatternTokenizer.Flags { get; set; } - /// + /// public PatternTokenizerDescriptor Group(int? group) => Assign(a => a.Group = group); - /// + /// public PatternTokenizerDescriptor Pattern(string pattern) => Assign(a => a.Pattern = pattern); - /// + /// public PatternTokenizerDescriptor Flags(string flags) => Assign(a => a.Flags = flags); - } } diff --git a/src/Nest/Analysis/Tokenizers/StandardTokenizer.cs b/src/Nest/Analysis/Tokenizers/StandardTokenizer.cs index 8771022ea72..ace2e48064e 100644 --- a/src/Nest/Analysis/Tokenizers/StandardTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/StandardTokenizer.cs @@ -3,7 +3,7 @@ namespace Nest { /// - /// A tokenizer of type standard providing grammar based tokenizer that is a good tokenizer for most European language documents. + /// A tokenizer of type standard providing grammar based tokenizer that is a good tokenizer for most European language documents. /// The tokenizer implements the Unicode Text Segmentation algorithm, as specified in Unicode Standard Annex #29. /// public interface IStandardTokenizer : ITokenizer @@ -12,24 +12,26 @@ public interface IStandardTokenizer : ITokenizer /// The maximum token length. If a token is seen that exceeds this length then it is discarded. Defaults to 255. /// [JsonProperty("max_token_length")] - int? MaxTokenLength { get; set; } + int? MaxTokenLength { get; set; } } - /// + + /// public class StandardTokenizer : TokenizerBase, IStandardTokenizer - { - public StandardTokenizer() { Type = "standard"; } + { + public StandardTokenizer() => Type = "standard"; + + /// + public int? MaxTokenLength { get; set; } + } - /// - public int? MaxTokenLength { get; set; } - } - public class StandardTokenizerDescriptor + public class StandardTokenizerDescriptor : TokenizerDescriptorBase, IStandardTokenizer { protected override string Type => "standard"; int? IStandardTokenizer.MaxTokenLength { get; set; } - /// + /// public StandardTokenizerDescriptor MaxTokenLength(int? maxLength) => Assign(a => a.MaxTokenLength = maxLength); } -} \ No newline at end of file +} diff --git a/src/Nest/Analysis/Tokenizers/TokenizerBase.cs b/src/Nest/Analysis/Tokenizers/TokenizerBase.cs index e484092dcce..8bd1bf35a7e 100644 --- a/src/Nest/Analysis/Tokenizers/TokenizerBase.cs +++ b/src/Nest/Analysis/Tokenizers/TokenizerBase.cs @@ -5,18 +5,17 @@ namespace Nest [ContractJsonConverter(typeof(TokenizerJsonConverter))] public interface ITokenizer { - [JsonProperty("version")] - string Version { get; set; } - [JsonProperty("type")] string Type { get; } + + [JsonProperty("version")] + string Version { get; set; } } public abstract class TokenizerBase : ITokenizer { - public string Version { get; set; } - public string Type { get; protected set; } + public string Version { get; set; } } public abstract class TokenizerDescriptorBase @@ -24,11 +23,10 @@ public abstract class TokenizerDescriptorBase where TTokenizer : TokenizerDescriptorBase, TTokenizerInterface where TTokenizerInterface : class, ITokenizer { - string ITokenizer.Version { get; set; } - string ITokenizer.Type => this.Type; protected abstract string Type { get; } + string ITokenizer.Type => Type; + string ITokenizer.Version { get; set; } public TTokenizer Version(string version) => Assign(a => a.Version = version); } - } diff --git a/src/Nest/Analysis/Tokenizers/TokenizerJsonConverter.cs b/src/Nest/Analysis/Tokenizers/TokenizerJsonConverter.cs index 2f0b34cd91a..e6be0f235a6 100644 --- a/src/Nest/Analysis/Tokenizers/TokenizerJsonConverter.cs +++ b/src/Nest/Analysis/Tokenizers/TokenizerJsonConverter.cs @@ -6,19 +6,20 @@ namespace Nest { internal class TokenizerJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) => true; - public override bool CanWrite => false; public override bool CanRead => true; + public override bool CanWrite => false; + + public override bool CanConvert(Type objectType) => true; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - JObject o = JObject.Load(reader); + var o = JObject.Load(reader); - JProperty typeProperty = o.Property("type"); + var typeProperty = o.Property("type"); if (typeProperty == null) return null; var typePropertyValue = typeProperty.Value.ToString(); - switch(typePropertyValue.ToLowerInvariant()) + switch (typePropertyValue.ToLowerInvariant()) { case "edgengram": case "edge_ngram": return o.ToObject(ElasticContractResolver.Empty); @@ -34,9 +35,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return null; } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); } } diff --git a/src/Nest/Analysis/Tokenizers/Tokenizers.cs b/src/Nest/Analysis/Tokenizers/Tokenizers.cs index 330162c49b4..ed9cd1cc1d7 100644 --- a/src/Nest/Analysis/Tokenizers/Tokenizers.cs +++ b/src/Nest/Analysis/Tokenizers/Tokenizers.cs @@ -10,11 +10,12 @@ public interface ITokenizers : IIsADictionary { } public class Tokenizers : IsADictionaryBase, ITokenizers { - public Tokenizers() {} + public Tokenizers() { } + public Tokenizers(IDictionary container) : base(container) { } + public Tokenizers(Dictionary container) - : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) - {} + : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) { } public void Add(string name, ITokenizer analyzer) => BackingDictionary.Add(name, analyzer); } @@ -45,7 +46,10 @@ public TokenizersDescriptor Keyword(string name, Func /// A tokenizer of type letter that divides text at non-letters. That’s to say, it defines tokens as maximal strings of adjacent letters. - /// Note, this does a decent job for most European languages, but does a terrible job for some Asian languages, where words are not separated by spaces. + /// + /// Note, this does a decent job for most European languages, but does a terrible job for some Asian languages, where words are not + /// separated by spaces. + /// /// public TokenizersDescriptor Letter(string name, Func selector) => Assign(name, selector?.Invoke(new LetterTokenizerDescriptor())); @@ -60,13 +64,13 @@ public TokenizersDescriptor Lowercase(string name, Func - /// The path_hierarchy tokenizer takes something like this: - ////something/something/else - ///And produces tokens: - /// - ////something - ////something/something - ////something/something/else + /// The path_hierarchy tokenizer takes something like this: + /// /something/something/else + /// And produces tokens: + /// + /// /something + /// /something/something + /// /something/something/else /// public TokenizersDescriptor PathHierarchy(string name, Func selector) => Assign(name, selector?.Invoke(new PathHierarchyTokenizerDescriptor())); @@ -113,11 +117,12 @@ public TokenizersDescriptor Kuromoji(string name, Func selector) => Assign(name, selector?.Invoke(new IcuTokenizerDescriptor())); - /// + /// public TokenizersDescriptor Nori(string name, Func selector) => Assign(name, selector?.Invoke(new NoriTokenizerDescriptor())); - /// > + /// + /// > public TokenizersDescriptor CharGroup(string name, Func selector) => Assign(name, selector?.Invoke(new CharGroupTokenizerDescriptor())); } diff --git a/src/Nest/Analysis/Tokenizers/UaxEmailUrlTokenizer.cs b/src/Nest/Analysis/Tokenizers/UaxEmailUrlTokenizer.cs index e1e07530ce7..005d6274566 100644 --- a/src/Nest/Analysis/Tokenizers/UaxEmailUrlTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/UaxEmailUrlTokenizer.cs @@ -11,25 +11,27 @@ public interface IUaxEmailUrlTokenizer : ITokenizer /// The maximum token length. If a token is seen that exceeds this length then it is discarded. Defaults to 255. /// [JsonProperty("max_token_length")] - int? MaxTokenLength { get; set; } + int? MaxTokenLength { get; set; } } - /// + + /// public class UaxEmailUrlTokenizer : TokenizerBase, IUaxEmailUrlTokenizer - { - public UaxEmailUrlTokenizer() { Type = "uax_url_email"; } + { + public UaxEmailUrlTokenizer() => Type = "uax_url_email"; + + /// + public int? MaxTokenLength { get; set; } + } - /// - public int? MaxTokenLength { get; set; } - } - /// - public class UaxEmailUrlTokenizerDescriptor + /// + public class UaxEmailUrlTokenizerDescriptor : TokenizerDescriptorBase, IUaxEmailUrlTokenizer { protected override string Type => "uax_url_email"; int? IUaxEmailUrlTokenizer.MaxTokenLength { get; set; } - /// + /// public UaxEmailUrlTokenizerDescriptor MaxTokenLength(int? maxLength) => Assign(a => a.MaxTokenLength = maxLength); } } diff --git a/src/Nest/Analysis/Tokenizers/WhitespaceTokenizer.cs b/src/Nest/Analysis/Tokenizers/WhitespaceTokenizer.cs index 00787340a49..c86a67c7a66 100644 --- a/src/Nest/Analysis/Tokenizers/WhitespaceTokenizer.cs +++ b/src/Nest/Analysis/Tokenizers/WhitespaceTokenizer.cs @@ -9,7 +9,7 @@ public interface IWhitespaceTokenizer : ITokenizer { /// /// The maximum token length. If a token is seen that exceeds this length then it is split at - /// intervals. Defaults to 255. + /// intervals. Defaults to 255. /// /// /// Valid for Elasticsearch 6.1.0+ @@ -18,16 +18,16 @@ public interface IWhitespaceTokenizer : ITokenizer int? MaxTokenLength { get; set; } } - /// + /// public class WhitespaceTokenizer : TokenizerBase, IWhitespaceTokenizer - { - public WhitespaceTokenizer() { Type = "whitespace"; } + { + public WhitespaceTokenizer() => Type = "whitespace"; - /// - public int? MaxTokenLength { get; set; } - } + /// + public int? MaxTokenLength { get; set; } + } - /// + /// public class WhitespaceTokenizerDescriptor : TokenizerDescriptorBase, IWhitespaceTokenizer { @@ -35,7 +35,7 @@ public class WhitespaceTokenizerDescriptor int? IWhitespaceTokenizer.MaxTokenLength { get; set; } - /// + /// public WhitespaceTokenizerDescriptor MaxTokenLength(int? maxTokenLength) => Assign(a => a.MaxTokenLength = maxTokenLength); } diff --git a/src/Nest/Cat/CatAliases/CatAliasesRecord.cs b/src/Nest/Cat/CatAliases/CatAliasesRecord.cs index 9b5e3b54055..8f959df3835 100644 --- a/src/Nest/Cat/CatAliases/CatAliasesRecord.cs +++ b/src/Nest/Cat/CatAliases/CatAliasesRecord.cs @@ -8,16 +8,16 @@ public class CatAliasesRecord : ICatRecord [JsonProperty("alias")] public string Alias { get; set; } - [JsonProperty("index")] - public string Index { get; set; } - [JsonProperty("filter")] public string Filter { get; set; } + [JsonProperty("index")] + public string Index { get; set; } + [JsonProperty("indexRouting")] public string IndexRouting { get; set; } [JsonProperty("searchRouting")] public string SearchRouting { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatAliases/ElasticClient-CatAliases.cs b/src/Nest/Cat/CatAliases/ElasticClient-CatAliases.cs index fe56122acec..0ae2210d327 100644 --- a/src/Nest/Cat/CatAliases/ElasticClient-CatAliases.cs +++ b/src/Nest/Cat/CatAliases/ElasticClient-CatAliases.cs @@ -1,43 +1,51 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatAliases(Func selector = null); - /// + /// ICatResponse CatAliases(ICatAliasesRequest request); - /// - Task> CatAliasesAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - Task> CatAliasesAsync(ICatAliasesRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatAliasesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); + /// + Task> CatAliasesAsync(ICatAliasesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatAliases(Func selector = null) => - this.CatAliases(selector.InvokeOrDefault(new CatAliasesDescriptor())); + CatAliases(selector.InvokeOrDefault(new CatAliasesDescriptor())); - /// + /// public ICatResponse CatAliases(ICatAliasesRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatAliasesDispatch>); - - /// - public Task> CatAliasesAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.CatAliasesAsync(selector.InvokeOrDefault(new CatAliasesDescriptor()), cancellationToken); - - /// - public Task> CatAliasesAsync(ICatAliasesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatAliasesDispatchAsync>); - + DoCat(request, + LowLevelDispatch.CatAliasesDispatch>); + + /// + public Task> CatAliasesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + CatAliasesAsync(selector.InvokeOrDefault(new CatAliasesDescriptor()), cancellationToken); + + /// + public Task> CatAliasesAsync(ICatAliasesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatAliasesDispatchAsync>); } } diff --git a/src/Nest/Cat/CatAllocation/CatAllocationRecord.cs b/src/Nest/Cat/CatAllocation/CatAllocationRecord.cs index 1a4c9375b9a..fb92cb007b0 100644 --- a/src/Nest/Cat/CatAllocation/CatAllocationRecord.cs +++ b/src/Nest/Cat/CatAllocation/CatAllocationRecord.cs @@ -5,22 +5,22 @@ namespace Nest [JsonObject] public class CatAllocationRecord : ICatRecord { - [JsonProperty("shards")] - public string Shards { get; set; } - - [JsonProperty("diskUsed")] - public string DiskUsed { get; set; } - [JsonProperty("diskAvail")] public string DiskAvailable { get; set; } [JsonProperty("diskRatio")] public string DiskRatio { get; set; } + [JsonProperty("diskUsed")] + public string DiskUsed { get; set; } + [JsonProperty("ip")] public string Ip { get; set; } [JsonProperty("node")] public string Node { get; set; } + + [JsonProperty("shards")] + public string Shards { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatAllocation/ElasticClient-CatAllocation.cs b/src/Nest/Cat/CatAllocation/ElasticClient-CatAllocation.cs index f065c67f3db..08c2b529a48 100644 --- a/src/Nest/Cat/CatAllocation/ElasticClient-CatAllocation.cs +++ b/src/Nest/Cat/CatAllocation/ElasticClient-CatAllocation.cs @@ -1,50 +1,55 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatAllocation(Func selector = null); - /// + /// ICatResponse CatAllocation(ICatAllocationRequest request); - /// + /// Task> CatAllocationAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatAllocationAsync(ICatAllocationRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatAllocationAsync(ICatAllocationRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } + public partial class ElasticClient { - /// + /// public ICatResponse CatAllocation(Func selector = null) => - this.CatAllocation(selector.InvokeOrDefault(new CatAllocationDescriptor())); + CatAllocation(selector.InvokeOrDefault(new CatAllocationDescriptor())); - /// + /// public ICatResponse CatAllocation(ICatAllocationRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatAllocationDispatch>); + DoCat(request, + LowLevelDispatch.CatAllocationDispatch>); - /// + /// public Task> CatAllocationAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatAllocationAsync(selector.InvokeOrDefault(new CatAllocationDescriptor()), cancellationToken); + ) => CatAllocationAsync(selector.InvokeOrDefault(new CatAllocationDescriptor()), cancellationToken); - /// - public Task> CatAllocationAsync(ICatAllocationRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync( + /// + public Task> CatAllocationAsync(ICatAllocationRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync( request, cancellationToken, - this.LowLevelDispatch.CatAllocationDispatchAsync> + LowLevelDispatch.CatAllocationDispatchAsync> ); } } diff --git a/src/Nest/Cat/CatCount/CatCountRecord.cs b/src/Nest/Cat/CatCount/CatCountRecord.cs index 99efe3535f2..8b57ca5b74a 100644 --- a/src/Nest/Cat/CatCount/CatCountRecord.cs +++ b/src/Nest/Cat/CatCount/CatCountRecord.cs @@ -5,13 +5,13 @@ namespace Nest [JsonObject] public class CatCountRecord : ICatRecord { + [JsonProperty("count")] + public string Count { get; set; } + [JsonProperty("epoch")] public string Epoch { get; set; } [JsonProperty("timestamp")] public string Timestamp { get; set; } - - [JsonProperty("count")] - public string Count { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatCount/ElasticClient-CatCount.cs b/src/Nest/Cat/CatCount/ElasticClient-CatCount.cs index 346859d50ee..f616d5f6455 100644 --- a/src/Nest/Cat/CatCount/ElasticClient-CatCount.cs +++ b/src/Nest/Cat/CatCount/ElasticClient-CatCount.cs @@ -1,42 +1,49 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatCount(Func selector = null); - /// + /// ICatResponse CatCount(ICatCountRequest request); - /// - Task> CatCountAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatCountAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task> CatCountAsync(ICatCountRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public ICatResponse CatCount(Func selector = null) => - this.CatCount(selector.InvokeOrDefault(new CatCountDescriptor())); - - /// - public ICatResponse CatCount(ICatCountRequest request)=> - this.DoCat(request, this.LowLevelDispatch.CatCountDispatch>); - - /// - public Task> CatCountAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.CatCountAsync(selector.InvokeOrDefault(new CatCountDescriptor()), cancellationToken); - - /// - public Task> CatCountAsync(ICatCountRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatCountDispatchAsync>); - + CatCount(selector.InvokeOrDefault(new CatCountDescriptor())); + + /// + public ICatResponse CatCount(ICatCountRequest request) => + DoCat(request, + LowLevelDispatch.CatCountDispatch>); + + /// + public Task> CatCountAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + CatCountAsync(selector.InvokeOrDefault(new CatCountDescriptor()), cancellationToken); + + /// + public Task> CatCountAsync(ICatCountRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatCountDispatchAsync>); } } diff --git a/src/Nest/Cat/CatFielddata/CatFielddataRecord.cs b/src/Nest/Cat/CatFielddata/CatFielddataRecord.cs index e2b15f06818..380cf768c1d 100644 --- a/src/Nest/Cat/CatFielddata/CatFielddataRecord.cs +++ b/src/Nest/Cat/CatFielddata/CatFielddataRecord.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -7,11 +6,11 @@ namespace Nest [JsonConverter(typeof(CatFielddataRecordJsonConverter))] public class CatFielddataRecord : ICatRecord { - public string Id { get; set; } + public string Field { get; set; } public string Host { get; set; } + public string Id { get; set; } public string Ip { get; set; } public string Node { get; set; } - public string Field { get; set; } public string Size { get; set; } } } diff --git a/src/Nest/Cat/CatFielddata/CatFielddataRecordJsonConverter.cs b/src/Nest/Cat/CatFielddata/CatFielddataRecordJsonConverter.cs index c08853de631..53dad182ce2 100644 --- a/src/Nest/Cat/CatFielddata/CatFielddataRecordJsonConverter.cs +++ b/src/Nest/Cat/CatFielddata/CatFielddataRecordJsonConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Newtonsoft.Json; namespace Nest @@ -8,13 +7,11 @@ internal class CatFielddataRecordJsonConverter : JsonConverter { public override bool CanWrite => false; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + JsonSerializer serializer + ) { var record = new CatFielddataRecord(); while (reader.Read()) diff --git a/src/Nest/Cat/CatFielddata/ElasticClient-CatFielddata.cs b/src/Nest/Cat/CatFielddata/ElasticClient-CatFielddata.cs index 0d75d860721..ef7f6d3c2b3 100644 --- a/src/Nest/Cat/CatFielddata/ElasticClient-CatFielddata.cs +++ b/src/Nest/Cat/CatFielddata/ElasticClient-CatFielddata.cs @@ -1,48 +1,52 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatFielddata(Func selector = null); - /// + /// ICatResponse CatFielddata(ICatFielddataRequest request); - /// + /// Task> CatFielddataAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatFielddataAsync(ICatFielddataRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatFielddataAsync(ICatFielddataRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatFielddata(Func selector = null) => - this.CatFielddata(selector.InvokeOrDefault(new CatFielddataDescriptor())); + CatFielddata(selector.InvokeOrDefault(new CatFielddataDescriptor())); - /// + /// public ICatResponse CatFielddata(ICatFielddataRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatFielddataDispatch>); + DoCat(request, + LowLevelDispatch.CatFielddataDispatch>); - /// + /// public Task> CatFielddataAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatFielddataAsync(selector.InvokeOrDefault(new CatFielddataDescriptor()), cancellationToken); - - /// - public Task> CatFielddataAsync(ICatFielddataRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatFielddataDispatchAsync>); + ) => CatFielddataAsync(selector.InvokeOrDefault(new CatFielddataDescriptor()), cancellationToken); + /// + public Task> CatFielddataAsync(ICatFielddataRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatFielddataDispatchAsync>); } } diff --git a/src/Nest/Cat/CatHealth/CatHealthRecord.cs b/src/Nest/Cat/CatHealth/CatHealthRecord.cs index c8c4104b88e..68ef41efbf1 100644 --- a/src/Nest/Cat/CatHealth/CatHealthRecord.cs +++ b/src/Nest/Cat/CatHealth/CatHealthRecord.cs @@ -11,21 +11,24 @@ public class CatHealthRecord : ICatRecord [JsonProperty("epoch")] public string Epoch { get; set; } + [JsonProperty("init")] + public string Initializing { get; set; } + [JsonProperty("node.data")] public string NodeData { get; set; } [JsonProperty("node.total")] public string NodeTotal { get; set; } + [JsonProperty("pending_tasks")] + public string PendingTasks { get; set; } + [JsonProperty("pri")] public string Primary { get; set; } [JsonProperty("relo")] public string Relocating { get; set; } - [JsonProperty("init")] - public string Initializing { get; set; } - [JsonProperty("shards")] public string Shards { get; set; } @@ -37,8 +40,5 @@ public class CatHealthRecord : ICatRecord [JsonProperty("unassign")] public string Unassigned { get; set; } - - [JsonProperty("pending_tasks")] - public string PendingTasks { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatHealth/ElasticClient-CatHealth.cs b/src/Nest/Cat/CatHealth/ElasticClient-CatHealth.cs index d115bfbc474..0bacbdea5f4 100644 --- a/src/Nest/Cat/CatHealth/ElasticClient-CatHealth.cs +++ b/src/Nest/Cat/CatHealth/ElasticClient-CatHealth.cs @@ -1,47 +1,51 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatHealth(Func selector = null); - /// + /// ICatResponse CatHealth(ICatHealthRequest request); - /// + /// Task> CatHealthAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatHealthAsync(ICatHealthRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatHealthAsync(ICatHealthRequest request, CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatHealth(Func selector = null) => - this.CatHealth(selector.InvokeOrDefault(new CatHealthDescriptor())); + CatHealth(selector.InvokeOrDefault(new CatHealthDescriptor())); - /// + /// public ICatResponse CatHealth(ICatHealthRequest request) => - DoCat(request, LowLevelDispatch.CatHealthDispatch>); + DoCat(request, + LowLevelDispatch.CatHealthDispatch>); - /// + /// public Task> CatHealthAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatHealthAsync(selector.InvokeOrDefault(new CatHealthDescriptor()), cancellationToken); + ) => CatHealthAsync(selector.InvokeOrDefault(new CatHealthDescriptor()), cancellationToken); - /// - public Task> CatHealthAsync(ICatHealthRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - DoCatAsync(request, cancellationToken, LowLevelDispatch.CatHealthDispatchAsync>); + /// + public Task> CatHealthAsync(ICatHealthRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatHealthDispatchAsync>); } } diff --git a/src/Nest/Cat/CatHelp/CatHelpRecord.cs b/src/Nest/Cat/CatHelp/CatHelpRecord.cs index 107e37db804..24d67ab0bda 100644 --- a/src/Nest/Cat/CatHelp/CatHelpRecord.cs +++ b/src/Nest/Cat/CatHelp/CatHelpRecord.cs @@ -7,6 +7,5 @@ public class CatHelpRecord : ICatRecord { [JsonProperty("endpoint")] public string Endpoint { get; set; } - } } diff --git a/src/Nest/Cat/CatHelp/ElasticClient-CatHelp.cs b/src/Nest/Cat/CatHelp/ElasticClient-CatHelp.cs index e3409fa4e5a..464bc78e7af 100644 --- a/src/Nest/Cat/CatHelp/ElasticClient-CatHelp.cs +++ b/src/Nest/Cat/CatHelp/ElasticClient-CatHelp.cs @@ -1,32 +1,59 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatHelp(Func selector = null); - /// + /// ICatResponse CatHelp(ICatHelpRequest request); - /// - Task> CatHelpAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatHelpAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task> CatHelpAsync(ICatHelpRequest request, CancellationToken cancellationToken = default(CancellationToken)); - } public partial class ElasticClient { + /// + public ICatResponse CatHelp(Func selector = null) => + CatHelp(selector.InvokeOrDefault(new CatHelpDescriptor())); + + /// + public ICatResponse CatHelp(ICatHelpRequest request) => + Dispatcher.Dispatch>( + request, + new Func>(DeserializeCatHelpResponse), + (p, d) => LowLevelDispatch.CatHelpDispatch>(p) + ); + + /// + public Task> CatHelpAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + CatHelpAsync(selector.InvokeOrDefault(new CatHelpDescriptor()), cancellationToken); + + /// + public Task> CatHelpAsync(ICatHelpRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync, ICatResponse>( + request, + cancellationToken, + new Func>(DeserializeCatHelpResponse), + (p, d, c) => LowLevelDispatch.CatHelpDispatchAsync>(p, c) + ); private CatResponse DeserializeCatHelpResponse(IApiCallDetails response, Stream stream) { @@ -37,37 +64,12 @@ private CatResponse DeserializeCatHelpResponse(IApiCallDetails re var body = ms.ToArray().Utf8String(); return new CatResponse { - Records = body.Split('\n').Skip(1) + Records = body.Split('\n') + .Skip(1) .Select(f => new CatHelpRecord { Endpoint = f.Trim() }) .ToList() }; } } - - /// - public ICatResponse CatHelp(Func selector = null) => - this.CatHelp(selector.InvokeOrDefault(new CatHelpDescriptor())); - - /// - public ICatResponse CatHelp(ICatHelpRequest request) => - this.Dispatcher.Dispatch>( - request, - new Func>(this.DeserializeCatHelpResponse), - (p, d) => this.LowLevelDispatch.CatHelpDispatch>(p) - ); - - /// - public Task> CatHelpAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.CatHelpAsync(selector.InvokeOrDefault(new CatHelpDescriptor()), cancellationToken); - - /// - public Task> CatHelpAsync(ICatHelpRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync, ICatResponse>( - request, - cancellationToken, - new Func>(this.DeserializeCatHelpResponse), - (p, d, c) => this.LowLevelDispatch.CatHelpDispatchAsync>(p, c) - ); - } } diff --git a/src/Nest/Cat/CatIndices/CatIndicesRecord.cs b/src/Nest/Cat/CatIndices/CatIndicesRecord.cs index e96e68af3e9..1c934512397 100644 --- a/src/Nest/Cat/CatIndices/CatIndicesRecord.cs +++ b/src/Nest/Cat/CatIndices/CatIndicesRecord.cs @@ -26,13 +26,13 @@ public class CatIndicesRecord : ICatRecord [JsonProperty("rep")] public string Replica { get; set; } - [JsonProperty("store.size")] - public string StoreSize { get; set; } - [JsonProperty("status")] public string Status { get; set; } + [JsonProperty("store.size")] + public string StoreSize { get; set; } + [JsonProperty("tm")] public string TotalMemory { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatIndices/ElasticClient-CatIndices.cs b/src/Nest/Cat/CatIndices/ElasticClient-CatIndices.cs index 59f970090c6..322f9df40e9 100644 --- a/src/Nest/Cat/CatIndices/ElasticClient-CatIndices.cs +++ b/src/Nest/Cat/CatIndices/ElasticClient-CatIndices.cs @@ -1,47 +1,52 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatIndices(Func selector = null); - /// + /// ICatResponse CatIndices(ICatIndicesRequest request); - /// + /// Task> CatIndicesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatIndicesAsync(ICatIndicesRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatIndicesAsync(ICatIndicesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatIndices(Func selector = null) => - this.CatIndices(selector.InvokeOrDefault(new CatIndicesDescriptor())); + CatIndices(selector.InvokeOrDefault(new CatIndicesDescriptor())); - /// + /// public ICatResponse CatIndices(ICatIndicesRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatIndicesDispatch>); + DoCat(request, + LowLevelDispatch.CatIndicesDispatch>); - /// + /// public Task> CatIndicesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatIndicesAsync(selector.InvokeOrDefault(new CatIndicesDescriptor()), cancellationToken); + ) => CatIndicesAsync(selector.InvokeOrDefault(new CatIndicesDescriptor()), cancellationToken); - /// - public Task> CatIndicesAsync(ICatIndicesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatIndicesDispatchAsync>); + /// + public Task> CatIndicesAsync(ICatIndicesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatIndicesDispatchAsync>); } } diff --git a/src/Nest/Cat/CatMaster/CatMasterRecord.cs b/src/Nest/Cat/CatMaster/CatMasterRecord.cs index b4963861d09..ff631f86c01 100644 --- a/src/Nest/Cat/CatMaster/CatMasterRecord.cs +++ b/src/Nest/Cat/CatMaster/CatMasterRecord.cs @@ -14,4 +14,4 @@ public class CatMasterRecord : ICatRecord [JsonProperty("node")] public string Node { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatMaster/ElasticClient-CatMaster.cs b/src/Nest/Cat/CatMaster/ElasticClient-CatMaster.cs index 78e8acad4f3..ad326c6e9a7 100644 --- a/src/Nest/Cat/CatMaster/ElasticClient-CatMaster.cs +++ b/src/Nest/Cat/CatMaster/ElasticClient-CatMaster.cs @@ -1,45 +1,51 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatMaster(Func selector = null); - /// + /// ICatResponse CatMaster(ICatMasterRequest request); - /// + /// Task> CatMasterAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatMasterAsync(ICatMasterRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatMasterAsync(ICatMasterRequest request, CancellationToken cancellationToken = default(CancellationToken) + ); } + public partial class ElasticClient { - /// + /// public ICatResponse CatMaster(Func selector = null) => - this.CatMaster(selector.InvokeOrDefault(new CatMasterDescriptor())); + CatMaster(selector.InvokeOrDefault(new CatMasterDescriptor())); - /// + /// public ICatResponse CatMaster(ICatMasterRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatMasterDispatch>); + DoCat(request, + LowLevelDispatch.CatMasterDispatch>); - /// - public Task> CatMasterAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.CatMasterAsync(selector.InvokeOrDefault(new CatMasterDescriptor()), cancellationToken); + /// + public Task> CatMasterAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + CatMasterAsync(selector.InvokeOrDefault(new CatMasterDescriptor()), cancellationToken); - /// - public Task> CatMasterAsync(ICatMasterRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatMasterDispatchAsync>); + /// + public Task> CatMasterAsync(ICatMasterRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatMasterDispatchAsync>); } } - diff --git a/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRecord.cs b/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRecord.cs index 787f069f106..77515bb0704 100644 --- a/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRecord.cs +++ b/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRecord.cs @@ -5,30 +5,29 @@ namespace Nest [JsonObject] public class CatNodeAttributesRecord : ICatRecord { - // duration indices successful_shards failed_shards total_shards - [JsonProperty("id")] - public string Id { get; set; } - - [JsonProperty("node")] - public string Node { get; set; } - - [JsonProperty("pid")] - public long ProcessId { get; set; } + [JsonProperty("attr")] + public string Attribute { get; set; } [JsonProperty("host")] public string Host { get; set; } + // duration indices successful_shards failed_shards total_shards + [JsonProperty("id")] + public string Id { get; set; } + [JsonProperty("ip")] public string Ip { get; set; } + [JsonProperty("node")] + public string Node { get; set; } + [JsonProperty("port")] public long Port { get; set; } - [JsonProperty("attr")] - public string Attribute { get; set; } + [JsonProperty("pid")] + public long ProcessId { get; set; } [JsonProperty("value")] public string Value { get; set; } - } } diff --git a/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRequest.cs b/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRequest.cs index ca8329771f9..3c3957cc7e2 100644 --- a/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRequest.cs +++ b/src/Nest/Cat/CatNodeAttributes/CatNodeAttributesRequest.cs @@ -1,5 +1,4 @@ -using System; -#pragma warning disable 612, 618 +#pragma warning disable 612, 618 namespace Nest { diff --git a/src/Nest/Cat/CatNodeAttributes/ElasticClient-CatNodeAttributes.cs b/src/Nest/Cat/CatNodeAttributes/ElasticClient-CatNodeAttributes.cs index 42cf4ec2fad..eedfc0665b7 100644 --- a/src/Nest/Cat/CatNodeAttributes/ElasticClient-CatNodeAttributes.cs +++ b/src/Nest/Cat/CatNodeAttributes/ElasticClient-CatNodeAttributes.cs @@ -1,48 +1,53 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatNodeAttributes(Func selector = null); - /// + /// ICatResponse CatNodeAttributes(ICatNodeAttributesRequest request); - /// + /// Task> CatNodeAttributesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatNodeAttributesAsync(ICatNodeAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatNodeAttributesAsync(ICatNodeAttributesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// - public ICatResponse CatNodeAttributes(Func selector = null) => - this.CatNodeAttributes(selector.InvokeOrDefault(new CatNodeAttributesDescriptor())); + /// + public ICatResponse + CatNodeAttributes(Func selector = null) => + CatNodeAttributes(selector.InvokeOrDefault(new CatNodeAttributesDescriptor())); - /// + /// public ICatResponse CatNodeAttributes(ICatNodeAttributesRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatNodeattrsDispatch>); + DoCat(request, + LowLevelDispatch.CatNodeattrsDispatch>); - /// + /// public Task> CatNodeAttributesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatNodeAttributesAsync(selector.InvokeOrDefault(new CatNodeAttributesDescriptor()), cancellationToken); - - /// - public Task> CatNodeAttributesAsync(ICatNodeAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatNodeattrsDispatchAsync>); + ) => CatNodeAttributesAsync(selector.InvokeOrDefault(new CatNodeAttributesDescriptor()), cancellationToken); + /// + public Task> CatNodeAttributesAsync(ICatNodeAttributesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatNodeattrsDispatchAsync>); } } diff --git a/src/Nest/Cat/CatNodes/CatNodesRecord.cs b/src/Nest/Cat/CatNodes/CatNodesRecord.cs index 81a53a8884a..62951c42261 100644 --- a/src/Nest/Cat/CatNodes/CatNodesRecord.cs +++ b/src/Nest/Cat/CatNodes/CatNodesRecord.cs @@ -5,538 +5,668 @@ namespace Nest [JsonObject(MemberSerialization.OptIn)] public class CatNodesRecord : ICatRecord { - [JsonProperty("id")] - internal string _id { get; set; } - [JsonProperty("nodeId")] - internal string _nodeId { get; set; } - public string NodeId => this._id ?? this._nodeId; + public string Build => _b ?? _build; + public string CompletionSize => _completionSize ?? _cs ?? _completion_size; - [JsonProperty("pid")] - internal string _pid { get; set; } - [JsonProperty("p")] - internal string _p { get; set; } - public string Pid => this._p ?? this._pid; + [JsonProperty("cpu")] + public string CPU { get; internal set; } - [JsonProperty("ip")] - internal string _ip { get; set; } - [JsonProperty("i")] - internal string _i { get; set; } - public string Ip => this._i ?? this._ip; + public string DiskAvailable => _diskAvail ?? _disk ?? _d ?? _disk_avail; + public string FielddataEvictions => _fielddataEvictions ?? _fe ?? _fielddata_evictions; + public string FielddataMemory => _fielddataMemory ?? _fm ?? _fielddata_memory_size; + public int? FileDescriptorCurrent => _fileDescriptorCurrent ?? _fdc ?? _file_desc_current; + public int? FileDescriptorMax => _fileDescriptorMax ?? _fdm ?? _file_desc_max; + public int? FileDescriptorPercent => _fileDescriptorPercent ?? _fdp ?? _file_desc_percent; + public string FilterCacheEvictions => _filterCacheEvictions ?? _fce ?? _filter_cache_evictions; + public string FilterCacheMemory => _filterCacheMemory ?? _fcm ?? _filter_cache_memory_size; + public string FlushTotal => _flushTotal ?? _ft ?? _flush_total; + public string FlushTotalTime => _flushTotalTime ?? _ftt ?? _flush_total_time; + public string GetCurrent => _getCurrent ?? _gc ?? _get_current; + public string GetExistsTime => _getExistsTime ?? _geti ?? _get_exists_time; + public string GetExistsTotal => _getExistsTotal ?? _geto ?? _get_exists_total; + public string GetMissingTime => _getMissingTime ?? _gmti ?? _get_missing_time; + public string GetMissingTotal => _getMissingTotal ?? _gmto ?? _get_missing_total; + public string GetTime => _getTime ?? _gti ?? _get_time; + public string GetTotal => _getTotal ?? _gto ?? _get_total; + public string HeapCurrent => _heapCurrent ?? _hc ?? _heap_current; + public string HeapMax => _heapMax ?? _hm ?? _heap_max; + public string HeapPercent => _heapPercent ?? _hp ?? _heap_percent; + public string IdCacheMemory => _idCacheMemory ?? _im ?? _id_cache_memory_size; + public string IndexingDeleteCurrent => _indexingDeleteCurrent ?? _idcs ?? _indexing_delete_current; + public string IndexingDeleteTime => _indexingDeleteTime ?? _idti ?? _indexing_delete_time; + public string IndexingDeleteTotal => _indexingDeleteTotal ?? _idto ?? _indexing_delete_total; + public string IndexingIndexCurrent => _indexingIndexCurrent ?? _iic ?? _indexing_index_current; + public string IndexingIndexTime => _indexingIndexTime ?? _iiti ?? _indexing_index_time; + public string IndexingIndexTotal => _indexingIndexTotal ?? _iito ?? _indexing_index_total; + public string Ip => _i ?? _ip; + public string Jdk => _j ?? _jdk; - [JsonProperty("port")] - internal string _port { get; set; } - [JsonProperty("po")] - internal string _po { get; set; } - public string Port => this._po ?? this._port; + [JsonProperty("load_15m")] + public string LoadFifteenMinute { get; internal set; } - [JsonProperty("version")] - internal string _version { get; set; } - [JsonProperty("v")] - internal string _v { get; set; } - public string Version => this._v ?? this._version; + [JsonProperty("load_5m")] + public string LoadFiveMinute { get; internal set; } + + [JsonProperty("load_1m")] + public string LoadOneMinute { get; internal set; } + + public string Master => _m ?? _master; + public string MergesCurrent => _mergesCurrent ?? _mc ?? _merges_current; + public string MergesCurrentDocs => _mergesCurrentDocs ?? _mcd ?? _merges_current_docs; + public string MergesCurrentSize => _mergesCurrentSize ?? _mcs ?? _merges_current_size; + public string MergesTotal => _mergesTotal ?? _mt ?? _merges_total; + public string MergesTotalDocs => _mergesTotalDocs ?? _mtd ?? _merges_total_docs; + public string MergesTotalTime => _mergesTotalTime ?? _mtt ?? _merges_total_time; + public string Name => _n ?? _name; + public string NodeId => _id ?? _nodeId; + public string NodeRole => _nodeRole ?? _data_client ?? _dc ?? _r ?? _node_role; + public string PercolateCurrent => _percolateCurrent ?? _pc ?? _percolate_current; + public string PercolateMemory => _percolateMemory ?? _pm ?? _percolate_memory_size; + public string PercolateQueries => _percolate_queries ?? _pq ?? _percolate_queries; + public string PercolateTime => _percolateTime ?? _pti ?? _percolate_time; + public string PercolateTotal => _percolateTotal ?? _pto ?? _percolate_total; + public string Pid => _p ?? _pid; + public string Port => _po ?? _port; + public string RamCurrent => _ramCurrent ?? _rc ?? _ram_current; + public string RamMax => _ramMax ?? _rm ?? _ram_max; + public string RamPercent => _ramPercent ?? _rp ?? _ram_percent; + public string RefreshTime => _refreshTime ?? _rti ?? _refreshTime; + public string RefreshTotal => _refreshTotal ?? _rto ?? _refresh_total; + public string SearchFetchCurrent => _searchFetchCurrent ?? _sfc ?? _search_fetch_current; + public string SearchFetchTime => _searchFetchTime ?? _sfti ?? _search_fetch_time; + public string SearchFetchTotal => _searchFetchTotal ?? _sfto ?? _searchFetchTotal; + public string SearchOpenContexts => _searchOpenContexts ?? _so ?? _search_open_contexts; + public string SearchQueryCurrent => _searchQueryCurrent ?? _sqc ?? _search_query_current; + public string SearchQueryTime => _searchQueryTime ?? _sqti ?? _search_query_time; + public string SearchQueryTotal => _searchQueryTotal ?? _sqto ?? _search_query_total; + public string SegmentsCount => _segmentsCount ?? _sc ?? _segmentsCount; + public string SegmentsIndexWriterMaxMemory => _segmentsIndexWriterMaxMemory ?? _siwmx ?? _segments_index_writer_max_memory; + public string SegmentsIndexWriterMemory => _segmentsIndexWriterMemory ?? _siwm ?? _segments_index_writer_memory; + public string SegmentsMemory => _segmentsMemory ?? _sm ?? _segments_memory; + public string SegmentsVersionMapMemory => _segmentsVersionMapMemory ?? _svmm ?? _segments_version_map_memory; + public string Uptime => _u ?? _uptime; + public string Version => _v ?? _version; - [JsonProperty("build")] - internal string _build { get; set; } [JsonProperty("b")] internal string _b { get; set; } - public string Build => this._b ?? this._build; - [JsonProperty("jdk")] - internal string _jdk { get; set; } - [JsonProperty("j")] - internal string _j { get; set; } - public string Jdk => this._j ?? this._jdk; + [JsonProperty("build")] + internal string _build { get; set; } + + [JsonProperty("completion.size")] + internal string _completion_size { get; set; } + + [JsonProperty("completionSize")] + internal string _completionSize { get; set; } + + [JsonProperty("cs")] + internal string _cs { get; set; } - [JsonProperty("disk.avail")] - internal string _disk_avail { get; set; } [JsonProperty("d")] internal string _d { get; set; } + + [JsonProperty("data/client")] + internal string _data_client { get; set; } + + [JsonProperty("dc")] + internal string _dc { get; set; } + [JsonProperty("disk")] internal string _disk { get; set; } + + [JsonProperty("disk.avail")] + internal string _disk_avail { get; set; } + [JsonProperty("diskAvail")] internal string _diskAvail { get; set; } - public string DiskAvailable => this._diskAvail ?? this._disk ?? this._d ?? this._disk_avail; - [JsonProperty("heap.current")] - internal string _heap_current { get; set; } - [JsonProperty("hc")] - internal string _hc { get; set; } - [JsonProperty("heapCurrent")] - internal string _heapCurrent { get; set; } - public string HeapCurrent => this._heapCurrent ?? this._hc ?? this._heap_current; + [JsonProperty("fce")] + internal string _fce { get; set; } - [JsonProperty("heap.percent")] - internal string _heap_percent { get; set; } - [JsonProperty("hp")] - internal string _hp { get; set; } - [JsonProperty("heapPercent")] - internal string _heapPercent { get; set; } - public string HeapPercent => this._heapPercent ?? this._hp ?? this._heap_percent; + [JsonProperty("fcm")] + internal string _fcm { get; set; } - [JsonProperty("heap.max")] - internal string _heap_max { get; set; } - [JsonProperty("hm")] - internal string _hm { get; set; } - [JsonProperty("heapMax")] - internal string _heapMax { get; set; } - public string HeapMax => this._heapMax ?? this._hm ?? this._heap_max; + [JsonProperty("fdc")] + internal int? _fdc { get; set; } - [JsonProperty("ram.current")] - internal string _ram_current { get; set; } - [JsonProperty("rc")] - internal string _rc { get; set; } - [JsonProperty("ramCurrent")] - internal string _ramCurrent { get; set; } - public string RamCurrent => this._ramCurrent ?? this._rc ?? this._ram_current; + [JsonProperty("fdm")] + internal int? _fdm { get; set; } - [JsonProperty("ram.percent")] - internal string _ram_percent { get; set; } - [JsonProperty("rp")] - internal string _rp { get; set; } - [JsonProperty("ramPercent")] - internal string _ramPercent { get; set; } - public string RamPercent => this._ramPercent ?? this._rp ?? this._ram_percent; + [JsonProperty("fdp")] + internal int? _fdp { get; set; } - [JsonProperty("ram.max")] - internal string _ram_max { get; set; } - [JsonProperty("rm")] - internal string _rm { get; set; } - [JsonProperty("ramMax")] - internal string _ramMax { get; set; } - public string RamMax => this._ramMax ?? this._rm ?? this._ram_max; + [JsonProperty("fe")] + internal string _fe { get; set; } - [JsonProperty("load_1m")] - public string LoadOneMinute { get; internal set; } + [JsonProperty("fielddata.evictions")] + internal string _fielddata_evictions { get; set; } - [JsonProperty("load_5m")] - public string LoadFiveMinute { get; internal set; } + [JsonProperty("fielddata.memory_size")] + internal string _fielddata_memory_size { get; set; } - [JsonProperty("load_15m")] - public string LoadFifteenMinute { get; internal set; } + [JsonProperty("fielddataEvictions")] + internal string _fielddataEvictions { get; set; } - [JsonProperty("cpu")] - public string CPU { get; internal set; } + [JsonProperty("fielddataMemory")] + internal string _fielddataMemory { get; set; } - [JsonProperty("uptime")] - internal string _uptime { get; set; } - [JsonProperty("u")] - internal string _u { get; set; } - public string Uptime => this._u ?? this._uptime; + [JsonProperty("file_desc.current")] + internal int? _file_desc_current { get; set; } - [JsonProperty("node.role")] - internal string _node_role { get; set; } - [JsonProperty("r")] - internal string _r { get; set; } - [JsonProperty("dc")] - internal string _dc { get; set; } - [JsonProperty("data/client")] - internal string _data_client { get; set; } - [JsonProperty("nodeRole")] - internal string _nodeRole { get; set; } - public string NodeRole => this._nodeRole ?? this._data_client ?? this._dc ?? this._r ?? this._node_role; + [JsonProperty("file_desc.max")] + internal int? _file_desc_max { get; set; } - [JsonProperty("master")] - internal string _master { get; set; } - [JsonProperty("m")] - internal string _m { get; set; } - public string Master => this._m ?? this._master; + [JsonProperty("file_desc.percent")] + internal int? _file_desc_percent { get; set; } - [JsonProperty("name")] - internal string _name { get; set; } - [JsonProperty("n")] - internal string _n { get; set; } - public string Name => this._n ?? this._name; + [JsonProperty("fileDescriptorCurrent")] + internal int? _fileDescriptorCurrent { get; set; } - [JsonProperty("completion.size")] - internal string _completion_size { get; set; } - [JsonProperty("cs")] - internal string _cs { get; set; } - [JsonProperty("completionSize")] - internal string _completionSize { get; set; } - public string CompletionSize => this._completionSize ?? this._cs ?? this._completion_size; + [JsonProperty("fileDescriptorMax")] + internal int? _fileDescriptorMax { get; set; } - [JsonProperty("fielddata.memory_size")] - internal string _fielddata_memory_size { get; set; } - [JsonProperty("fm")] - internal string _fm { get; set; } - [JsonProperty("fielddataMemory")] - internal string _fielddataMemory { get; set; } - public string FielddataMemory => this._fielddataMemory ?? this._fm ?? this._fielddata_memory_size; + [JsonProperty("fileDescriptorPercent")] + internal int? _fileDescriptorPercent { get; set; } - [JsonProperty("fielddata.evictions")] - internal string _fielddata_evictions { get; set; } - [JsonProperty("fe")] - internal string _fe { get; set; } - [JsonProperty("fielddataEvictions")] - internal string _fielddataEvictions { get; set; } - public string FielddataEvictions => this._fielddataEvictions ?? this._fe ?? this._fielddata_evictions; + [JsonProperty("filter_cache.evictions")] + internal string _filter_cache_evictions { get; set; } [JsonProperty("filter_cache.memory_size")] internal string _filter_cache_memory_size { get; set; } - [JsonProperty("fcm")] - internal string _fcm { get; set; } - [JsonProperty("filterCacheMemory")] - internal string _filterCacheMemory { get; set; } - public string FilterCacheMemory => this._filterCacheMemory ?? this._fcm ?? this._filter_cache_memory_size; - [JsonProperty("filter_cache.evictions")] - internal string _filter_cache_evictions { get; set; } - [JsonProperty("fce")] - internal string _fce { get; set; } [JsonProperty("filterCacheEvictions")] internal string _filterCacheEvictions { get; set; } - public string FilterCacheEvictions => this._filterCacheEvictions ?? this._fce ?? this._filter_cache_evictions; + + [JsonProperty("filterCacheMemory")] + internal string _filterCacheMemory { get; set; } [JsonProperty("flush.total")] internal string _flush_total { get; set; } - [JsonProperty("ft")] - internal string _ft { get; set; } - [JsonProperty("flushTotal")] - internal string _flushTotal { get; set; } - public string FlushTotal => this._flushTotal ?? this._ft ?? this._flush_total; [JsonProperty("flush.total_time")] internal string _flush_total_time { get; set; } - [JsonProperty("ftt")] - internal string _ftt { get; set; } + + [JsonProperty("flushTotal")] + internal string _flushTotal { get; set; } + [JsonProperty("flushTotalTime")] internal string _flushTotalTime { get; set; } - public string FlushTotalTime => this._flushTotalTime ?? this._ftt ?? this._flush_total_time; - [JsonProperty("file_desc.current")] - internal int? _file_desc_current { get; set; } - [JsonProperty("fdc")] - internal int? _fdc { get; set; } - [JsonProperty("fileDescriptorCurrent")] - internal int? _fileDescriptorCurrent { get; set; } - public int? FileDescriptorCurrent => this._fileDescriptorCurrent ?? this._fdc ?? this._file_desc_current; + [JsonProperty("fm")] + internal string _fm { get; set; } - [JsonProperty("file_desc.percent")] - internal int? _file_desc_percent { get; set; } - [JsonProperty("fdp")] - internal int? _fdp { get; set; } - [JsonProperty("fileDescriptorPercent")] - internal int? _fileDescriptorPercent { get; set; } - public int? FileDescriptorPercent => this._fileDescriptorPercent ?? this._fdp ?? this._file_desc_percent; + [JsonProperty("ft")] + internal string _ft { get; set; } - [JsonProperty("file_desc.max")] - internal int? _file_desc_max { get; set; } - [JsonProperty("fdm")] - internal int? _fdm { get; set; } - [JsonProperty("fileDescriptorMax")] - internal int? _fileDescriptorMax { get; set; } - public int? FileDescriptorMax => this._fileDescriptorMax ?? this._fdm ?? this._file_desc_max; + [JsonProperty("ftt")] + internal string _ftt { get; set; } - [JsonProperty("get.current")] - internal string _get_current { get; set; } [JsonProperty("gc")] internal string _gc { get; set; } - [JsonProperty("getCurrent")] - internal string _getCurrent { get; set; } - public string GetCurrent => this._getCurrent ?? this._gc ?? this._get_current; + + [JsonProperty("get.current")] + internal string _get_current { get; set; } + + [JsonProperty("get.exists_time")] + internal string _get_exists_time { get; set; } + + [JsonProperty("get.exists_total")] + internal string _get_exists_total { get; set; } + + [JsonProperty("get.missing_time")] + internal string _get_missing_time { get; set; } + + [JsonProperty("get.missing_total")] + internal string _get_missing_total { get; set; } [JsonProperty("get.time")] internal string _get_time { get; set; } - [JsonProperty("gti")] - internal string _gti { get; set; } - [JsonProperty("getTime")] - internal string _getTime { get; set; } - public string GetTime => this._getTime ?? this._gti ?? this._get_time; [JsonProperty("get.total")] internal string _get_total { get; set; } - [JsonProperty("gto")] - internal string _gto { get; set; } - [JsonProperty("getTotal")] - internal string _getTotal { get; set; } - public string GetTotal => this._getTotal ?? this._gto ?? this._get_total; - [JsonProperty("get.exists_time")] - internal string _get_exists_time { get; set; } - [JsonProperty("geti")] - internal string _geti { get; set; } + [JsonProperty("getCurrent")] + internal string _getCurrent { get; set; } + [JsonProperty("getExistsTime")] internal string _getExistsTime { get; set; } - public string GetExistsTime => this._getExistsTime ?? this._geti ?? this._get_exists_time; - [JsonProperty("get.exists_total")] - internal string _get_exists_total { get; set; } - [JsonProperty("geto")] - internal string _geto { get; set; } [JsonProperty("getExistsTotal")] internal string _getExistsTotal { get; set; } - public string GetExistsTotal => this._getExistsTotal ?? this._geto ?? this._get_exists_total; - [JsonProperty("get.missing_time")] - internal string _get_missing_time { get; set; } - [JsonProperty("gmti")] - internal string _gmti { get; set; } + [JsonProperty("geti")] + internal string _geti { get; set; } + [JsonProperty("getMissingTime")] internal string _getMissingTime { get; set; } - public string GetMissingTime => this._getMissingTime ?? this._gmti ?? this._get_missing_time; - [JsonProperty("get.missing_total")] - internal string _get_missing_total { get; set; } - [JsonProperty("gmto")] - internal string _gmto { get; set; } [JsonProperty("getMissingTotal")] internal string _getMissingTotal { get; set; } - public string GetMissingTotal => this._getMissingTotal ?? this._gmto ?? this._get_missing_total; + + [JsonProperty("geto")] + internal string _geto { get; set; } + + [JsonProperty("getTime")] + internal string _getTime { get; set; } + + [JsonProperty("getTotal")] + internal string _getTotal { get; set; } + + [JsonProperty("gmti")] + internal string _gmti { get; set; } + + [JsonProperty("gmto")] + internal string _gmto { get; set; } + + [JsonProperty("gti")] + internal string _gti { get; set; } + + [JsonProperty("gto")] + internal string _gto { get; set; } + + [JsonProperty("hc")] + internal string _hc { get; set; } + + [JsonProperty("heap.current")] + internal string _heap_current { get; set; } + + [JsonProperty("heap.max")] + internal string _heap_max { get; set; } + + [JsonProperty("heap.percent")] + internal string _heap_percent { get; set; } + + [JsonProperty("heapCurrent")] + internal string _heapCurrent { get; set; } + + [JsonProperty("heapMax")] + internal string _heapMax { get; set; } + + [JsonProperty("heapPercent")] + internal string _heapPercent { get; set; } + + [JsonProperty("hm")] + internal string _hm { get; set; } + + [JsonProperty("hp")] + internal string _hp { get; set; } + + [JsonProperty("i")] + internal string _i { get; set; } + + [JsonProperty("id")] + internal string _id { get; set; } [JsonProperty("id_cache.memory_size")] internal string _id_cache_memory_size { get; set; } - [JsonProperty("im")] - internal string _im { get; set; } + [JsonProperty("idCacheMemory")] internal string _idCacheMemory { get; set; } - public string IdCacheMemory => this._idCacheMemory ?? this._im ?? this._id_cache_memory_size; - [JsonProperty("indexing.delete_current")] - internal string _indexing_delete_current { get; set; } [JsonProperty("idc")] internal string _idcs { get; set; } - [JsonProperty("indexingDeleteCurrent")] - internal string _indexingDeleteCurrent { get; set; } - public string IndexingDeleteCurrent => this._indexingDeleteCurrent ?? this._idcs ?? this._indexing_delete_current; - [JsonProperty("indexing.delete_time")] - internal string _indexing_delete_time { get; set; } [JsonProperty("idti")] internal string _idti { get; set; } - [JsonProperty("indexingDeleteTime")] - internal string _indexingDeleteTime { get; set; } - public string IndexingDeleteTime => this._indexingDeleteTime ?? this._idti ?? this._indexing_delete_time; - [JsonProperty("indexing.delete_total")] - internal string _indexing_delete_total { get; set; } [JsonProperty("idto")] internal string _idto { get; set; } - [JsonProperty("indexingDeleteTotal")] - internal string _indexingDeleteTotal { get; set; } - public string IndexingDeleteTotal => this._indexingDeleteTotal ?? this._idto ?? this._indexing_delete_total; - [JsonProperty("indexing.index_current")] - internal string _indexing_index_current { get; set; } [JsonProperty("iic")] internal string _iic { get; set; } - [JsonProperty("indexingIndexCurrent")] - internal string _indexingIndexCurrent { get; set; } - public string IndexingIndexCurrent => this._indexingIndexCurrent ?? this._iic ?? this._indexing_index_current; - [JsonProperty("indexing.index_time")] - internal string _indexing_index_time { get; set; } [JsonProperty("iiti")] internal string _iiti { get; set; } - [JsonProperty("indexingIndexTime")] - internal string _indexingIndexTime { get; set; } - public string IndexingIndexTime => this._indexingIndexTime ?? this._iiti ?? this._indexing_index_time; - [JsonProperty("indexing.index_total")] - internal string _indexing_index_total { get; set; } [JsonProperty("iito")] internal string _iito { get; set; } + + [JsonProperty("im")] + internal string _im { get; set; } + + [JsonProperty("indexing.delete_current")] + internal string _indexing_delete_current { get; set; } + + [JsonProperty("indexing.delete_time")] + internal string _indexing_delete_time { get; set; } + + [JsonProperty("indexing.delete_total")] + internal string _indexing_delete_total { get; set; } + + [JsonProperty("indexing.index_current")] + internal string _indexing_index_current { get; set; } + + [JsonProperty("indexing.index_time")] + internal string _indexing_index_time { get; set; } + + [JsonProperty("indexing.index_total")] + internal string _indexing_index_total { get; set; } + + [JsonProperty("indexingDeleteCurrent")] + internal string _indexingDeleteCurrent { get; set; } + + [JsonProperty("indexingDeleteTime")] + internal string _indexingDeleteTime { get; set; } + + [JsonProperty("indexingDeleteTotal")] + internal string _indexingDeleteTotal { get; set; } + + [JsonProperty("indexingIndexCurrent")] + internal string _indexingIndexCurrent { get; set; } + + [JsonProperty("indexingIndexTime")] + internal string _indexingIndexTime { get; set; } + [JsonProperty("indexingIndexTotal")] internal string _indexingIndexTotal { get; set; } - public string IndexingIndexTotal => this._indexingIndexTotal ?? this._iito ?? this._indexing_index_total; - [JsonProperty("merges.current")] - internal string _merges_current { get; set; } + [JsonProperty("ip")] + internal string _ip { get; set; } + + [JsonProperty("j")] + internal string _j { get; set; } + + [JsonProperty("jdk")] + internal string _jdk { get; set; } + + [JsonProperty("m")] + internal string _m { get; set; } + + [JsonProperty("master")] + internal string _master { get; set; } + [JsonProperty("mc")] internal string _mc { get; set; } - [JsonProperty("mergesCurrent")] - internal string _mergesCurrent { get; set; } - public string MergesCurrent => this._mergesCurrent ?? this._mc ?? this._merges_current; - [JsonProperty("merges.current_docs")] - internal string _merges_current_docs { get; set; } [JsonProperty("mcd")] internal string _mcd { get; set; } - [JsonProperty("mergesCurrentDocs")] - internal string _mergesCurrentDocs { get; set; } - public string MergesCurrentDocs => this._mergesCurrentDocs ?? this._mcd ?? this._merges_current_docs; - [JsonProperty("merges.current_size")] - internal string _merges_current_size { get; set; } [JsonProperty("mcs")] internal string _mcs { get; set; } + + [JsonProperty("merges.current")] + internal string _merges_current { get; set; } + + [JsonProperty("merges.current_docs")] + internal string _merges_current_docs { get; set; } + + [JsonProperty("merges.current_size")] + internal string _merges_current_size { get; set; } + + [JsonProperty("merges.total")] + internal string _merges_total { get; set; } + + [JsonProperty("merges.total_docs")] + internal string _merges_total_docs { get; set; } + + [JsonProperty("merges.total_time")] + internal string _merges_total_time { get; set; } + + [JsonProperty("mergesCurrent")] + internal string _mergesCurrent { get; set; } + + [JsonProperty("mergesCurrentDocs")] + internal string _mergesCurrentDocs { get; set; } + [JsonProperty("mergesCurrentSize")] internal string _mergesCurrentSize { get; set; } - public string MergesCurrentSize => this._mergesCurrentSize ?? this._mcs ?? this._merges_current_size; - [JsonProperty("merges.total")] - internal string _merges_total { get; set; } + [JsonProperty("mergesTotal")] + internal string _mergesTotal { get; set; } + + [JsonProperty("mergesTotalDocs")] + internal string _mergesTotalDocs { get; set; } + + [JsonProperty("mergesTotalTime")] + internal string _mergesTotalTime { get; set; } + [JsonProperty("mt")] internal string _mt { get; set; } - [JsonProperty("mergesTotal")] - internal string _mergesTotal { get; set; } - public string MergesTotal => this._mergesTotal ?? this._mt ?? this._merges_total; - [JsonProperty("merges.total_docs")] - internal string _merges_total_docs { get; set; } [JsonProperty("mtd")] internal string _mtd { get; set; } - [JsonProperty("mergesTotalDocs")] - internal string _mergesTotalDocs { get; set; } - public string MergesTotalDocs => this._mergesTotalDocs ?? this._mtd ?? this._merges_total_docs; - [JsonProperty("merges.total_time")] - internal string _merges_total_time { get; set; } [JsonProperty("mtt")] internal string _mtt { get; set; } - [JsonProperty("mergesTotalTime")] - internal string _mergesTotalTime { get; set; } - public string MergesTotalTime => this._mergesTotalTime ?? this._mtt ?? this._merges_total_time; - [JsonProperty("percolate.current")] - internal string _percolate_current { get; set; } + [JsonProperty("n")] + internal string _n { get; set; } + + [JsonProperty("name")] + internal string _name { get; set; } + + [JsonProperty("node.role")] + internal string _node_role { get; set; } + + [JsonProperty("nodeId")] + internal string _nodeId { get; set; } + + [JsonProperty("nodeRole")] + internal string _nodeRole { get; set; } + + [JsonProperty("p")] + internal string _p { get; set; } + [JsonProperty("pc")] internal string _pc { get; set; } - [JsonProperty("percolateCurrent")] - internal string _percolateCurrent { get; set; } - public string PercolateCurrent => this._percolateCurrent ?? this._pc ?? this._percolate_current; + + [JsonProperty("percolate.current")] + internal string _percolate_current { get; set; } [JsonProperty("percolate.memory_size")] internal string _percolate_memory_size { get; set; } - [JsonProperty("pm")] - internal string _pm { get; set; } - [JsonProperty("percolateMemory")] - internal string _percolateMemory { get; set; } - public string PercolateMemory => this._percolateMemory ?? this._pm ?? this._percolate_memory_size; [JsonProperty("percolate.queries")] internal string _percolate_queries { get; set; } - [JsonProperty("pq")] - internal string _pq { get; set; } - [JsonProperty("percolateQueries")] - internal string _percolateQueries { get; set; } - public string PercolateQueries => this._percolate_queries ?? this._pq ?? this._percolate_queries; [JsonProperty("percolate.time")] internal string _percolate_time { get; set; } - [JsonProperty("pti")] - internal string _pti { get; set; } - [JsonProperty("percolateTime")] - internal string _percolateTime { get; set; } - public string PercolateTime => this._percolateTime ?? this._pti ?? this._percolate_time; [JsonProperty("percolate.total")] internal string _percolate_total { get; set; } - [JsonProperty("pto")] - internal string _pto { get; set; } + + [JsonProperty("percolateCurrent")] + internal string _percolateCurrent { get; set; } + + [JsonProperty("percolateMemory")] + internal string _percolateMemory { get; set; } + + [JsonProperty("percolateQueries")] + internal string _percolateQueries { get; set; } + + [JsonProperty("percolateTime")] + internal string _percolateTime { get; set; } + [JsonProperty("percolateTotal")] internal string _percolateTotal { get; set; } - public string PercolateTotal => this._percolateTotal ?? this._pto ?? this._percolate_total; + + [JsonProperty("pid")] + internal string _pid { get; set; } + + [JsonProperty("pm")] + internal string _pm { get; set; } + + [JsonProperty("po")] + internal string _po { get; set; } + + [JsonProperty("port")] + internal string _port { get; set; } + + [JsonProperty("pq")] + internal string _pq { get; set; } + + [JsonProperty("pti")] + internal string _pti { get; set; } + + [JsonProperty("pto")] + internal string _pto { get; set; } + + [JsonProperty("r")] + internal string _r { get; set; } + + [JsonProperty("ram.current")] + internal string _ram_current { get; set; } + + [JsonProperty("ram.max")] + internal string _ram_max { get; set; } + + [JsonProperty("ram.percent")] + internal string _ram_percent { get; set; } + + [JsonProperty("ramCurrent")] + internal string _ramCurrent { get; set; } + + [JsonProperty("ramMax")] + internal string _ramMax { get; set; } + + [JsonProperty("ramPercent")] + internal string _ramPercent { get; set; } + + [JsonProperty("rc")] + internal string _rc { get; set; } + + [JsonProperty("refresh.time")] + internal string _refresh_time { get; set; } [JsonProperty("refresh.total")] internal string _refresh_total { get; set; } - [JsonProperty("rto")] - internal string _rto { get; set; } + + [JsonProperty("refreshTime")] + internal string _refreshTime { get; set; } + [JsonProperty("refreshTotal")] internal string _refreshTotal { get; set; } - public string RefreshTotal => this._refreshTotal ?? this._rto ?? this._refresh_total; - [JsonProperty("refresh.time")] - internal string _refresh_time { get; set; } + [JsonProperty("rm")] + internal string _rm { get; set; } + + [JsonProperty("rp")] + internal string _rp { get; set; } + [JsonProperty("rti")] internal string _rti { get; set; } - [JsonProperty("refreshTime")] - internal string _refreshTime { get; set; } - public string RefreshTime => this._refreshTime ?? this._rti ?? this._refreshTime; + + [JsonProperty("rto")] + internal string _rto { get; set; } + + [JsonProperty("sc")] + internal string _sc { get; set; } [JsonProperty("search.fetch_current")] internal string _search_fetch_current { get; set; } - [JsonProperty("sfc")] - internal string _sfc { get; set; } - [JsonProperty("searchFetchCurrent")] - internal string _searchFetchCurrent { get; set; } - public string SearchFetchCurrent => this._searchFetchCurrent ?? this._sfc ?? this._search_fetch_current; [JsonProperty("search.fetch_time")] internal string _search_fetch_time { get; set; } - [JsonProperty("sfti")] - internal string _sfti { get; set; } - [JsonProperty("searchFetchTime")] - internal string _searchFetchTime { get; set; } - public string SearchFetchTime => this._searchFetchTime ?? this._sfti ?? this._search_fetch_time; [JsonProperty("search.fetch_total")] internal string _search_fetch_total { get; set; } - [JsonProperty("sfto")] - internal string _sfto { get; set; } - [JsonProperty("searchFetchTotal")] - internal string _searchFetchTotal { get; set; } - public string SearchFetchTotal => this._searchFetchTotal ?? this._sfto ?? this._searchFetchTotal; [JsonProperty("search.open_contexts")] internal string _search_open_contexts { get; set; } - [JsonProperty("so")] - internal string _so { get; set; } - [JsonProperty("searchOpenContexts")] - internal string _searchOpenContexts { get; set; } - public string SearchOpenContexts => this._searchOpenContexts ?? this._so ?? this._search_open_contexts; [JsonProperty("search.query_current")] internal string _search_query_current { get; set; } - [JsonProperty("sqc")] - internal string _sqc { get; set; } - [JsonProperty("searchQueryCurrent")] - internal string _searchQueryCurrent { get; set; } - public string SearchQueryCurrent => this._searchQueryCurrent ?? this._sqc ?? this._search_query_current; [JsonProperty("search.query_time")] internal string _search_query_time { get; set; } - [JsonProperty("sqti")] - internal string _sqti { get; set; } - [JsonProperty("searchQueryTime")] - internal string _searchQueryTime { get; set; } - public string SearchQueryTime => this._searchQueryTime ?? this._sqti ?? this._search_query_time; [JsonProperty("search.query_total")] internal string _search_query_total { get; set; } - [JsonProperty("sqto")] - internal string _sqto { get; set; } + + [JsonProperty("searchFetchCurrent")] + internal string _searchFetchCurrent { get; set; } + + [JsonProperty("searchFetchTime")] + internal string _searchFetchTime { get; set; } + + [JsonProperty("searchFetchTotal")] + internal string _searchFetchTotal { get; set; } + + [JsonProperty("searchOpenContexts")] + internal string _searchOpenContexts { get; set; } + + [JsonProperty("searchQueryCurrent")] + internal string _searchQueryCurrent { get; set; } + + [JsonProperty("searchQueryTime")] + internal string _searchQueryTime { get; set; } + [JsonProperty("searchQueryTotal")] internal string _searchQueryTotal { get; set; } - public string SearchQueryTotal => this._searchQueryTotal ?? this._sqto ?? this._search_query_total; [JsonProperty("segments.count")] internal string _segments_count { get; set; } - [JsonProperty("sc")] - internal string _sc { get; set; } - [JsonProperty("segmentsCount")] - internal string _segmentsCount { get; set; } - public string SegmentsCount => this._segmentsCount ?? this._sc ?? this._segmentsCount; + + [JsonProperty("segments.index_writer_max_memory")] + internal string _segments_index_writer_max_memory { get; set; } + + [JsonProperty("segments.index_writer_memory")] + internal string _segments_index_writer_memory { get; set; } [JsonProperty("segments.memory")] internal string _segments_memory { get; set; } - [JsonProperty("sm")] - internal string _sm { get; set; } + + [JsonProperty("segments.version_map_memory")] + internal string _segments_version_map_memory { get; set; } + + [JsonProperty("segmentsCount")] + internal string _segmentsCount { get; set; } + + [JsonProperty("segmentsIndexWriterMaxMemory")] + internal string _segmentsIndexWriterMaxMemory { get; set; } + + [JsonProperty("segmentsIndexWriterMemory")] + internal string _segmentsIndexWriterMemory { get; set; } + [JsonProperty("segmentsMemory")] internal string _segmentsMemory { get; set; } - public string SegmentsMemory => this._segmentsMemory ?? this._sm ?? this._segments_memory; - [JsonProperty("segments.index_writer_memory")] - internal string _segments_index_writer_memory { get; set; } + [JsonProperty("segmentsVersionMapMemory")] + internal string _segmentsVersionMapMemory { get; set; } + + [JsonProperty("sfc")] + internal string _sfc { get; set; } + + [JsonProperty("sfti")] + internal string _sfti { get; set; } + + [JsonProperty("sfto")] + internal string _sfto { get; set; } + [JsonProperty("siwm")] internal string _siwm { get; set; } - [JsonProperty("segmentsIndexWriterMemory")] - internal string _segmentsIndexWriterMemory { get; set; } - public string SegmentsIndexWriterMemory => this._segmentsIndexWriterMemory ?? this._siwm ?? this._segments_index_writer_memory; - [JsonProperty("segments.index_writer_max_memory")] - internal string _segments_index_writer_max_memory { get; set; } [JsonProperty("siwmx")] internal string _siwmx { get; set; } - [JsonProperty("segmentsIndexWriterMaxMemory")] - internal string _segmentsIndexWriterMaxMemory { get; set; } - public string SegmentsIndexWriterMaxMemory => this._segmentsIndexWriterMaxMemory ?? this._siwmx ?? this._segments_index_writer_max_memory; - [JsonProperty("segments.version_map_memory")] - internal string _segments_version_map_memory { get; set; } + [JsonProperty("sm")] + internal string _sm { get; set; } + + [JsonProperty("so")] + internal string _so { get; set; } + + [JsonProperty("sqc")] + internal string _sqc { get; set; } + + [JsonProperty("sqti")] + internal string _sqti { get; set; } + + [JsonProperty("sqto")] + internal string _sqto { get; set; } + [JsonProperty("svmm")] internal string _svmm { get; set; } - [JsonProperty("segmentsVersionMapMemory")] - internal string _segmentsVersionMapMemory { get; set; } - public string SegmentsVersionMapMemory => this._segmentsVersionMapMemory ?? this._svmm ?? this._segments_version_map_memory; + + [JsonProperty("u")] + internal string _u { get; set; } + + [JsonProperty("uptime")] + internal string _uptime { get; set; } + + [JsonProperty("v")] + internal string _v { get; set; } + + [JsonProperty("version")] + internal string _version { get; set; } } } diff --git a/src/Nest/Cat/CatNodes/ElasticClient-CatNodes.cs b/src/Nest/Cat/CatNodes/ElasticClient-CatNodes.cs index 513ef6f0756..c5c28690b29 100644 --- a/src/Nest/Cat/CatNodes/ElasticClient-CatNodes.cs +++ b/src/Nest/Cat/CatNodes/ElasticClient-CatNodes.cs @@ -1,42 +1,49 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatNodes(Func selector = null); - /// + /// ICatResponse CatNodes(ICatNodesRequest request); - /// - Task> CatNodesAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatNodesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task> CatNodesAsync(ICatNodesRequest request, CancellationToken cancellationToken = default(CancellationToken)); - } public partial class ElasticClient { - /// + /// public ICatResponse CatNodes(Func selector = null) => - this.CatNodes(selector.InvokeOrDefault(new CatNodesDescriptor())); - - /// - public ICatResponse CatNodes(ICatNodesRequest request)=> - this.DoCat(request, this.LowLevelDispatch.CatNodesDispatch>); - - /// - public Task> CatNodesAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.CatNodesAsync(selector.InvokeOrDefault(new CatNodesDescriptor()), cancellationToken); - - /// - public Task> CatNodesAsync(ICatNodesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatNodesDispatchAsync>); + CatNodes(selector.InvokeOrDefault(new CatNodesDescriptor())); + + /// + public ICatResponse CatNodes(ICatNodesRequest request) => + DoCat(request, + LowLevelDispatch.CatNodesDispatch>); + + /// + public Task> CatNodesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + CatNodesAsync(selector.InvokeOrDefault(new CatNodesDescriptor()), cancellationToken); + + /// + public Task> CatNodesAsync(ICatNodesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatNodesDispatchAsync>); } } diff --git a/src/Nest/Cat/CatPendingTasks/CatPendingTasksRecord.cs b/src/Nest/Cat/CatPendingTasks/CatPendingTasksRecord.cs index b29a4c82665..63db30b72af 100644 --- a/src/Nest/Cat/CatPendingTasks/CatPendingTasksRecord.cs +++ b/src/Nest/Cat/CatPendingTasks/CatPendingTasksRecord.cs @@ -8,14 +8,13 @@ public class CatPendingTasksRecord : ICatRecord [JsonProperty("insertOrder")] public int? InsertOrder { get; set; } - [JsonProperty("timeInQueue")] - public string TimeInQueue { get; set; } - [JsonProperty("priority")] public string Priority { get; set; } [JsonProperty("source")] public string Source { get; set; } + [JsonProperty("timeInQueue")] + public string TimeInQueue { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatPendingTasks/ElasticClient-CatPendingTasks.cs b/src/Nest/Cat/CatPendingTasks/ElasticClient-CatPendingTasks.cs index 07b423cf1ca..e790d5862ed 100644 --- a/src/Nest/Cat/CatPendingTasks/ElasticClient-CatPendingTasks.cs +++ b/src/Nest/Cat/CatPendingTasks/ElasticClient-CatPendingTasks.cs @@ -1,46 +1,52 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatPendingTasks(Func selector = null); - /// + /// ICatResponse CatPendingTasks(ICatPendingTasksRequest request); - /// + /// Task> CatPendingTasksAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatPendingTasksAsync(ICatPendingTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatPendingTasksAsync(ICatPendingTasksRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatPendingTasks(Func selector = null) => - this.CatPendingTasks(selector.InvokeOrDefault(new CatPendingTasksDescriptor())); + CatPendingTasks(selector.InvokeOrDefault(new CatPendingTasksDescriptor())); - /// + /// public ICatResponse CatPendingTasks(ICatPendingTasksRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatPendingTasksDispatch>); + DoCat(request, + LowLevelDispatch.CatPendingTasksDispatch>); - /// + /// public Task> CatPendingTasksAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatPendingTasksAsync(selector.InvokeOrDefault(new CatPendingTasksDescriptor()), cancellationToken); + ) => CatPendingTasksAsync(selector.InvokeOrDefault(new CatPendingTasksDescriptor()), cancellationToken); - /// - public Task> CatPendingTasksAsync(ICatPendingTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatPendingTasksDispatchAsync>); + /// + public Task> CatPendingTasksAsync(ICatPendingTasksRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatPendingTasksDispatchAsync>); } } diff --git a/src/Nest/Cat/CatPlugins/CatPluginsRecord.cs b/src/Nest/Cat/CatPlugins/CatPluginsRecord.cs index d0b245315ac..2f62769676f 100644 --- a/src/Nest/Cat/CatPlugins/CatPluginsRecord.cs +++ b/src/Nest/Cat/CatPlugins/CatPluginsRecord.cs @@ -5,28 +5,28 @@ namespace Nest [JsonObject] public class CatPluginsRecord : ICatRecord { - [JsonProperty("id")] - public string Id { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - [JsonProperty("component")] public string Component { get; set; } - [JsonProperty("version")] - public string Version { get; set; } + [JsonProperty("description")] + public string Description { get; set; } - [JsonProperty("type")] - public string Type { get; set; } + [JsonProperty("id")] + public string Id { get; set; } [JsonProperty("isolation")] public string Isolation { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + [JsonProperty("url")] public string Url { get; set; } - [JsonProperty("description")] - public string Description { get; set; } + [JsonProperty("version")] + public string Version { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatPlugins/ElasticClient-CatPlugins.cs b/src/Nest/Cat/CatPlugins/ElasticClient-CatPlugins.cs index 4a61325bd09..1c8e1d00d15 100644 --- a/src/Nest/Cat/CatPlugins/ElasticClient-CatPlugins.cs +++ b/src/Nest/Cat/CatPlugins/ElasticClient-CatPlugins.cs @@ -1,43 +1,49 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatPlugins(Func selector = null); - /// + /// ICatResponse CatPlugins(ICatPluginsRequest request); - /// - Task> CatPluginsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - Task> CatPluginsAsync(ICatPluginsRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatPluginsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); + /// + Task> CatPluginsAsync(ICatPluginsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatPlugins(Func selector = null) => - this.CatPlugins(selector.InvokeOrDefault(new CatPluginsDescriptor())); + CatPlugins(selector.InvokeOrDefault(new CatPluginsDescriptor())); - /// + /// public ICatResponse CatPlugins(ICatPluginsRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatPluginsDispatch>); + DoCat(request, + LowLevelDispatch.CatPluginsDispatch>); - /// + /// public Task> CatPluginsAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatPluginsAsync(selector.InvokeOrDefault(new CatPluginsDescriptor()), cancellationToken); - - public Task> CatPluginsAsync(ICatPluginsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatPluginsDispatchAsync>); + ) => CatPluginsAsync(selector.InvokeOrDefault(new CatPluginsDescriptor()), cancellationToken); + public Task> CatPluginsAsync(ICatPluginsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatPluginsDispatchAsync>); } } diff --git a/src/Nest/Cat/CatRecovery/CatRecoveryRecord.cs b/src/Nest/Cat/CatRecovery/CatRecoveryRecord.cs index 5d138e69a65..627e128490e 100644 --- a/src/Nest/Cat/CatRecovery/CatRecoveryRecord.cs +++ b/src/Nest/Cat/CatRecovery/CatRecoveryRecord.cs @@ -5,62 +5,59 @@ namespace Nest [JsonObject] public class CatRecoveryRecord : ICatRecord { - [JsonProperty("index")] - public string Index { get; set; } + [JsonProperty("bytes")] + public string Bytes { get; set; } - [JsonProperty("shard")] - public string Shard { get; set; } + [JsonProperty("bytes_percent")] + public string BytesPercent { get; set; } - [JsonProperty("time")] - public string Time { get; set; } + [JsonProperty("bytes_recovered")] + public string BytesRecovered { get; set; } - [JsonProperty("type")] - public string Type { get; set; } + [JsonProperty("bytes_total")] + public string BytesTotal { get; set; } - [JsonProperty("stage")] - public string Stage { get; set; } + [JsonProperty("files")] + public string Files { get; set; } - [JsonProperty("source_host")] - public string SourceHost { get; set; } + [JsonProperty("files_percent")] + public string FilesPercent { get; set; } - [JsonProperty("source_node")] - public string SourceNode { get; set; } + [JsonProperty("files_recovered")] + public string FilesRecovered { get; set; } - [JsonProperty("target_host")] - public string TargetHost { get; set; } + [JsonProperty("files_total")] + public string FilesTotal { get; set; } - [JsonProperty("target_node")] - public string TargetNode { get; set; } + [JsonProperty("index")] + public string Index { get; set; } [JsonProperty("repository")] public string Repository { get; set; } + [JsonProperty("shard")] + public string Shard { get; set; } + [JsonProperty("snapshot")] public string Snapshot { get; set; } - [JsonProperty("files")] - public string Files { get; set; } - - [JsonProperty("files_recovered")] - public string FilesRecovered { get; set; } - - [JsonProperty("files_percent")] - public string FilesPercent { get; set; } + [JsonProperty("source_host")] + public string SourceHost { get; set; } - [JsonProperty("files_total")] - public string FilesTotal { get; set; } + [JsonProperty("source_node")] + public string SourceNode { get; set; } - [JsonProperty("bytes")] - public string Bytes { get; set; } + [JsonProperty("stage")] + public string Stage { get; set; } - [JsonProperty("bytes_recovered")] - public string BytesRecovered { get; set; } + [JsonProperty("target_host")] + public string TargetHost { get; set; } - [JsonProperty("bytes_percent")] - public string BytesPercent { get; set; } + [JsonProperty("target_node")] + public string TargetNode { get; set; } - [JsonProperty("bytes_total")] - public string BytesTotal { get; set; } + [JsonProperty("time")] + public string Time { get; set; } [JsonProperty("translog_ops")] public long? TranslogOps { get; set; } @@ -70,5 +67,8 @@ public class CatRecoveryRecord : ICatRecord [JsonProperty("translog_ops_recovered")] public long? TranslogOpsRecovered { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } } } diff --git a/src/Nest/Cat/CatRecovery/ElasticClient-CatRecovery.cs b/src/Nest/Cat/CatRecovery/ElasticClient-CatRecovery.cs index a168532f45e..b18e1fd0438 100644 --- a/src/Nest/Cat/CatRecovery/ElasticClient-CatRecovery.cs +++ b/src/Nest/Cat/CatRecovery/ElasticClient-CatRecovery.cs @@ -1,47 +1,53 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatRecovery(Func selector = null); - /// + /// ICatResponse CatRecovery(ICatRecoveryRequest request); - /// + /// Task> CatRecoveryAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatRecoveryAsync(ICatRecoveryRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatRecoveryAsync(ICatRecoveryRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatRecovery(Func selector = null) => - this.CatRecovery(selector.InvokeOrDefault(new CatRecoveryDescriptor())); + CatRecovery(selector.InvokeOrDefault(new CatRecoveryDescriptor())); - /// + /// public ICatResponse CatRecovery(ICatRecoveryRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatRecoveryDispatch>); + DoCat(request, + LowLevelDispatch.CatRecoveryDispatch>); - /// + /// public Task> CatRecoveryAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatRecoveryAsync(selector.InvokeOrDefault(new CatRecoveryDescriptor()), cancellationToken); + ) => CatRecoveryAsync(selector.InvokeOrDefault(new CatRecoveryDescriptor()), cancellationToken); - /// - public Task> CatRecoveryAsync(ICatRecoveryRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatRecoveryDispatchAsync>); + /// + public Task> CatRecoveryAsync(ICatRecoveryRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatRecoveryDispatchAsync>); } } diff --git a/src/Nest/Cat/CatRepositories/ElasticClient-CatRepositories.cs b/src/Nest/Cat/CatRepositories/ElasticClient-CatRepositories.cs index e2995346e15..51fe56a8605 100644 --- a/src/Nest/Cat/CatRepositories/ElasticClient-CatRepositories.cs +++ b/src/Nest/Cat/CatRepositories/ElasticClient-CatRepositories.cs @@ -1,48 +1,52 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatRepositories(Func selector = null); - /// + /// ICatResponse CatRepositories(ICatRepositoriesRequest request); - /// + /// Task> CatRepositoriesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatRepositoriesAsync(ICatRepositoriesRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatRepositoriesAsync(ICatRepositoriesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatRepositories(Func selector = null) => - this.CatRepositories(selector.InvokeOrDefault(new CatRepositoriesDescriptor())); + CatRepositories(selector.InvokeOrDefault(new CatRepositoriesDescriptor())); - /// + /// public ICatResponse CatRepositories(ICatRepositoriesRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatRepositoriesDispatch>); + DoCat(request, + LowLevelDispatch.CatRepositoriesDispatch>); - /// + /// public Task> CatRepositoriesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatRepositoriesAsync(selector.InvokeOrDefault(new CatRepositoriesDescriptor()), cancellationToken); - - /// - public Task> CatRepositoriesAsync(ICatRepositoriesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatRepositoriesDispatchAsync>); + ) => CatRepositoriesAsync(selector.InvokeOrDefault(new CatRepositoriesDescriptor()), cancellationToken); + /// + public Task> CatRepositoriesAsync(ICatRepositoriesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatRepositoriesDispatchAsync>); } } diff --git a/src/Nest/Cat/CatResponse.cs b/src/Nest/Cat/CatResponse.cs index dbbda524a89..195bf8c1293 100644 --- a/src/Nest/Cat/CatResponse.cs +++ b/src/Nest/Cat/CatResponse.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using Newtonsoft.Json; namespace Nest diff --git a/src/Nest/Cat/CatSegments/CatSegmentsRecord.cs b/src/Nest/Cat/CatSegments/CatSegmentsRecord.cs index 1fd09d04e2a..c1c0bbb0451 100644 --- a/src/Nest/Cat/CatSegments/CatSegmentsRecord.cs +++ b/src/Nest/Cat/CatSegments/CatSegmentsRecord.cs @@ -5,32 +5,41 @@ namespace Nest [JsonObject] public class CatSegmentsRecord : ICatRecord { + [JsonProperty("committed")] + public string Committed { get; set; } + + [JsonProperty("compound")] + public string Compound { get; set; } + + [JsonProperty("docs.count")] + public string DocsCount { get; set; } + + [JsonProperty("docs.deleted")] + public string DocsDeleted { get; set; } + + [JsonProperty("generation")] + public string Generation { get; set; } + + [JsonProperty("id")] + public string Id { get; set; } + [JsonProperty("index")] public string Index { get; set; } - [JsonProperty("shard")] - public string Shard { get; set; } - - [JsonProperty("prirep")] - public string PrimaryReplica { get; set; } - [JsonProperty("ip")] public string Ip { get; set; } - [JsonProperty("id")] - public string Id { get; set; } + [JsonProperty("prirep")] + public string PrimaryReplica { get; set; } + + [JsonProperty("searchable")] + public string Searchable { get; set; } [JsonProperty("segment")] public string Segment { get; set; } - [JsonProperty("generation")] - public string Generation { get; set; } - - [JsonProperty("docs.count")] - public string DocsCount { get; set; } - - [JsonProperty("docs.deleted")] - public string DocsDeleted { get; set; } + [JsonProperty("shard")] + public string Shard { get; set; } [JsonProperty("size")] public string Size { get; set; } @@ -38,16 +47,7 @@ public class CatSegmentsRecord : ICatRecord [JsonProperty("size.memory")] public string SizeMemory { get; set; } - [JsonProperty("committed")] - public string Committed { get; set; } - - [JsonProperty("searchable")] - public string Searchable { get; set; } - [JsonProperty("version")] public string Version { get; set; } - - [JsonProperty("compound")] - public string Compound { get; set; } } } diff --git a/src/Nest/Cat/CatSegments/ElasticClient-CatSegments.cs b/src/Nest/Cat/CatSegments/ElasticClient-CatSegments.cs index 4f4d9088c20..01b392b51a5 100644 --- a/src/Nest/Cat/CatSegments/ElasticClient-CatSegments.cs +++ b/src/Nest/Cat/CatSegments/ElasticClient-CatSegments.cs @@ -1,48 +1,52 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatSegments(Func selector = null); - /// + /// ICatResponse CatSegments(ICatSegmentsRequest request); - /// + /// Task> CatSegmentsAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatSegmentsAsync(ICatSegmentsRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatSegmentsAsync(ICatSegmentsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatSegments(Func selector = null) => - this.CatSegments(selector.InvokeOrDefault(new CatSegmentsDescriptor())); + CatSegments(selector.InvokeOrDefault(new CatSegmentsDescriptor())); - /// + /// public ICatResponse CatSegments(ICatSegmentsRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatSegmentsDispatch>); + DoCat(request, + LowLevelDispatch.CatSegmentsDispatch>); - /// + /// public Task> CatSegmentsAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatSegmentsAsync(selector.InvokeOrDefault(new CatSegmentsDescriptor()), cancellationToken); - - /// - public Task> CatSegmentsAsync(ICatSegmentsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatSegmentsDispatchAsync>); + ) => CatSegmentsAsync(selector.InvokeOrDefault(new CatSegmentsDescriptor()), cancellationToken); + /// + public Task> CatSegmentsAsync(ICatSegmentsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatSegmentsDispatchAsync>); } } diff --git a/src/Nest/Cat/CatShards/CatShardsRecord.cs b/src/Nest/Cat/CatShards/CatShardsRecord.cs index ae6b2862264..404a157d113 100644 --- a/src/Nest/Cat/CatShards/CatShardsRecord.cs +++ b/src/Nest/Cat/CatShards/CatShardsRecord.cs @@ -5,45 +5,21 @@ namespace Nest [JsonObject] public class CatShardsRecord : ICatRecord { - [JsonProperty("index")] - public string Index { get; set; } - - [JsonProperty("shard")] - public string Shard { get; set; } - - [JsonProperty("prirep")] - public string PrimaryOrReplica { get; set; } - - [JsonProperty("state")] - public string State { get; set; } + [JsonProperty("completion.size")] + public string CompletionSize { get; set; } [JsonProperty("docs")] public string Docs { get; set; } - [JsonProperty("store")] - public string Store { get; set; } - - [JsonProperty("ip")] - public string Ip { get; set; } - - [JsonProperty("id")] - public string Id { get; set; } - - [JsonProperty("node")] - public string Node { get; set; } - - [JsonProperty("completion.size")] - public string CompletionSize { get; set; } + [JsonProperty("fielddata.evictions")] + public string FielddataEvictions { get; set; } [JsonProperty("fielddata.memory_size")] public string FielddataMemorySize { get; set; } - [JsonProperty("fielddata.evictions")] - public string FielddataEvictions { get; set; } - [JsonProperty("filter_cache.memory_size")] public string FilterCacheMemorySize { get; set; } - + [JsonProperty("flush.total")] public string FlushTotal { get; set; } @@ -53,12 +29,6 @@ public class CatShardsRecord : ICatRecord [JsonProperty("get.current")] public string GetCurrent { get; set; } - [JsonProperty("get.time")] - public string GetTime { get; set; } - - [JsonProperty("get.total")] - public string GetTotal { get; set; } - [JsonProperty("get.exists_time")] public string GetExistsTime { get; set; } @@ -71,9 +41,21 @@ public class CatShardsRecord : ICatRecord [JsonProperty("get.missing_total")] public string GetMissingTotal { get; set; } + [JsonProperty("get.time")] + public string GetTime { get; set; } + + [JsonProperty("get.total")] + public string GetTotal { get; set; } + + [JsonProperty("id")] + public string Id { get; set; } + [JsonProperty("id_cache.memory_size")] public string IdCacheMemorySize { get; set; } + [JsonProperty("index")] + public string Index { get; set; } + [JsonProperty("indexing.delete_current")] public string IndexingDeleteCurrent { get; set; } @@ -92,6 +74,9 @@ public class CatShardsRecord : ICatRecord [JsonProperty("indexing.index_total")] public string IndexingIndexTotal { get; set; } + [JsonProperty("ip")] + public string Ip { get; set; } + [JsonProperty("merges.current")] public string MergesCurrent { get; set; } @@ -100,83 +85,98 @@ public class CatShardsRecord : ICatRecord [JsonProperty("merges.current_size")] public string MergesCurrentSize { get; set; } - + [JsonProperty("merges.total_docs")] public string MergesTotalDocs { get; set; } - + [JsonProperty("merges.total_size")] public string MergesTotalSize { get; set; } - + [JsonProperty("merges.total_time")] public string MergesTotalTime { get; set; } - + + [JsonProperty("node")] + public string Node { get; set; } + [JsonProperty("percolate.current")] public string PercolateCurrent { get; set; } - + [JsonProperty("percolate.memory_size")] public string PercolateMemorySize { get; set; } - + [JsonProperty("percolate.queries")] public string PercolateQueries { get; set; } - + [JsonProperty("percolate.time")] public string PercolateTime { get; set; } - + [JsonProperty("percolate.total")] public string PercolateTotal { get; set; } - - [JsonProperty("refresh.total")] - public string RefreshTotal { get; set; } - + + [JsonProperty("prirep")] + public string PrimaryOrReplica { get; set; } + [JsonProperty("refresh.time")] public string RefreshTime { get; set; } - + + [JsonProperty("refresh.total")] + public string RefreshTotal { get; set; } + [JsonProperty("search.fetch_current")] public string SearchFetchCurrent { get; set; } - + [JsonProperty("search.fetch_time")] public string SearchFetchTime { get; set; } - + [JsonProperty("search.fetch_total")] public string SearchFetchTotal { get; set; } - + [JsonProperty("search.open_contexts")] public string SearchOpenContexts { get; set; } - + [JsonProperty("search.query_current")] public string SearchQueryCurrent { get; set; } - + [JsonProperty("search.query_time")] public string SearchQueryTime { get; set; } - + [JsonProperty("search.query_total")] public string SearchQueryTotal { get; set; } - + [JsonProperty("segments.count")] public string SegmentsCount { get; set; } - - [JsonProperty("segments.memory")] - public string SegmentsMemory { get; set; } - - [JsonProperty("segments.index_writer_memory")] - public string SegmentsIndexWriterMemory { get; set; } - + + [JsonProperty("segments.fixed_bitset_memory")] + public string SegmentsFixedBitsetMemory { get; set; } + [JsonProperty("segments.index_writer_max_memory")] public string SegmentsIndexWriterMaxMemory { get; set; } - + + [JsonProperty("segments.index_writer_memory")] + public string SegmentsIndexWriterMemory { get; set; } + + [JsonProperty("segments.memory")] + public string SegmentsMemory { get; set; } + [JsonProperty("segments.version_map_memory")] public string SegmentsVersionMapMemory { get; set; } - - [JsonProperty("segments.fixed_bitset_memory")] - public string SegmentsFixedBitsetMemory { get; set; } - + + [JsonProperty("shard")] + public string Shard { get; set; } + + [JsonProperty("state")] + public string State { get; set; } + + [JsonProperty("store")] + public string Store { get; set; } + [JsonProperty("warmer.current")] public string WarmerCurrent { get; set; } - + [JsonProperty("warmer.total")] public string WarmerTotal { get; set; } - + [JsonProperty("warmer.total_time")] public string WarmerTotalTime { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cat/CatShards/CatShardsRequest.cs b/src/Nest/Cat/CatShards/CatShardsRequest.cs index 9e1ac58ac4d..6de13678b04 100644 --- a/src/Nest/Cat/CatShards/CatShardsRequest.cs +++ b/src/Nest/Cat/CatShards/CatShardsRequest.cs @@ -1,7 +1,7 @@ namespace Nest { public partial interface ICatShardsRequest { } - + public partial class CatShardsRequest { } public partial class CatShardsDescriptor { } diff --git a/src/Nest/Cat/CatShards/ElasticClient-CatShards.cs b/src/Nest/Cat/CatShards/ElasticClient-CatShards.cs index c60224da132..485ecd6e6e9 100644 --- a/src/Nest/Cat/CatShards/ElasticClient-CatShards.cs +++ b/src/Nest/Cat/CatShards/ElasticClient-CatShards.cs @@ -1,41 +1,49 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatShards(Func selector = null); - /// + /// ICatResponse CatShards(ICatShardsRequest request); - /// - Task> CatShardsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatShardsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// - Task> CatShardsAsync(ICatShardsRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatShardsAsync(ICatShardsRequest request, CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatShards(Func selector = null) => - this.CatShards(selector.InvokeOrDefault(new CatShardsDescriptor())); + CatShards(selector.InvokeOrDefault(new CatShardsDescriptor())); - /// + /// public ICatResponse CatShards(ICatShardsRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatShardsDispatch>); - - /// - public Task> CatShardsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.CatShardsAsync(selector.InvokeOrDefault(new CatShardsDescriptor()), cancellationToken); - - public Task> CatShardsAsync(ICatShardsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatShardsDispatchAsync>); - + DoCat(request, + LowLevelDispatch.CatShardsDispatch>); + + /// + public Task> CatShardsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + CatShardsAsync(selector.InvokeOrDefault(new CatShardsDescriptor()), cancellationToken); + + public Task> CatShardsAsync(ICatShardsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatShardsDispatchAsync>); } } diff --git a/src/Nest/Cat/CatSnapshots/CatSnapshotsRecord.cs b/src/Nest/Cat/CatSnapshots/CatSnapshotsRecord.cs index 38ab9ea16b9..b2ef9fb82fe 100644 --- a/src/Nest/Cat/CatSnapshots/CatSnapshotsRecord.cs +++ b/src/Nest/Cat/CatSnapshots/CatSnapshotsRecord.cs @@ -5,12 +5,24 @@ namespace Nest [JsonObject] public class CatSnapshotsRecord : ICatRecord { + [JsonProperty("duration")] + public Time Duration { get; set; } + + [JsonProperty("end_epoch")] + public long EndEpoch { get; set; } + + [JsonProperty("end_time")] + public string EndTime { get; set; } + + [JsonProperty("failed_shards")] + public long FailedShards { get; set; } + // duration indices successful_shards failed_shards total_shards [JsonProperty("id")] public string Id { get; set; } - [JsonProperty("status")] - public string Status { get; set; } + [JsonProperty("indices")] + public long Indices { get; set; } [JsonProperty("start_epoch")] public long StartEpoch { get; set; } @@ -18,26 +30,13 @@ public class CatSnapshotsRecord : ICatRecord [JsonProperty("start_time")] public string StartTime { get; set; } - [JsonProperty("end_epoch")] - public long EndEpoch { get; set; } - - [JsonProperty("end_time")] - public string EndTime { get; set; } - - [JsonProperty("duration")] - public Time Duration { get; set; } - - [JsonProperty("indices")] - public long Indices { get; set; } + [JsonProperty("status")] + public string Status { get; set; } [JsonProperty("succesful_shards")] public long SuccesfulShards { get; set; } - [JsonProperty("failed_shards")] - public long FailedShards { get; set; } - [JsonProperty("total_shards")] public long TotalShards { get; set; } - } } diff --git a/src/Nest/Cat/CatSnapshots/ElasticClient-CatSnapshots.cs b/src/Nest/Cat/CatSnapshots/ElasticClient-CatSnapshots.cs index d774744bc81..d3833fe7f6b 100644 --- a/src/Nest/Cat/CatSnapshots/ElasticClient-CatSnapshots.cs +++ b/src/Nest/Cat/CatSnapshots/ElasticClient-CatSnapshots.cs @@ -1,50 +1,55 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatSnapshots(Names repositories, Func selector = null); - /// + /// ICatResponse CatSnapshots(ICatSnapshotsRequest request); - /// + /// Task> CatSnapshotsAsync( Names repositories, Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatSnapshotsAsync(ICatSnapshotsRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatSnapshotsAsync(ICatSnapshotsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// - public ICatResponse CatSnapshots(Names repositories, Func selector = null) => - this.CatSnapshots(selector.InvokeOrDefault(new CatSnapshotsDescriptor().RepositoryName(repositories))); + /// + public ICatResponse + CatSnapshots(Names repositories, Func selector = null) => + CatSnapshots(selector.InvokeOrDefault(new CatSnapshotsDescriptor().RepositoryName(repositories))); - /// + /// public ICatResponse CatSnapshots(ICatSnapshotsRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatSnapshotsDispatch>); + DoCat(request, + LowLevelDispatch.CatSnapshotsDispatch>); - /// + /// public Task> CatSnapshotsAsync( Names repositories, Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatSnapshotsAsync(selector.InvokeOrDefault(new CatSnapshotsDescriptor().RepositoryName(repositories)), cancellationToken); - - /// - public Task> CatSnapshotsAsync(ICatSnapshotsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatSnapshotsDispatchAsync>); + ) => CatSnapshotsAsync(selector.InvokeOrDefault(new CatSnapshotsDescriptor().RepositoryName(repositories)), cancellationToken); + /// + public Task> CatSnapshotsAsync(ICatSnapshotsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatSnapshotsDispatchAsync>); } } diff --git a/src/Nest/Cat/CatTasks/CatTasksRequest.cs b/src/Nest/Cat/CatTasks/CatTasksRequest.cs index 5d349e0669a..2189178c1c0 100644 --- a/src/Nest/Cat/CatTasks/CatTasksRequest.cs +++ b/src/Nest/Cat/CatTasks/CatTasksRequest.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Nest +namespace Nest { public partial interface ICatTasksRequest { } diff --git a/src/Nest/Cat/CatTasks/ElasticClient-CatTasks.cs b/src/Nest/Cat/CatTasks/ElasticClient-CatTasks.cs index d7f9c82eac4..112dcd55643 100644 --- a/src/Nest/Cat/CatTasks/ElasticClient-CatTasks.cs +++ b/src/Nest/Cat/CatTasks/ElasticClient-CatTasks.cs @@ -1,53 +1,54 @@ using System; -using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatTasks(Func selector = null); - /// + /// ICatResponse CatTasks(ICatTasksRequest request); - /// + /// Task> CatTasksAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// + /// Task> CatTasksAsync(ICatTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public ICatResponse CatTasks(Func selector = null) => - this.CatTasks(selector.InvokeOrDefault(new CatTasksDescriptor())); + CatTasks(selector.InvokeOrDefault(new CatTasksDescriptor())); - /// + /// public ICatResponse CatTasks(ICatTasksRequest request) => - this.DoCat( + DoCat( request, - this.LowLevelDispatch.CatTasksDispatch>); + LowLevelDispatch.CatTasksDispatch>); - /// + /// public Task> CatTasksAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatTasksAsync(selector.InvokeOrDefault(new CatTasksDescriptor())); + ) => CatTasksAsync(selector.InvokeOrDefault(new CatTasksDescriptor())); - /// - public Task> CatTasksAsync(ICatTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync( + /// + public Task> CatTasksAsync(ICatTasksRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync( request, cancellationToken, - this.LowLevelDispatch.CatTasksDispatchAsync> + LowLevelDispatch.CatTasksDispatchAsync> ); } } diff --git a/src/Nest/Cat/CatTemplates/CatTemplatesRecord.cs b/src/Nest/Cat/CatTemplates/CatTemplatesRecord.cs index c8bfcbcc38d..09618ee4925 100644 --- a/src/Nest/Cat/CatTemplates/CatTemplatesRecord.cs +++ b/src/Nest/Cat/CatTemplates/CatTemplatesRecord.cs @@ -1,18 +1,16 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { [JsonObject] public class CatTemplatesRecord : ICatRecord { - [JsonProperty("name")] - public string Name { get; set; } - [JsonProperty("index_patterns")] public string IndexPatterns { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("order")] public long Order { get; set; } diff --git a/src/Nest/Cat/CatTemplates/CatTemplatesRequest.cs b/src/Nest/Cat/CatTemplates/CatTemplatesRequest.cs index e9fcf6b00fc..3a86910d268 100644 --- a/src/Nest/Cat/CatTemplates/CatTemplatesRequest.cs +++ b/src/Nest/Cat/CatTemplates/CatTemplatesRequest.cs @@ -1,5 +1,4 @@ -using System; -#pragma warning disable 612, 618 +#pragma warning disable 612, 618 namespace Nest { diff --git a/src/Nest/Cat/CatTemplates/ElasticClient-CatTemplates.cs b/src/Nest/Cat/CatTemplates/ElasticClient-CatTemplates.cs index f391e8d1164..74ecfe2e3b3 100644 --- a/src/Nest/Cat/CatTemplates/ElasticClient-CatTemplates.cs +++ b/src/Nest/Cat/CatTemplates/ElasticClient-CatTemplates.cs @@ -1,48 +1,52 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatTemplates(Func selector = null); - /// + /// ICatResponse CatTemplates(ICatTemplatesRequest request); - /// + /// Task> CatTemplatesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatTemplatesAsync(ICatTemplatesRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task> CatTemplatesAsync(ICatTemplatesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatTemplates(Func selector = null) => - this.CatTemplates(selector.InvokeOrDefault(new CatTemplatesDescriptor())); + CatTemplates(selector.InvokeOrDefault(new CatTemplatesDescriptor())); - /// + /// public ICatResponse CatTemplates(ICatTemplatesRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatTemplatesDispatch>); + DoCat(request, + LowLevelDispatch.CatTemplatesDispatch>); - /// + /// public Task> CatTemplatesAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatTemplatesAsync(selector.InvokeOrDefault(new CatTemplatesDescriptor()), cancellationToken); - - /// - public Task> CatTemplatesAsync(ICatTemplatesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatTemplatesDispatchAsync>); + ) => CatTemplatesAsync(selector.InvokeOrDefault(new CatTemplatesDescriptor()), cancellationToken); + /// + public Task> CatTemplatesAsync(ICatTemplatesRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatTemplatesDispatchAsync>); } } diff --git a/src/Nest/Cat/CatThreadPool/CatThreadPoolRecord.cs b/src/Nest/Cat/CatThreadPool/CatThreadPoolRecord.cs index 881ebc68187..99bf750ad34 100644 --- a/src/Nest/Cat/CatThreadPool/CatThreadPoolRecord.cs +++ b/src/Nest/Cat/CatThreadPool/CatThreadPoolRecord.cs @@ -5,44 +5,61 @@ namespace Nest [JsonObject] public class CatThreadPoolRecord : ICatRecord { - [JsonProperty("node_name")] - public string NodeName { get; set; } - [JsonProperty("node_id")] - public string NodeId { get; set; } + [JsonProperty("active")] + public int Active { get; set; } + + [JsonProperty("completed")] + public long Completed { get; set; } + [JsonProperty("ephemeral_node_id")] public string EphemeralNodeId { get; set; } - [JsonProperty("pid")] - public int ProcessId { get; set; } + [JsonProperty("host")] public string Host { get; set; } + [JsonProperty("ip")] public string Ip { get; set; } - [JsonProperty("port")] - public int Port { get; set; } + + [JsonProperty("keep_alive")] + public Time KeepAlive { get; set; } + + [JsonProperty("largest")] + public int Largest { get; set; } + + [JsonProperty("max")] + public int Maximum { get; set; } + + [JsonProperty("min")] + public int Minimum { get; set; } + [JsonProperty("name")] public string Name { get; set; } - [JsonProperty("type")] - public string Type { get; set; } - [JsonProperty("active")] - public int Active { get; set; } - [JsonProperty("size")] - public int Size { get; set; } + + [JsonProperty("node_id")] + public string NodeId { get; set; } + + [JsonProperty("node_name")] + public string NodeName { get; set; } + + [JsonProperty("port")] + public int Port { get; set; } + + [JsonProperty("pid")] + public int ProcessId { get; set; } + [JsonProperty("queue")] public int Queue { get; set; } + [JsonProperty("queue_size")] public int? QueueSize { get; set; } + [JsonProperty("rejected")] public long Rejected { get; set; } - [JsonProperty("largest")] - public int Largest { get; set; } - [JsonProperty("completed")] - public long Completed { get; set; } - [JsonProperty("min")] - public int Minimum { get; set; } - [JsonProperty("max")] - public int Maximum { get; set; } - [JsonProperty("keep_alive")] - public Time KeepAlive { get; set; } + [JsonProperty("size")] + public int Size { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } } } diff --git a/src/Nest/Cat/CatThreadPool/ElasticClient-CatThreadpool.cs b/src/Nest/Cat/CatThreadPool/ElasticClient-CatThreadpool.cs index f97647e654c..ccd79cfb44b 100644 --- a/src/Nest/Cat/CatThreadPool/ElasticClient-CatThreadpool.cs +++ b/src/Nest/Cat/CatThreadPool/ElasticClient-CatThreadpool.cs @@ -1,46 +1,52 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial interface IElasticClient { - /// + /// ICatResponse CatThreadPool(Func selector = null); - /// + /// ICatResponse CatThreadPool(ICatThreadPoolRequest request); - /// + /// Task> CatThreadPoolAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) ); - /// - Task> CatThreadPoolAsync(ICatThreadPoolRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task> CatThreadPoolAsync(ICatThreadPoolRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public ICatResponse CatThreadPool(Func selector = null) => - this.CatThreadPool(selector.InvokeOrDefault(new CatThreadPoolDescriptor())); + CatThreadPool(selector.InvokeOrDefault(new CatThreadPoolDescriptor())); - /// + /// public ICatResponse CatThreadPool(ICatThreadPoolRequest request) => - this.DoCat(request, this.LowLevelDispatch.CatThreadPoolDispatch>); + DoCat(request, + LowLevelDispatch.CatThreadPoolDispatch>); - /// + /// public Task> CatThreadPoolAsync( Func selector = null, CancellationToken cancellationToken = default(CancellationToken) - ) => this.CatThreadPoolAsync(selector.InvokeOrDefault(new CatThreadPoolDescriptor()), cancellationToken); + ) => CatThreadPoolAsync(selector.InvokeOrDefault(new CatThreadPoolDescriptor()), cancellationToken); - /// - public Task> CatThreadPoolAsync(ICatThreadPoolRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.DoCatAsync(request, cancellationToken, this.LowLevelDispatch.CatThreadPoolDispatchAsync>); + /// + public Task> CatThreadPoolAsync(ICatThreadPoolRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + DoCatAsync(request, cancellationToken, + LowLevelDispatch.CatThreadPoolDispatchAsync>); } } diff --git a/src/Nest/Cat/ElasticClient-Cat.cs b/src/Nest/Cat/ElasticClient-Cat.cs index fb22341d278..ed85a19c756 100644 --- a/src/Nest/Cat/ElasticClient-Cat.cs +++ b/src/Nest/Cat/ElasticClient-Cat.cs @@ -1,15 +1,14 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { public partial class ElasticClient { - private CatResponse DeserializeCatResponse(IApiCallDetails response, Stream stream) where TCatRecord : ICatRecord { @@ -17,7 +16,7 @@ private CatResponse DeserializeCatResponse(IApiCallDetai if (!response.Success) return catResponse; - var records = this.RequestResponseSerializer.Deserialize>(stream); + var records = RequestResponseSerializer.Deserialize>(stream); catResponse.Records = records; return catResponse; @@ -26,16 +25,17 @@ private CatResponse DeserializeCatResponse(IApiCallDetai private ICatResponse DoCat( TRequest request, Func, CatResponse> dispatch - ) + ) where TCatRecord : ICatRecord where TParams : RequestParameters, new() where TRequest : IRequest => - this.Dispatcher.Dispatch>( - ForceConfiguration(request, c => { + Dispatcher.Dispatch>( + ForceConfiguration(request, c => + { c.Accept = RequestData.MimeType; c.ContentType = RequestData.MimeType; }), - new Func>(this.DeserializeCatResponse), + new Func>(DeserializeCatResponse), (p, d) => dispatch(p) ); @@ -43,20 +43,19 @@ private Task> DoCatAsync TRequest request, CancellationToken cancellationToken, Func, CancellationToken, Task>> dispatch - ) + ) where TCatRecord : ICatRecord where TParams : RequestParameters, new() where TRequest : IRequest => - this.Dispatcher.DispatchAsync, ICatResponse>( + Dispatcher.DispatchAsync, ICatResponse>( ForceConfiguration(request, c => { c.Accept = RequestData.MimeType; c.ContentType = RequestData.MimeType; }), cancellationToken, - new Func>(this.DeserializeCatResponse), + new Func>(DeserializeCatResponse), (p, d, c) => dispatch(p, c) ); - } } diff --git a/src/Nest/Cat/ICatRecord.cs b/src/Nest/Cat/ICatRecord.cs index 3dee65cc781..ea4cdea7606 100644 --- a/src/Nest/Cat/ICatRecord.cs +++ b/src/Nest/Cat/ICatRecord.cs @@ -1,4 +1,4 @@ namespace Nest { - public interface ICatRecord {} -} \ No newline at end of file + public interface ICatRecord { } +} diff --git a/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainRequest.cs b/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainRequest.cs index 3a343bca12e..453a497550c 100644 --- a/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainRequest.cs +++ b/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainRequest.cs @@ -11,17 +11,17 @@ public partial interface IClusterAllocationExplainRequest [JsonProperty("index")] IndexName Index { get; set; } - /// - /// The shard id to provide an explanation for - /// - [JsonProperty("shard")] - int? Shard { get; set; } - /// /// Whether to explain a primary or replica shard /// [JsonProperty("primary")] bool? Primary { get; set; } + + /// + /// The shard id to provide an explanation for + /// + [JsonProperty("shard")] + int? Shard { get; set; } } public partial class ClusterAllocationExplainRequest @@ -32,21 +32,21 @@ public partial class ClusterAllocationExplainRequest public IndexName Index { get; set; } /// - /// The shard id to provide an explanation for + /// Whether to explain a primary or replica shard /// - public int? Shard { get; set; } + public bool? Primary { get; set; } /// - /// Whether to explain a primary or replica shard + /// The shard id to provide an explanation for /// - public bool? Primary { get; set; } + public int? Shard { get; set; } } public partial class ClusterAllocationExplainDescriptor { IndexName IClusterAllocationExplainRequest.Index { get; set; } - int? IClusterAllocationExplainRequest.Shard { get; set; } bool? IClusterAllocationExplainRequest.Primary { get; set; } + int? IClusterAllocationExplainRequest.Shard { get; set; } /// /// The name of the index to provide an explanation for diff --git a/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainResponse.cs b/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainResponse.cs index a6bdd539283..e162e874b3b 100644 --- a/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainResponse.cs +++ b/src/Nest/Cluster/ClusterAllocationExplain/ClusterAllocationExplainResponse.cs @@ -9,123 +9,123 @@ namespace Nest [JsonObject] public interface IClusterAllocationExplainResponse : IResponse { - [JsonProperty("index")] - string Index { get; } - - [JsonProperty("shard")] - int Shard { get; } - - [JsonProperty("primary")] - bool Primary { get; } + [JsonProperty("allocate_explanation")] + string AllocateExplanation { get; } - [JsonProperty("current_state")] - string CurrentState { get; } + [JsonProperty("allocation_delay")] + string AllocationDelay { get; } - [JsonProperty("unassigned_info")] - UnassignedInformation UnassignedInformation { get; } + [JsonProperty("allocation_delay_in_millis")] + long AllocationDelayInMilliseconds { get; } [JsonProperty("can_allocate")] Decision? CanAllocate { get; } - [JsonProperty("allocate_explanation")] - string AllocateExplanation { get; } - - [JsonProperty("configured_delay")] - string ConfiguredDelay { get; } + [JsonProperty("can_move_to_other_node")] + Decision? CanMoveToOtherNode { get; } - [JsonProperty("configured_delay_in_mills")] - long ConfiguredDelayInMilliseconds { get; } + [JsonProperty("can_rebalance_cluster")] + Decision? CanRebalanceCluster { get; } - [JsonProperty("current_node")] - CurrentNode CurrentNode { get; } + [JsonProperty("can_rebalance_cluster_decisions")] + IReadOnlyCollection CanRebalanceClusterDecisions { get; } - [JsonProperty("can_remain_on_current_node")] - Decision? CanRemainOnCurrentNode { get; } + [JsonProperty("can_rebalance_to_other_node")] + Decision? CanRebalanceToOtherNode { get; } [JsonProperty("can_remain_decisions")] IReadOnlyCollection CanRemainDecisions { get; } - [JsonProperty("can_rebalance_cluster")] - Decision? CanRebalanceCluster { get; } + [JsonProperty("can_remain_on_current_node")] + Decision? CanRemainOnCurrentNode { get; } - [JsonProperty("can_rebalance_to_other_node")] - Decision? CanRebalanceToOtherNode { get; } + [JsonProperty("configured_delay")] + string ConfiguredDelay { get; } - [JsonProperty("can_rebalance_cluster_decisions")] - IReadOnlyCollection CanRebalanceClusterDecisions { get; } + [JsonProperty("configured_delay_in_mills")] + long ConfiguredDelayInMilliseconds { get; } - [JsonProperty("rebalance_explanation")] - string RebalanceExplanation { get; } + [JsonProperty("current_node")] + CurrentNode CurrentNode { get; } - [JsonProperty("node_allocation_decisions")] - IReadOnlyCollection NodeAllocationDecisions { get; } + [JsonProperty("current_state")] + string CurrentState { get; } - [JsonProperty("can_move_to_other_node")] - Decision? CanMoveToOtherNode { get; } + [JsonProperty("index")] + string Index { get; } [JsonProperty("move_explanation")] string MoveExplanation { get; } - [JsonProperty("allocation_delay")] - string AllocationDelay { get; } + [JsonProperty("node_allocation_decisions")] + IReadOnlyCollection NodeAllocationDecisions { get; } - [JsonProperty("allocation_delay_in_millis")] - long AllocationDelayInMilliseconds { get; } + [JsonProperty("primary")] + bool Primary { get; } + + [JsonProperty("rebalance_explanation")] + string RebalanceExplanation { get; } [JsonProperty("remaining_delay")] string RemainingDelay { get; } [JsonProperty("remaining_delay_in_millis")] long RemainingDelayInMilliseconds { get; } + + [JsonProperty("shard")] + int Shard { get; } + + [JsonProperty("unassigned_info")] + UnassignedInformation UnassignedInformation { get; } } public class ClusterAllocationExplainResponse : ResponseBase, IClusterAllocationExplainResponse { - public string Index { get; internal set; } - - public int Shard { get; internal set; } - - public bool Primary { get; internal set; } + public string AllocateExplanation { get; internal set; } - public string CurrentState { get; internal set; } + public string AllocationDelay { get; internal set; } - public UnassignedInformation UnassignedInformation { get; internal set; } + public long AllocationDelayInMilliseconds { get; internal set; } public Decision? CanAllocate { get; internal set; } - public string AllocateExplanation { get; internal set; } - - public string ConfiguredDelay { get; internal set; } + public Decision? CanMoveToOtherNode { get; internal set; } - public long ConfiguredDelayInMilliseconds { get; internal set; } + public Decision? CanRebalanceCluster { get; internal set; } - public CurrentNode CurrentNode { get; internal set; } + public IReadOnlyCollection CanRebalanceClusterDecisions { get; internal set; } = + EmptyReadOnly.Collection; - public Decision? CanRemainOnCurrentNode { get; internal set; } + public Decision? CanRebalanceToOtherNode { get; internal set; } public IReadOnlyCollection CanRemainDecisions { get; internal set; } - public Decision? CanRebalanceCluster { get; internal set; } - - public Decision? CanRebalanceToOtherNode { get; internal set; } + public Decision? CanRemainOnCurrentNode { get; internal set; } - public IReadOnlyCollection CanRebalanceClusterDecisions { get; internal set; } = EmptyReadOnly.Collection; + public string ConfiguredDelay { get; internal set; } - public string RebalanceExplanation { get; internal set; } + public long ConfiguredDelayInMilliseconds { get; internal set; } - public IReadOnlyCollection NodeAllocationDecisions { get; internal set; } + public CurrentNode CurrentNode { get; internal set; } - public Decision? CanMoveToOtherNode { get; internal set; } + public string CurrentState { get; internal set; } + public string Index { get; internal set; } public string MoveExplanation { get; internal set; } - public string AllocationDelay { get; internal set; } + public IReadOnlyCollection NodeAllocationDecisions { get; internal set; } - public long AllocationDelayInMilliseconds { get; internal set; } + public bool Primary { get; internal set; } + + public string RebalanceExplanation { get; internal set; } public string RemainingDelay { get; internal set; } public long RemainingDelayInMilliseconds { get; internal set; } + + public int Shard { get; internal set; } + + public UnassignedInformation UnassignedInformation { get; internal set; } } [JsonObject] @@ -137,14 +137,14 @@ public class CurrentNode [JsonProperty("name")] public string Name { get; internal set; } + [JsonProperty("attributes")] + public IReadOnlyDictionary NodeAttributes { get; set; } = EmptyReadOnly.Dictionary; + [JsonProperty("transport_address")] public string TransportAddress { get; internal set; } [JsonProperty("weight_ranking")] public string WeightRanking { get; internal set; } - - [JsonProperty("attributes")] - public IReadOnlyDictionary NodeAttributes { get; set; } = EmptyReadOnly.Dictionary; } [JsonConverter(typeof(StringEnumConverter))] @@ -166,29 +166,29 @@ public enum AllocationExplainDecision [JsonObject] public class NodeAllocationExplanation { - [JsonProperty("node_id")] - public string NodeId { get; set; } - - [JsonProperty("node_name")] - public string NodeName { get; set; } + [JsonProperty("deciders")] + public IReadOnlyCollection Deciders { get; set; } = EmptyReadOnly.Collection; - [JsonProperty("transport_address")] - public string TransportAddress { get; set; } + [JsonProperty("node_attributes")] + public IReadOnlyDictionary NodeAttributes { get; set; } = EmptyReadOnly.Dictionary; [JsonProperty("node_decision")] public Decision? NodeDecision { get; set; } - [JsonProperty("node_attributes")] - public IReadOnlyDictionary NodeAttributes { get; set; } = EmptyReadOnly.Dictionary; + [JsonProperty("node_id")] + public string NodeId { get; set; } + + [JsonProperty("node_name")] + public string NodeName { get; set; } [JsonProperty("store")] public AllocationStore Store { get; set; } + [JsonProperty("transport_address")] + public string TransportAddress { get; set; } + [JsonProperty("weight_ranking")] public int? WeightRanking { get; set; } - - [JsonProperty("deciders")] - public IReadOnlyCollection Deciders { get; set; } = EmptyReadOnly.Collection; } [JsonConverter(typeof(StringEnumConverter))] @@ -244,21 +244,21 @@ public enum StoreCopy [JsonObject] public class AllocationStore { + [JsonProperty("allocation_id")] + public string AllocationId { get; set; } + [JsonProperty("found")] public bool? Found { get; set; } [JsonProperty("in_sync")] public bool? InSync { get; set; } - [JsonProperty("allocation_id")] - public string AllocationId { get; set; } + [JsonProperty("matching_size_in_bytes")] + public long? MatchingSizeInBytes { get; set; } [JsonProperty("matching_sync_id")] public bool? MatchingSyncId { get; set; } - [JsonProperty("matching_size_in_bytes")] - public long? MatchingSizeInBytes { get; set; } - [JsonProperty("store_exception")] public string StoreException { get; set; } } @@ -278,27 +278,27 @@ public class AllocationDecision public class UnassignedInformation { - [JsonProperty("reason")] - public UnassignedInformationReason Reason { get; set; } - [JsonProperty("at")] public DateTime At { get; set; } [JsonProperty("last_allocation_status")] public string LastAllocationStatus { get; set; } + + [JsonProperty("reason")] + public UnassignedInformationReason Reason { get; set; } } public class ShardAllocationExplanation { + [JsonProperty("id")] + public int Id { get; set; } + [JsonProperty("index")] public IndexName Index { get; set; } [JsonProperty("index_uuid")] public string IndexUniqueId { get; set; } - [JsonProperty("id")] - public int Id { get; set; } - [JsonProperty("primary")] public bool Primary { get; set; } } @@ -306,93 +306,93 @@ public class ShardAllocationExplanation [JsonConverter(typeof(StringEnumConverter))] public enum UnassignedInformationReason { - /// - /// Unassigned as a result of an API creation of an index. - /// + /// + /// Unassigned as a result of an API creation of an index. + /// [EnumMember(Value = "INDEX_CREATED")] IndexCreated, - /// - /// Unassigned as a result of a full cluster recovery. - /// + /// + /// Unassigned as a result of a full cluster recovery. + /// [EnumMember(Value = "CLUSTER_RECOVERED")] ClusterRecovered, - /// - /// Unassigned as a result of opening a closed index. - /// + /// + /// Unassigned as a result of opening a closed index. + /// [EnumMember(Value = "INDEX_REOPENED")] IndexReopened, - /// - /// Unassigned as a result of importing a dangling index. - /// + /// + /// Unassigned as a result of importing a dangling index. + /// [EnumMember(Value = "DANGLING_INDEX_IMPORTED")] DanglingIndexImported, - /// - /// Unassigned as a result of restoring into a new index. - /// + /// + /// Unassigned as a result of restoring into a new index. + /// [EnumMember(Value = "NEW_INDEX_RESTORED")] NewIndexRestored, - /// - /// Unassigned as a result of restoring into a closed index. - /// + /// + /// Unassigned as a result of restoring into a closed index. + /// [EnumMember(Value = "EXISTING_INDEX_RESTORED")] ExistingIndexRestored, - /// - /// Unassigned as a result of explicit addition of a replica. - /// + /// + /// Unassigned as a result of explicit addition of a replica. + /// [EnumMember(Value = "REPLICA_ADDED")] ReplicaAdded, - /// - /// Unassigned as a result of a failed allocation of the shard. - /// + /// + /// Unassigned as a result of a failed allocation of the shard. + /// [EnumMember(Value = "ALLOCATION_FAILED")] AllocationFailed, - /// - /// Unassigned as a result of the node hosting it leaving the cluster. - /// + /// + /// Unassigned as a result of the node hosting it leaving the cluster. + /// [EnumMember(Value = "NODE_LEFT")] NodeLeft, - /// - /// Unassigned as a result of explicit cancel reroute command. - /// + /// + /// Unassigned as a result of explicit cancel reroute command. + /// [EnumMember(Value = "REROUTE_CANCELLED")] RerouteCancelled, - /// - /// When a shard moves from started back to initializing, for example, during shadow replica - /// + /// + /// When a shard moves from started back to initializing, for example, during shadow replica + /// [EnumMember(Value = "REINITIALIZED")] Reinitialized, - /// - /// A better replica location is identified and causes the existing replica allocation to be cancelled. - /// + /// + /// A better replica location is identified and causes the existing replica allocation to be cancelled. + /// [EnumMember(Value = "REALLOCATED_REPLICA")] ReallocatedReplica, - /// - /// Unassigned as a result of a failed primary while the replica was initializing. - /// + /// + /// Unassigned as a result of a failed primary while the replica was initializing. + /// [EnumMember(Value = "PRIMARY_FAILED")] PrimaryFailed, - /// - /// Unassigned after forcing an empty primary - /// + /// + /// Unassigned after forcing an empty primary + /// [EnumMember(Value = "FORCED_EMPTY_PRIMARY")] ForcedEmptyPrimary, - /// - /// Forced manually to allocate - /// + /// + /// Forced manually to allocate + /// [EnumMember(Value = "MANUAL_ALLOCATION")] ManualAllocation } diff --git a/src/Nest/Cluster/ClusterAllocationExplain/ElasticClient-ClusterAllocationExplain.cs b/src/Nest/Cluster/ClusterAllocationExplain/ElasticClient-ClusterAllocationExplain.cs index 9ee676ab92b..f39824a2b38 100644 --- a/src/Nest/Cluster/ClusterAllocationExplain/ElasticClient-ClusterAllocationExplain.cs +++ b/src/Nest/Cluster/ClusterAllocationExplain/ElasticClient-ClusterAllocationExplain.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -12,44 +9,61 @@ public partial interface IElasticClient { /// /// The cluster allocation explanation API is designed to assist in answering the question "why is this shard unassigned?" - /// https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html /// /// An optional descriptor to further describe the cluster allocation explain operation - IClusterAllocationExplainResponse ClusterAllocationExplain(Func selector = null); + IClusterAllocationExplainResponse ClusterAllocationExplain( + Func selector = null + ); - /// + /// IClusterAllocationExplainResponse ClusterAllocationExplain(IClusterAllocationExplainRequest request); - /// - Task ClusterAllocationExplainAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterAllocationExplainAsync( + Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// - Task ClusterAllocationExplainAsync(IClusterAllocationExplainRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterAllocationExplainAsync(IClusterAllocationExplainRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// - public IClusterAllocationExplainResponse ClusterAllocationExplain(Func selector = null) => - this.ClusterAllocationExplain(selector.InvokeOrDefault(new ClusterAllocationExplainDescriptor())); + /// + public IClusterAllocationExplainResponse ClusterAllocationExplain( + Func selector = null + ) => + ClusterAllocationExplain(selector.InvokeOrDefault(new ClusterAllocationExplainDescriptor())); - /// + /// public IClusterAllocationExplainResponse ClusterAllocationExplain(IClusterAllocationExplainRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.ClusterAllocationExplainDispatch(p, d) + (p, d) => LowLevelDispatch.ClusterAllocationExplainDispatch(p, d) ); - /// - public Task ClusterAllocationExplainAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterAllocationExplainAsync(selector.InvokeOrDefault(new ClusterAllocationExplainDescriptor()), cancellationToken); + /// + public Task ClusterAllocationExplainAsync( + Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterAllocationExplainAsync(selector.InvokeOrDefault(new ClusterAllocationExplainDescriptor()), cancellationToken); - /// - public Task ClusterAllocationExplainAsync(IClusterAllocationExplainRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( - request, - cancellationToken, - (p, d, c) => this.LowLevelDispatch.ClusterAllocationExplainDispatchAsync(p, d, c) - ); + /// + public Task ClusterAllocationExplainAsync(IClusterAllocationExplainRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher + .DispatchAsync( + request, + cancellationToken, + (p, d, c) => LowLevelDispatch.ClusterAllocationExplainDispatchAsync(p, d, c) + ); } } diff --git a/src/Nest/Cluster/ClusterHealth.cs b/src/Nest/Cluster/ClusterHealth.cs index ea98a05e657..29dc6a28999 100644 --- a/src/Nest/Cluster/ClusterHealth.cs +++ b/src/Nest/Cluster/ClusterHealth.cs @@ -5,12 +5,14 @@ namespace Nest { [JsonConverter(typeof(StringEnumConverter))] - public enum ClusterStatus + public enum ClusterStatus { [EnumMember(Value = "green")] Green, + [EnumMember(Value = "yellow")] Yellow, + [EnumMember(Value = "red")] Red } diff --git a/src/Nest/Cluster/ClusterHealth/ClusterHealthResponse.cs b/src/Nest/Cluster/ClusterHealth/ClusterHealthResponse.cs index 28d9625b42f..3b936bbcc44 100644 --- a/src/Nest/Cluster/ClusterHealth/ClusterHealthResponse.cs +++ b/src/Nest/Cluster/ClusterHealth/ClusterHealthResponse.cs @@ -6,49 +6,59 @@ namespace Nest { public interface IClusterHealthResponse : IResponse { - string ClusterName { get; } - Health Status { get; } - bool TimedOut { get; } - int NumberOfNodes { get; } - int NumberOfDataNodes { get; } int ActivePrimaryShards { get; } int ActiveShards { get; } - int RelocatingShards { get; } + string ClusterName { get; } + IReadOnlyDictionary Indices { get; } int InitializingShards { get; } - int UnassignedShards { get; } + int NumberOfDataNodes { get; } + int NumberOfNodes { get; } int NumberOfPendingTasks { get; } - IReadOnlyDictionary Indices { get; } + int RelocatingShards { get; } + Health Status { get; } + bool TimedOut { get; } + int UnassignedShards { get; } } [JsonObject] public class ClusterHealthResponse : ResponseBase, IClusterHealthResponse { + [JsonProperty("active_primary_shards")] + public int ActivePrimaryShards { get; internal set; } + + [JsonProperty("active_shards")] + public int ActiveShards { get; internal set; } + [JsonProperty("cluster_name")] public string ClusterName { get; internal set; } - [JsonProperty("status")] - public Health Status { get; internal set; } - [JsonProperty("timed_out")] - public bool TimedOut { get; internal set; } - [JsonProperty("number_of_nodes")] - public int NumberOfNodes { get; internal set; } + [JsonProperty("indices")] + [JsonConverter(typeof(ResolvableDictionaryJsonConverter))] + public IReadOnlyDictionary Indices { get; internal set; } = + EmptyReadOnly.Dictionary; + + [JsonProperty("initializing_shards")] + public int InitializingShards { get; internal set; } + [JsonProperty("number_of_data_nodes")] public int NumberOfDataNodes { get; internal set; } - [JsonProperty("active_primary_shards")] - public int ActivePrimaryShards { get; internal set; } - [JsonProperty("active_shards")] - public int ActiveShards { get; internal set; } + [JsonProperty("number_of_nodes")] + public int NumberOfNodes { get; internal set; } + + [JsonProperty(PropertyName = "number_of_pending_tasks")] + public int NumberOfPendingTasks { get; internal set; } + [JsonProperty("relocating_shards")] public int RelocatingShards { get; internal set; } - [JsonProperty("initializing_shards")] - public int InitializingShards { get; internal set; } + + [JsonProperty("status")] + public Health Status { get; internal set; } + + [JsonProperty("timed_out")] + public bool TimedOut { get; internal set; } + [JsonProperty("unassigned_shards")] public int UnassignedShards { get; internal set; } - [JsonProperty(PropertyName="number_of_pending_tasks")] - public int NumberOfPendingTasks { get; internal set; } - [JsonProperty("indices")] - [JsonConverter(typeof(ResolvableDictionaryJsonConverter))] - public IReadOnlyDictionary Indices { get; internal set; } = EmptyReadOnly.Dictionary; } } diff --git a/src/Nest/Cluster/ClusterHealth/ElasticClient-ClusterHealth.cs b/src/Nest/Cluster/ClusterHealth/ElasticClient-ClusterHealth.cs index 8d1c92aa1e7..7e4eddca5af 100644 --- a/src/Nest/Cluster/ClusterHealth/ElasticClient-ClusterHealth.cs +++ b/src/Nest/Cluster/ClusterHealth/ElasticClient-ClusterHealth.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -9,44 +9,53 @@ public partial interface IElasticClient { /// /// The cluster health API allows to get a very simple status on the health of the cluster. - /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-health.html + /// + /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-health.html /// /// An optional descriptor to further describe the cluster health operation IClusterHealthResponse ClusterHealth(Func selector = null); - /// + /// IClusterHealthResponse ClusterHealth(IClusterHealthRequest request); - /// - Task ClusterHealthAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterHealthAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// - Task ClusterHealthAsync(IClusterHealthRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterHealthAsync(IClusterHealthRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public IClusterHealthResponse ClusterHealth(Func selector = null) => - this.ClusterHealth(selector.InvokeOrDefault(new ClusterHealthDescriptor())); + ClusterHealth(selector.InvokeOrDefault(new ClusterHealthDescriptor())); - /// + /// public IClusterHealthResponse ClusterHealth(IClusterHealthRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.ClusterHealthDispatch(p) + (p, d) => LowLevelDispatch.ClusterHealthDispatch(p) ); - /// - public Task ClusterHealthAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterHealthAsync(selector.InvokeOrDefault(new ClusterHealthDescriptor()), cancellationToken); - - /// - public Task ClusterHealthAsync(IClusterHealthRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task ClusterHealthAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterHealthAsync(selector.InvokeOrDefault(new ClusterHealthDescriptor()), cancellationToken); + + /// + public Task ClusterHealthAsync(IClusterHealthRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.ClusterHealthDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.ClusterHealthDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/ClusterHealth/IndexHealthStats.cs b/src/Nest/Cluster/ClusterHealth/IndexHealthStats.cs index 0ef74207990..e57925fe13b 100644 --- a/src/Nest/Cluster/ClusterHealth/IndexHealthStats.cs +++ b/src/Nest/Cluster/ClusterHealth/IndexHealthStats.cs @@ -7,27 +7,32 @@ namespace Nest [JsonObject] public class IndexHealthStats { - [JsonProperty("status")] - public Health Status { get; internal set; } - - [JsonProperty("number_of_shards")] - public int NumberOfShards { get; internal set; } - [JsonProperty("number_of_replicas")] - public int NumberOfReplicas { get; internal set; } - [JsonProperty("active_primary_shards")] public int ActivePrimaryShards { get; internal set; } + [JsonProperty("active_shards")] public int ActiveShards { get; internal set; } - [JsonProperty("relocating_shards")] - public int RelocatingShards { get; internal set; } + [JsonProperty("initializing_shards")] public int InitializingShards { get; internal set; } - [JsonProperty("unassigned_shards")] - public int UnassignedShards { get; internal set; } + + [JsonProperty("number_of_replicas")] + public int NumberOfReplicas { get; internal set; } + + [JsonProperty("number_of_shards")] + public int NumberOfShards { get; internal set; } + + [JsonProperty("relocating_shards")] + public int RelocatingShards { get; internal set; } [JsonProperty("shards")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public IReadOnlyDictionary Shards { get; internal set; } = EmptyReadOnly.Dictionary; + + [JsonProperty("status")] + public Health Status { get; internal set; } + + [JsonProperty("unassigned_shards")] + public int UnassignedShards { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterHealth/ShardHealthStats.cs b/src/Nest/Cluster/ClusterHealth/ShardHealthStats.cs index 94c172ad8f6..4755b8671a8 100644 --- a/src/Nest/Cluster/ClusterHealth/ShardHealthStats.cs +++ b/src/Nest/Cluster/ClusterHealth/ShardHealthStats.cs @@ -6,16 +6,21 @@ namespace Nest [JsonObject] public class ShardHealthStats { - [JsonProperty("status")] - public Health Status { get; internal set; } - [JsonProperty("primary_active")] - public bool PrimaryActive { get; internal set; } [JsonProperty("active_shards")] public int ActiveShards { get; internal set; } - [JsonProperty("relocating_shards")] - public int RelocatingShards { get; internal set; } + [JsonProperty("initializing_shards")] public int InitializingShards { get; internal set; } + + [JsonProperty("primary_active")] + public bool PrimaryActive { get; internal set; } + + [JsonProperty("relocating_shards")] + public int RelocatingShards { get; internal set; } + + [JsonProperty("status")] + public Health Status { get; internal set; } + [JsonProperty("unassigned_shards")] public int UnassignedShards { get; internal set; } } diff --git a/src/Nest/Cluster/ClusterPendingTasks/ClusterPendingTasksResponse.cs b/src/Nest/Cluster/ClusterPendingTasks/ClusterPendingTasksResponse.cs index 867f7324883..b3593ecc96b 100644 --- a/src/Nest/Cluster/ClusterPendingTasks/ClusterPendingTasksResponse.cs +++ b/src/Nest/Cluster/ClusterPendingTasks/ClusterPendingTasksResponse.cs @@ -27,10 +27,10 @@ public class PendingTask [JsonProperty("source")] public string Source { get; internal set; } - [JsonProperty("time_in_queue_millis")] - public int TimeInQueueMilliseconds { get; internal set; } - [JsonProperty("time_in_queue")] public string TimeInQueue { get; internal set; } + + [JsonProperty("time_in_queue_millis")] + public int TimeInQueueMilliseconds { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterPendingTasks/ElasticClient-ClusterPendingTasks.cs b/src/Nest/Cluster/ClusterPendingTasks/ElasticClient-ClusterPendingTasks.cs index b3a2b3db54c..2f8a000143f 100644 --- a/src/Nest/Cluster/ClusterPendingTasks/ElasticClient-ClusterPendingTasks.cs +++ b/src/Nest/Cluster/ClusterPendingTasks/ElasticClient-ClusterPendingTasks.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -9,43 +9,55 @@ public partial interface IElasticClient { /// /// Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed. - /// https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html /// IClusterPendingTasksResponse ClusterPendingTasks(Func selector = null); - /// - Task ClusterPendingTasksAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterPendingTasksAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// IClusterPendingTasksResponse ClusterPendingTasks(IClusterPendingTasksRequest request); - /// - Task ClusterPendingTasksAsync(IClusterPendingTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterPendingTasksAsync(IClusterPendingTasksRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public IClusterPendingTasksResponse ClusterPendingTasks(Func selector = null) => - this.ClusterPendingTasks(selector.InvokeOrDefault(new ClusterPendingTasksDescriptor())); - - /// - public Task ClusterPendingTasksAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterPendingTasksAsync(selector.InvokeOrDefault(new ClusterPendingTasksDescriptor()), cancellationToken); + ClusterPendingTasks(selector.InvokeOrDefault(new ClusterPendingTasksDescriptor())); - /// + /// public IClusterPendingTasksResponse ClusterPendingTasks(IClusterPendingTasksRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.ClusterPendingTasksDispatch(p) + (p, d) => LowLevelDispatch.ClusterPendingTasksDispatch(p) ); - /// - public Task ClusterPendingTasksAsync(IClusterPendingTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( - request, - cancellationToken, - (p, d, c) => this.LowLevelDispatch.ClusterPendingTasksDispatchAsync(p, c) - ); + /// + public Task ClusterPendingTasksAsync( + Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterPendingTasksAsync(selector.InvokeOrDefault(new ClusterPendingTasksDescriptor()), cancellationToken); + + /// + public Task ClusterPendingTasksAsync(IClusterPendingTasksRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher + .DispatchAsync( + request, + cancellationToken, + (p, d, c) => LowLevelDispatch.ClusterPendingTasksDispatchAsync(p, c) + ); } } diff --git a/src/Nest/Cluster/ClusterReroute/ClusterRerouteExplanation.cs b/src/Nest/Cluster/ClusterReroute/ClusterRerouteExplanation.cs index 04966e70963..d84291c9a8c 100644 --- a/src/Nest/Cluster/ClusterReroute/ClusterRerouteExplanation.cs +++ b/src/Nest/Cluster/ClusterReroute/ClusterRerouteExplanation.cs @@ -8,11 +8,11 @@ public class ClusterRerouteExplanation { [JsonProperty("command")] public string Command { get; set; } - - [JsonProperty("parameters")] - public ClusterRerouteParameters Parameters { get; set; } [JsonProperty("decisions")] public IEnumerable Decisions { get; set; } + + [JsonProperty("parameters")] + public ClusterRerouteParameters Parameters { get; set; } } } diff --git a/src/Nest/Cluster/ClusterReroute/ClusterRerouteParameters.cs b/src/Nest/Cluster/ClusterReroute/ClusterRerouteParameters.cs index 625d6e84eba..fbfc9fe8c56 100644 --- a/src/Nest/Cluster/ClusterReroute/ClusterRerouteParameters.cs +++ b/src/Nest/Cluster/ClusterReroute/ClusterRerouteParameters.cs @@ -5,22 +5,22 @@ namespace Nest [JsonObject] public class ClusterRerouteParameters { - [JsonProperty("index")] - public string Index { get; set; } - - [JsonProperty("shard")] - public int Shard { get; set; } + [JsonProperty("allow_primary")] + public bool? AllowPrimary { get; set; } [JsonProperty("from_node")] public string FromNode { get; set; } - [JsonProperty("to_node")] - public string ToNode { get; set; } + [JsonProperty("index")] + public string Index { get; set; } [JsonProperty("node")] public string Node { get; set; } - [JsonProperty("allow_primary")] - public bool? AllowPrimary { get; set; } + [JsonProperty("shard")] + public int Shard { get; set; } + + [JsonProperty("to_node")] + public string ToNode { get; set; } } } diff --git a/src/Nest/Cluster/ClusterReroute/ClusterRerouteRequest.cs b/src/Nest/Cluster/ClusterReroute/ClusterRerouteRequest.cs index db9a3f84db0..d7a123ad3cb 100644 --- a/src/Nest/Cluster/ClusterReroute/ClusterRerouteRequest.cs +++ b/src/Nest/Cluster/ClusterReroute/ClusterRerouteRequest.cs @@ -23,16 +23,21 @@ public partial class ClusterRerouteDescriptor public ClusterRerouteDescriptor Move(Func selector) => AddCommand(selector?.Invoke(new MoveClusterRerouteCommandDescriptor())); - public ClusterRerouteDescriptor Cancel(Func selector)=> + public ClusterRerouteDescriptor Cancel(Func selector) => AddCommand(selector?.Invoke(new CancelClusterRerouteCommandDescriptor())); - public ClusterRerouteDescriptor AllocateReplica(Func selector) => + public ClusterRerouteDescriptor AllocateReplica(Func selector + ) => AddCommand(selector?.Invoke(new AllocateReplicaClusterRerouteCommandDescriptor())); - public ClusterRerouteDescriptor AllocateEmptyPrimary(Func selector) => + public ClusterRerouteDescriptor AllocateEmptyPrimary( + Func selector + ) => AddCommand(selector?.Invoke(new AllocateEmptyPrimaryRerouteCommandDescriptor())); - public ClusterRerouteDescriptor AllocateStalePrimary(Func selector) => + public ClusterRerouteDescriptor AllocateStalePrimary( + Func selector + ) => AddCommand(selector?.Invoke(new AllocateStalePrimaryRerouteCommandDescriptor())); private ClusterRerouteDescriptor AddCommand(IClusterRerouteCommand rerouteCommand) => Assign(a => a.Commands?.AddIfNotNull(rerouteCommand)); diff --git a/src/Nest/Cluster/ClusterReroute/ClusterRerouteResponse.cs b/src/Nest/Cluster/ClusterReroute/ClusterRerouteResponse.cs index 18bc3e05b01..c950f5b1f6a 100644 --- a/src/Nest/Cluster/ClusterReroute/ClusterRerouteResponse.cs +++ b/src/Nest/Cluster/ClusterReroute/ClusterRerouteResponse.cs @@ -5,16 +5,18 @@ namespace Nest { public interface IClusterRerouteResponse : IResponse { - [JsonProperty("state")] - ClusterRerouteState State { get; } - [JsonProperty("explanations")] IReadOnlyCollection Explanations { get; } + + [JsonProperty("state")] + ClusterRerouteState State { get; } } public class ClusterRerouteResponse : ResponseBase, IClusterRerouteResponse { + public IReadOnlyCollection Explanations { get; internal set; } = + EmptyReadOnly.Collection; + public ClusterRerouteState State { get; internal set; } - public IReadOnlyCollection Explanations { get; internal set; } = EmptyReadOnly.Collection; } } diff --git a/src/Nest/Cluster/ClusterReroute/ClusterRerouteState.cs b/src/Nest/Cluster/ClusterReroute/ClusterRerouteState.cs index 39674c6333c..bbdc2b04422 100644 --- a/src/Nest/Cluster/ClusterReroute/ClusterRerouteState.cs +++ b/src/Nest/Cluster/ClusterReroute/ClusterRerouteState.cs @@ -6,23 +6,23 @@ namespace Nest [JsonObject] public class ClusterRerouteState { - [JsonProperty("version")] - public int Version { get; internal set; } + [JsonProperty("blocks")] + public BlockState Blocks { get; internal set; } [JsonProperty("master_node")] public string MasterNode { get; internal set; } - [JsonProperty("blocks")] - public BlockState Blocks { get; internal set; } - [JsonProperty("nodes")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public IReadOnlyDictionary Nodes { get; internal set; } + [JsonProperty("routing_nodes")] + public RoutingNodesState RoutingNodes { get; internal set; } + [JsonProperty("routing_table")] public RoutingTableState RoutingTable { get; internal set; } - [JsonProperty("routing_nodes")] - public RoutingNodesState RoutingNodes { get; internal set; } + [JsonProperty("version")] + public int Version { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterReroute/Commands/AllocateClusterRerouteCommandBase.cs b/src/Nest/Cluster/ClusterReroute/Commands/AllocateClusterRerouteCommandBase.cs index fd4bd7162b2..d2092636816 100644 --- a/src/Nest/Cluster/ClusterReroute/Commands/AllocateClusterRerouteCommandBase.cs +++ b/src/Nest/Cluster/ClusterReroute/Commands/AllocateClusterRerouteCommandBase.cs @@ -7,17 +7,15 @@ public interface IAllocateClusterRerouteCommand : IClusterRerouteCommand [JsonProperty("index")] IndexName Index { get; set; } - [JsonProperty("shard")] - int? Shard { get; set; } - [JsonProperty("node")] string Node { get; set; } - } - public interface IAllocateReplicaClusterRerouteCommand : IAllocateClusterRerouteCommand - { + [JsonProperty("shard")] + int? Shard { get; set; } } + public interface IAllocateReplicaClusterRerouteCommand : IAllocateClusterRerouteCommand { } + public interface IAllocateEmptyPrimaryRerouteCommand : IAllocateClusterRerouteCommand { [JsonProperty("accept_data_loss")] @@ -32,13 +30,12 @@ public interface IAllocateStalePrimaryRerouteCommand : IAllocateClusterRerouteCo public abstract class AllocateClusterRerouteCommandBase : IAllocateClusterRerouteCommand { + public IndexName Index { get; set; } public abstract string Name { get; } - public IndexName Index { get; set; } + public string Node { get; set; } public int? Shard { get; set; } - - public string Node { get; set; } } public class AllocateReplicaClusterRerouteCommand : AllocateClusterRerouteCommandBase, IAllocateReplicaClusterRerouteCommand @@ -48,16 +45,14 @@ public class AllocateReplicaClusterRerouteCommand : AllocateClusterRerouteComman public class AllocateEmptyPrimaryRerouteCommand : AllocateClusterRerouteCommandBase, IAllocateEmptyPrimaryRerouteCommand { - public override string Name => "allocate_empty_primary"; - public bool? AcceptDataLoss { get; set; } + public override string Name => "allocate_empty_primary"; } public class AllocateStalePrimaryRerouteCommand : AllocateClusterRerouteCommandBase, IAllocateStalePrimaryRerouteCommand { - public override string Name => "allocate_stale_primary"; - public bool? AcceptDataLoss { get; set; } + public override string Name => "allocate_stale_primary"; } public abstract class AllocateClusterRerouteCommandDescriptorBase @@ -65,16 +60,15 @@ public abstract class AllocateClusterRerouteCommandDescriptorBase, TInterface, IAllocateClusterRerouteCommand where TInterface : class, IAllocateClusterRerouteCommand { - string IClusterRerouteCommand.Name => Name; - public abstract string Name { get; } IndexName IAllocateClusterRerouteCommand.Index { get; set; } - - int? IAllocateClusterRerouteCommand.Shard { get; set; } + string IClusterRerouteCommand.Name => Name; string IAllocateClusterRerouteCommand.Node { get; set; } + int? IAllocateClusterRerouteCommand.Shard { get; set; } + public TDescriptor Index(IndexName index) => Assign(a => a.Index = index); public TDescriptor Index() where T : class => Assign(a => a.Index = typeof(T)); @@ -85,28 +79,33 @@ public abstract class AllocateClusterRerouteCommandDescriptorBase, IAllocateReplicaClusterRerouteCommand + : AllocateClusterRerouteCommandDescriptorBase, + IAllocateReplicaClusterRerouteCommand { public override string Name => "allocate_replica"; } public class AllocateEmptyPrimaryRerouteCommandDescriptor - : AllocateClusterRerouteCommandDescriptorBase, IAllocateEmptyPrimaryRerouteCommand + : AllocateClusterRerouteCommandDescriptorBase, + IAllocateEmptyPrimaryRerouteCommand { public override string Name => "allocate_empty_primary"; bool? IAllocateEmptyPrimaryRerouteCommand.AcceptDataLoss { get; set; } - public AllocateEmptyPrimaryRerouteCommandDescriptor AcceptDataLoss(bool? acceptDataLoss = true) => Assign(a => a.AcceptDataLoss = acceptDataLoss); + public AllocateEmptyPrimaryRerouteCommandDescriptor AcceptDataLoss(bool? acceptDataLoss = true) => + Assign(a => a.AcceptDataLoss = acceptDataLoss); } public class AllocateStalePrimaryRerouteCommandDescriptor - : AllocateClusterRerouteCommandDescriptorBase, IAllocateStalePrimaryRerouteCommand + : AllocateClusterRerouteCommandDescriptorBase, + IAllocateStalePrimaryRerouteCommand { public override string Name => "allocate_stale_primary"; bool? IAllocateStalePrimaryRerouteCommand.AcceptDataLoss { get; set; } - public AllocateStalePrimaryRerouteCommandDescriptor AcceptDataLoss(bool? acceptDataLoss = true) => Assign(a => a.AcceptDataLoss = acceptDataLoss); + public AllocateStalePrimaryRerouteCommandDescriptor AcceptDataLoss(bool? acceptDataLoss = true) => + Assign(a => a.AcceptDataLoss = acceptDataLoss); } } diff --git a/src/Nest/Cluster/ClusterReroute/Commands/CancelClusterRerouteCommand.cs b/src/Nest/Cluster/ClusterReroute/Commands/CancelClusterRerouteCommand.cs index c150a5624c7..e414c02e3b8 100644 --- a/src/Nest/Cluster/ClusterReroute/Commands/CancelClusterRerouteCommand.cs +++ b/src/Nest/Cluster/ClusterReroute/Commands/CancelClusterRerouteCommand.cs @@ -2,46 +2,44 @@ namespace Nest { - public interface ICancelClusterRerouteCommand : IClusterRerouteCommand { + [JsonProperty("allow_primary")] + bool? AllowPrimary { get; set; } + [JsonProperty("index")] IndexName Index { get; set; } - [JsonProperty("shard")] - int? Shard { get; set; } - [JsonProperty("node")] string Node { get; set; } - [JsonProperty("allow_primary")] - bool? AllowPrimary { get; set; } + [JsonProperty("shard")] + int? Shard { get; set; } } + public class CancelClusterRerouteCommand : ICancelClusterRerouteCommand { - public string Name => "cancel"; + public bool? AllowPrimary { get; set; } public IndexName Index { get; set; } - - public int? Shard { get; set; } + public string Name => "cancel"; public string Node { get; set; } - public bool? AllowPrimary { get; set; } + public int? Shard { get; set; } } public class CancelClusterRerouteCommandDescriptor : DescriptorBase, ICancelClusterRerouteCommand { - string IClusterRerouteCommand.Name => "cancel"; + bool? ICancelClusterRerouteCommand.AllowPrimary { get; set; } IndexName ICancelClusterRerouteCommand.Index { get; set; } - - int? ICancelClusterRerouteCommand.Shard { get; set; } + string IClusterRerouteCommand.Name => "cancel"; string ICancelClusterRerouteCommand.Node { get; set; } - bool? ICancelClusterRerouteCommand.AllowPrimary { get; set; } + int? ICancelClusterRerouteCommand.Shard { get; set; } public CancelClusterRerouteCommandDescriptor Index(IndexName index) => Assign(a => a.Index = index); diff --git a/src/Nest/Cluster/ClusterReroute/Commands/ClusterRerouteCommandJsonConverter.cs b/src/Nest/Cluster/ClusterReroute/Commands/ClusterRerouteCommandJsonConverter.cs index 34208ca7446..d6d88099816 100644 --- a/src/Nest/Cluster/ClusterReroute/Commands/ClusterRerouteCommandJsonConverter.cs +++ b/src/Nest/Cluster/ClusterReroute/Commands/ClusterRerouteCommandJsonConverter.cs @@ -7,8 +7,9 @@ namespace Nest { internal class ClusterRerouteCommandJsonConverter : JsonConverter { - public override bool CanWrite => true; public override bool CanRead => true; + public override bool CanWrite => true; + public override bool CanConvert(Type objectType) => true; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) @@ -18,6 +19,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist var child = o.Children().FirstOrDefault(); var v = child?.Children().FirstOrDefault(); if (v == null) return null; + switch (child.Name) { case "allocate_replica": @@ -37,8 +39,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist break; } return command; - - } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) @@ -48,14 +48,17 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s var properties = value.GetType().GetCachedObjectProperties(); if (properties.Count == 0) return; + writer.WriteStartObject(); writer.WritePropertyName(c.Name); writer.WriteStartObject(); foreach (var p in properties) { if (p.Ignored) continue; + var vv = p.ValueProvider.GetValue(value); if (vv == null) continue; + writer.WritePropertyName(p.PropertyName); serializer.Serialize(writer, vv); } diff --git a/src/Nest/Cluster/ClusterReroute/Commands/IClusterRerouteCommand.cs b/src/Nest/Cluster/ClusterReroute/Commands/IClusterRerouteCommand.cs index 37926de5f2a..bd860c943a2 100644 --- a/src/Nest/Cluster/ClusterReroute/Commands/IClusterRerouteCommand.cs +++ b/src/Nest/Cluster/ClusterReroute/Commands/IClusterRerouteCommand.cs @@ -8,4 +8,4 @@ public interface IClusterRerouteCommand [JsonIgnore] string Name { get; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cluster/ClusterReroute/Commands/MoveClusterRerouteCommand.cs b/src/Nest/Cluster/ClusterReroute/Commands/MoveClusterRerouteCommand.cs index f93d7ca3a0a..9d712e8d9c1 100644 --- a/src/Nest/Cluster/ClusterReroute/Commands/MoveClusterRerouteCommand.cs +++ b/src/Nest/Cluster/ClusterReroute/Commands/MoveClusterRerouteCommand.cs @@ -2,8 +2,7 @@ namespace Nest { - - public interface IMoveClusterRerouteCommand: IClusterRerouteCommand + public interface IMoveClusterRerouteCommand : IClusterRerouteCommand { [JsonProperty("from_node")] string FromNode { get; set; } @@ -17,30 +16,29 @@ public interface IMoveClusterRerouteCommand: IClusterRerouteCommand [JsonProperty("to_node")] string ToNode { get; set; } } + public class MoveClusterRerouteCommand : IMoveClusterRerouteCommand { - public string Name => "move"; + public string FromNode { get; set; } public IndexName Index { get; set; } + public string Name => "move"; public int? Shard { get; set; } - public string FromNode { get; set; } - public string ToNode { get; set; } } public class MoveClusterRerouteCommandDescriptor : DescriptorBase, IMoveClusterRerouteCommand { - string IClusterRerouteCommand.Name => "move"; + string IMoveClusterRerouteCommand.FromNode { get; set; } IndexName IMoveClusterRerouteCommand.Index { get; set; } + string IClusterRerouteCommand.Name => "move"; int? IMoveClusterRerouteCommand.Shard { get; set; } - string IMoveClusterRerouteCommand.FromNode { get; set; } - string IMoveClusterRerouteCommand.ToNode { get; set; } public MoveClusterRerouteCommandDescriptor Index(IndexName index) => Assign(a => a.Index = index); diff --git a/src/Nest/Cluster/ClusterReroute/ElasticClient-ClusterReroute.cs b/src/Nest/Cluster/ClusterReroute/ElasticClient-ClusterReroute.cs index 306f761547a..e3d5c107987 100644 --- a/src/Nest/Cluster/ClusterReroute/ElasticClient-ClusterReroute.cs +++ b/src/Nest/Cluster/ClusterReroute/ElasticClient-ClusterReroute.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -14,40 +14,47 @@ public partial interface IElasticClient /// IClusterRerouteResponse ClusterReroute(Func selector); - /// - Task ClusterRerouteAsync(Func selector, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterRerouteAsync(Func selector, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// IClusterRerouteResponse ClusterReroute(IClusterRerouteRequest request); - /// - Task ClusterRerouteAsync(IClusterRerouteRequest request, CancellationToken cancellationToken = default(CancellationToken)); - + /// + Task ClusterRerouteAsync(IClusterRerouteRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public IClusterRerouteResponse ClusterReroute(Func selector) => - this.ClusterReroute(selector?.Invoke(new ClusterRerouteDescriptor())); - - /// - public Task ClusterRerouteAsync(Func selector, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterRerouteAsync(selector?.Invoke(new ClusterRerouteDescriptor()), cancellationToken); + ClusterReroute(selector?.Invoke(new ClusterRerouteDescriptor())); - /// + /// public IClusterRerouteResponse ClusterReroute(IClusterRerouteRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - this.LowLevelDispatch.ClusterRerouteDispatch + LowLevelDispatch.ClusterRerouteDispatch ); - /// - public Task ClusterRerouteAsync(IClusterRerouteRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task ClusterRerouteAsync(Func selector, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterRerouteAsync(selector?.Invoke(new ClusterRerouteDescriptor()), cancellationToken); + + /// + public Task ClusterRerouteAsync(IClusterRerouteRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - this.LowLevelDispatch.ClusterRerouteDispatchAsync + LowLevelDispatch.ClusterRerouteDispatchAsync ); } } diff --git a/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ClusterGetSettingsRequest.cs b/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ClusterGetSettingsRequest.cs index d0d8913b0b9..7706c40cb5f 100644 --- a/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ClusterGetSettingsRequest.cs +++ b/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ClusterGetSettingsRequest.cs @@ -1,7 +1,7 @@ namespace Nest { public partial interface IClusterGetSettingsRequest { } - + public partial class ClusterGetSettingsRequest { } public partial class ClusterGetSettingsDescriptor { } diff --git a/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ElasticClient-ClusterGetSettings.cs b/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ElasticClient-ClusterGetSettings.cs index e40a556d1da..a8a75014342 100644 --- a/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ElasticClient-ClusterGetSettings.cs +++ b/src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ElasticClient-ClusterGetSettings.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -10,43 +10,55 @@ public partial interface IElasticClient /// /// Gets cluster wide specific settings. Settings updated can either be persistent /// (applied cross restarts) or transient (will not survive a full cluster restart). - /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-update-settings.html + /// + /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-update-settings.html /// IClusterGetSettingsResponse ClusterGetSettings(Func selector = null); - /// - Task ClusterGetSettingsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterGetSettingsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// IClusterGetSettingsResponse ClusterGetSettings(IClusterGetSettingsRequest request); - /// - Task ClusterGetSettingsAsync(IClusterGetSettingsRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterGetSettingsAsync(IClusterGetSettingsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + /// public IClusterGetSettingsResponse ClusterGetSettings(Func selector = null) => - this.ClusterGetSettings(selector.InvokeOrDefault(new ClusterGetSettingsDescriptor())); - - /// - public Task ClusterGetSettingsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterGetSettingsAsync(selector.InvokeOrDefault(new ClusterGetSettingsDescriptor()), cancellationToken); + ClusterGetSettings(selector.InvokeOrDefault(new ClusterGetSettingsDescriptor())); - /// + /// public IClusterGetSettingsResponse ClusterGetSettings(IClusterGetSettingsRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request ?? new ClusterGetSettingsRequest(), - (p, d) => this.LowLevelDispatch.ClusterGetSettingsDispatch(p) + (p, d) => LowLevelDispatch.ClusterGetSettingsDispatch(p) ); - /// - public Task ClusterGetSettingsAsync(IClusterGetSettingsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( - request ?? new ClusterGetSettingsRequest(), - cancellationToken, - (p, d, c) => this.LowLevelDispatch.ClusterGetSettingsDispatchAsync(p, c) - ); + /// + public Task ClusterGetSettingsAsync( + Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterGetSettingsAsync(selector.InvokeOrDefault(new ClusterGetSettingsDescriptor()), cancellationToken); + + /// + public Task ClusterGetSettingsAsync(IClusterGetSettingsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher + .DispatchAsync( + request ?? new ClusterGetSettingsRequest(), + cancellationToken, + (p, d, c) => LowLevelDispatch.ClusterGetSettingsDispatchAsync(p, c) + ); } } diff --git a/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ClusterPutSettingsRequest.cs b/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ClusterPutSettingsRequest.cs index 825c460ddb9..8a83d68669e 100644 --- a/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ClusterPutSettingsRequest.cs +++ b/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ClusterPutSettingsRequest.cs @@ -11,7 +11,6 @@ public partial interface IClusterPutSettingsRequest [JsonProperty("transient")] IDictionary Transient { get; set; } - } public partial class ClusterPutSettingsRequest diff --git a/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ElasticClient-ClusterPutSettings.cs b/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ElasticClient-ClusterPutSettings.cs index d401d91826c..81af835f29c 100644 --- a/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ElasticClient-ClusterPutSettings.cs +++ b/src/Nest/Cluster/ClusterSettings/ClusterPutSettings/ElasticClient-ClusterPutSettings.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -10,42 +10,54 @@ public partial interface IElasticClient /// /// Allows to update cluster wide specific settings. Settings updated can either be persistent /// (applied cross restarts) or transient (will not survive a full cluster restart). - /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-update-settings.html + /// + /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-update-settings.html /// IClusterPutSettingsResponse ClusterPutSettings(Func selector); - /// - Task ClusterPutSettingsAsync(Func selector, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterPutSettingsAsync(Func selector, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// IClusterPutSettingsResponse ClusterPutSettings(IClusterPutSettingsRequest request); - /// - Task ClusterPutSettingsAsync(IClusterPutSettingsRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterPutSettingsAsync(IClusterPutSettingsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } + public partial class ElasticClient { - /// + /// public IClusterPutSettingsResponse ClusterPutSettings(Func selector) => - this.ClusterPutSettings(selector.InvokeOrDefault(new ClusterPutSettingsDescriptor())); - - /// - public Task ClusterPutSettingsAsync(Func selector, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterPutSettingsAsync(selector.InvokeOrDefault(new ClusterPutSettingsDescriptor()), cancellationToken); + ClusterPutSettings(selector.InvokeOrDefault(new ClusterPutSettingsDescriptor())); - /// + /// public IClusterPutSettingsResponse ClusterPutSettings(IClusterPutSettingsRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - this.LowLevelDispatch.ClusterPutSettingsDispatch + LowLevelDispatch.ClusterPutSettingsDispatch ); - /// - public Task ClusterPutSettingsAsync(IClusterPutSettingsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( - request, - cancellationToken, - this.LowLevelDispatch.ClusterPutSettingsDispatchAsync - ); + /// + public Task ClusterPutSettingsAsync(Func selector, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterPutSettingsAsync(selector.InvokeOrDefault(new ClusterPutSettingsDescriptor()), cancellationToken); + + /// + public Task ClusterPutSettingsAsync(IClusterPutSettingsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher + .DispatchAsync( + request, + cancellationToken, + LowLevelDispatch.ClusterPutSettingsDispatchAsync + ); } } diff --git a/src/Nest/Cluster/ClusterState/AllocationId.cs b/src/Nest/Cluster/ClusterState/AllocationId.cs index dd7b7dc9fab..12d9e8b8af5 100644 --- a/src/Nest/Cluster/ClusterState/AllocationId.cs +++ b/src/Nest/Cluster/ClusterState/AllocationId.cs @@ -1,6 +1,3 @@ -using System; -using System.Linq; -using System.Collections.Generic; using Newtonsoft.Json; namespace Nest @@ -10,4 +7,4 @@ public class AllocationId [JsonProperty("id")] public string Id { get; internal set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cluster/ClusterState/BlockState.cs b/src/Nest/Cluster/ClusterState/BlockState.cs index 6157f665b0e..a7ce273c0ff 100644 --- a/src/Nest/Cluster/ClusterState/BlockState.cs +++ b/src/Nest/Cluster/ClusterState/BlockState.cs @@ -1,6 +1,3 @@ -using System; -using System.Linq; -using System.Collections.Generic; using Newtonsoft.Json; namespace Nest @@ -10,4 +7,4 @@ public class BlockState [JsonProperty("read_only")] public bool ReadOnly { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cluster/ClusterState/ClusterStateResponse.cs b/src/Nest/Cluster/ClusterState/ClusterStateResponse.cs index ea640c12623..7612334ddd5 100644 --- a/src/Nest/Cluster/ClusterState/ClusterStateResponse.cs +++ b/src/Nest/Cluster/ClusterState/ClusterStateResponse.cs @@ -5,61 +5,60 @@ namespace Nest { public interface IClusterStateResponse : IResponse { + [JsonProperty("blocks")] + BlockState Blocks { get; } + [JsonProperty("cluster_name")] string ClusterName { get; } - [JsonProperty("master_node")] - string MasterNode { get; } - - [JsonProperty("state_uuid")] - string StateUUID { get; } - /// The Universally Unique Identifier for the cluster. /// While the cluster is still forming, it is possible for the `cluster_uuid` to be `_na_`. [JsonProperty("cluster_uuid")] string ClusterUUID { get; } - [JsonProperty("version")] - long Version { get; } + [JsonProperty("master_node")] + string MasterNode { get; } + + [JsonProperty("metadata")] + MetadataState Metadata { get; } [JsonProperty("nodes")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] IReadOnlyDictionary Nodes { get; } - [JsonProperty("metadata")] - MetadataState Metadata { get; } + [JsonProperty("routing_nodes")] + RoutingNodesState RoutingNodes { get; } [JsonProperty("routing_table")] RoutingTableState RoutingTable { get; } - [JsonProperty("routing_nodes")] - RoutingNodesState RoutingNodes { get; } + [JsonProperty("state_uuid")] + string StateUUID { get; } - [JsonProperty("blocks")] - BlockState Blocks { get; } + [JsonProperty("version")] + long Version { get; } } public class ClusterStateResponse : ResponseBase, IClusterStateResponse { + public BlockState Blocks { get; internal set; } public string ClusterName { get; internal set; } - public string MasterNode { get; internal set; } - - public string StateUUID { get; internal set; } - - /// + /// public string ClusterUUID { get; internal set; } - public long Version { get; internal set; } + public string MasterNode { get; internal set; } + + public MetadataState Metadata { get; internal set; } public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; - public MetadataState Metadata { get; internal set; } + public RoutingNodesState RoutingNodes { get; internal set; } public RoutingTableState RoutingTable { get; internal set; } - public RoutingNodesState RoutingNodes { get; internal set; } + public string StateUUID { get; internal set; } - public BlockState Blocks { get; internal set; } + public long Version { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterState/ElasticClient-ClusterState.cs b/src/Nest/Cluster/ClusterState/ElasticClient-ClusterState.cs index 6b3016757e9..fb504457071 100644 --- a/src/Nest/Cluster/ClusterState/ElasticClient-ClusterState.cs +++ b/src/Nest/Cluster/ClusterState/ElasticClient-ClusterState.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -9,44 +9,51 @@ public partial interface IElasticClient { /// /// The cluster state API allows to get a comprehensive state information of the whole cluster. - /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-state.html + /// + /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-state.html /// /// A descriptor that describes the parameters for the cluster state operation IClusterStateResponse ClusterState(Func selector = null); - /// + /// IClusterStateResponse ClusterState(IClusterStateRequest request); - /// - Task ClusterStateAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterStateAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task ClusterStateAsync(IClusterStateRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public IClusterStateResponse ClusterState(Func selector = null) => - this.ClusterState(selector.InvokeOrDefault(new ClusterStateDescriptor())); + ClusterState(selector.InvokeOrDefault(new ClusterStateDescriptor())); - /// + /// public IClusterStateResponse ClusterState(IClusterStateRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.ClusterStateDispatch(p) + (p, d) => LowLevelDispatch.ClusterStateDispatch(p) ); - /// - public Task ClusterStateAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterStateAsync(selector.InvokeOrDefault(new ClusterStateDescriptor()), cancellationToken); - - /// - public Task ClusterStateAsync(IClusterStateRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task ClusterStateAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterStateAsync(selector.InvokeOrDefault(new ClusterStateDescriptor()), cancellationToken); + + /// + public Task ClusterStateAsync(IClusterStateRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.ClusterStateDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.ClusterStateDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/ClusterState/MetadataIndexState.cs b/src/Nest/Cluster/ClusterState/MetadataIndexState.cs index 0b33ebcba80..8897b8f5be5 100644 --- a/src/Nest/Cluster/ClusterState/MetadataIndexState.cs +++ b/src/Nest/Cluster/ClusterState/MetadataIndexState.cs @@ -6,17 +6,17 @@ namespace Nest { public class MetadataIndexState { - [JsonProperty("state")] - public string State { get; internal set; } + [JsonProperty("aliases")] + public IEnumerable Aliases { get; internal set; } + + [JsonProperty("mappings")] + public IMappings Mappings { get; internal set; } [JsonProperty("settings")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public DynamicBody Settings { get; internal set; } - [JsonProperty("mappings")] - public IMappings Mappings { get; internal set; } - - [JsonProperty("aliases")] - public IEnumerable Aliases { get; internal set; } + [JsonProperty("state")] + public string State { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterState/MetadataState.cs b/src/Nest/Cluster/ClusterState/MetadataState.cs index 2a706e83af2..a905566fd26 100644 --- a/src/Nest/Cluster/ClusterState/MetadataState.cs +++ b/src/Nest/Cluster/ClusterState/MetadataState.cs @@ -1,5 +1,3 @@ -using System; -using System.Linq; using System.Collections.Generic; using Newtonsoft.Json; @@ -7,15 +5,15 @@ namespace Nest { public class MetadataState { - [JsonProperty("templates")] - [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] - public IReadOnlyDictionary Templates { get; internal set; } - [JsonProperty("cluster_uuid")] public string ClusterUUID { get; internal set; } [JsonProperty("indices")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public IReadOnlyDictionary Indices { get; internal set; } + + [JsonProperty("templates")] + [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] + public IReadOnlyDictionary Templates { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterState/NodeState.cs b/src/Nest/Cluster/ClusterState/NodeState.cs index 15f6972f7d3..42e0f58ed7f 100644 --- a/src/Nest/Cluster/ClusterState/NodeState.cs +++ b/src/Nest/Cluster/ClusterState/NodeState.cs @@ -5,14 +5,14 @@ namespace Nest { public class NodeState { + [JsonProperty("attributes")] + [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] + public Dictionary Attributes { get; internal set; } + [JsonProperty("name")] public string Name { get; internal set; } [JsonProperty("transport_address")] public string TransportAddress { get; internal set; } - - [JsonProperty("attributes")] - [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] - public Dictionary Attributes { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterState/RoutingNodesState.cs b/src/Nest/Cluster/ClusterState/RoutingNodesState.cs index 46ae4b9cd0c..3c2a6d6e619 100644 --- a/src/Nest/Cluster/ClusterState/RoutingNodesState.cs +++ b/src/Nest/Cluster/ClusterState/RoutingNodesState.cs @@ -1,5 +1,3 @@ -using System; -using System.Linq; using System.Collections.Generic; using Newtonsoft.Json; @@ -7,10 +5,10 @@ namespace Nest { public class RoutingNodesState { - [JsonProperty("unassigned")] - public IReadOnlyCollection Unassigned { get; internal set; } - [JsonProperty("nodes")] public IReadOnlyDictionary> Nodes { get; internal set; } + + [JsonProperty("unassigned")] + public IReadOnlyCollection Unassigned { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterState/RoutingShard.cs b/src/Nest/Cluster/ClusterState/RoutingShard.cs index 0e2f18a164e..11289da98b3 100644 --- a/src/Nest/Cluster/ClusterState/RoutingShard.cs +++ b/src/Nest/Cluster/ClusterState/RoutingShard.cs @@ -1,6 +1,3 @@ -using System; -using System.Linq; -using System.Collections.Generic; using Newtonsoft.Json; namespace Nest @@ -10,22 +7,22 @@ public class RoutingShard [JsonProperty("allocation_id")] public AllocationId AllocationId { get; internal set; } - [JsonProperty("state")] - public string State { get; internal set; } - - [JsonProperty("primary")] - public bool Primary { get; internal set; } + [JsonProperty("index")] + public string Index { get; internal set; } [JsonProperty("node")] public string Node { get; internal set; } + [JsonProperty("primary")] + public bool Primary { get; internal set; } + [JsonProperty("relocating_node")] public string RelocatingNode { get; internal set; } [JsonProperty("shard")] public int Shard { get; internal set; } - [JsonProperty("index")] - public string Index { get; internal set; } + [JsonProperty("state")] + public string State { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterState/RoutingTableState.cs b/src/Nest/Cluster/ClusterState/RoutingTableState.cs index 2276ab4ce49..7a321497ecb 100644 --- a/src/Nest/Cluster/ClusterState/RoutingTableState.cs +++ b/src/Nest/Cluster/ClusterState/RoutingTableState.cs @@ -1,5 +1,3 @@ -using System; -using System.Linq; using System.Collections.Generic; using Newtonsoft.Json; diff --git a/src/Nest/Cluster/ClusterStats/ClusterIndicesStats.cs b/src/Nest/Cluster/ClusterStats/ClusterIndicesStats.cs index b5092c1dbb1..38706c8536f 100644 --- a/src/Nest/Cluster/ClusterStats/ClusterIndicesStats.cs +++ b/src/Nest/Cluster/ClusterStats/ClusterIndicesStats.cs @@ -1,5 +1,4 @@ - -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { @@ -29,14 +28,13 @@ public class ClusterIndicesStats [JsonProperty("store")] public StoreStats Store { get; internal set; } - } [JsonObject] public class ClusterIndicesShardsStats { - [JsonProperty("total")] - public double Total { get; internal set; } + [JsonProperty("index")] + public ClusterIndicesShardsIndexStats Index { get; internal set; } [JsonProperty("primaries")] public double Primaries { get; internal set; } @@ -44,33 +42,33 @@ public class ClusterIndicesShardsStats [JsonProperty("replication")] public double Replication { get; internal set; } - [JsonProperty("index")] - public ClusterIndicesShardsIndexStats Index { get; internal set; } + [JsonProperty("total")] + public double Total { get; internal set; } } [JsonObject] public class ClusterIndicesShardsIndexStats { - [JsonProperty("shards")] - public ClusterShardMetrics Shards { get; internal set; } - [JsonProperty("primaries")] public ClusterShardMetrics Primaries { get; internal set; } [JsonProperty("replication")] public ClusterShardMetrics Replication { get; internal set; } + + [JsonProperty("shards")] + public ClusterShardMetrics Shards { get; internal set; } } [JsonObject] public class ClusterShardMetrics { - [JsonProperty("min")] - public double Min { get; internal set; } + [JsonProperty("avg")] + public double Avg { get; internal set; } [JsonProperty("max")] public double Max { get; internal set; } - [JsonProperty("avg")] - public double Avg { get; internal set; } + [JsonProperty("min")] + public double Min { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterStats/ClusterNodesStats.cs b/src/Nest/Cluster/ClusterStats/ClusterNodesStats.cs index 15a77a271c5..b8cda13c4e8 100644 --- a/src/Nest/Cluster/ClusterStats/ClusterNodesStats.cs +++ b/src/Nest/Cluster/ClusterStats/ClusterNodesStats.cs @@ -9,40 +9,45 @@ public class ClusterNodesStats [JsonProperty("count")] public ClusterNodeCount Count { get; internal set; } - [JsonProperty("versions")] - public IReadOnlyCollection Versions { get; internal set; } - - [JsonProperty("os")] - public ClusterOperatingSystemStats OperatingSystem { get; internal set; } - - [JsonProperty("process")] - public ClusterProcess Process { get; internal set; } + [JsonProperty("fs")] + public ClusterFileSystem FileSystem { get; internal set; } [JsonProperty("jvm")] public ClusterJvm Jvm { get; internal set; } - [JsonProperty("fs")] - public ClusterFileSystem FileSystem { get; internal set; } + [JsonProperty("os")] + public ClusterOperatingSystemStats OperatingSystem { get; internal set; } [JsonProperty("plugins")] public IReadOnlyCollection Plugins { get; internal set; } + + [JsonProperty("process")] + public ClusterProcess Process { get; internal set; } + + [JsonProperty("versions")] + public IReadOnlyCollection Versions { get; internal set; } } [JsonObject] public class ClusterFileSystem { - [JsonProperty("total")] - public string Total { get; internal set; } - [JsonProperty("total_in_bytes")] - public long TotalInBytes { get; internal set; } - [JsonProperty("free")] - public string Free { get; internal set; } - [JsonProperty("free_in_bytes")] - public long FreeInBytes { get; internal set; } [JsonProperty("available")] public string Available { get; internal set; } + [JsonProperty("available_in_bytes")] public long AvailableInBytes { get; internal set; } + + [JsonProperty("free")] + public string Free { get; internal set; } + + [JsonProperty("free_in_bytes")] + public long FreeInBytes { get; internal set; } + + [JsonProperty("total")] + public string Total { get; internal set; } + + [JsonProperty("total_in_bytes")] + public long TotalInBytes { get; internal set; } } [JsonObject] @@ -54,49 +59,49 @@ public class ClusterJvm [JsonProperty("max_uptime_in_millis")] public long MaxUptimeInMilliseconds { get; internal set; } - [JsonProperty("versions")] - public IReadOnlyCollection Versions { get; internal set; } - [JsonProperty("mem")] public ClusterJvmMemory Memory { get; internal set; } [JsonProperty("threads")] public long Threads { get; internal set; } + + [JsonProperty("versions")] + public IReadOnlyCollection Versions { get; internal set; } } [JsonObject] public class ClusterJvmVersion { + [JsonProperty("count")] + public int Count { get; internal set; } + [JsonProperty("version")] public string Version { get; internal set; } [JsonProperty("vm_name")] public string VmName { get; internal set; } - [JsonProperty("vm_version")] - public string VmVersion { get; internal set; } - [JsonProperty("vm_vendor")] public string VmVendor { get; internal set; } - [JsonProperty("count")] - public int Count { get; internal set; } + [JsonProperty("vm_version")] + public string VmVersion { get; internal set; } } [JsonObject] public class ClusterJvmMemory { - [JsonProperty("heap_used")] - public string HeapUsed { get ;set;} - - [JsonProperty("heap_used_in_bytes")] - public long HeapUsedInBytes { get; internal set; } - [JsonProperty("heap_max")] public string HeapMax { get; internal set; } [JsonProperty("heap_max_in_bytes")] public long HeapMaxInBytes { get; internal set; } + + [JsonProperty("heap_used")] + public string HeapUsed { get; set; } + + [JsonProperty("heap_used_in_bytes")] + public long HeapUsedInBytes { get; internal set; } } [JsonObject] @@ -119,25 +124,25 @@ public class ClusterProcessCpu [JsonObject] public class ClusterProcessOpenFileDescriptors { - [JsonProperty("min")] - public long Min { get; internal set; } + [JsonProperty("avg")] + public long Avg { get; internal set; } [JsonProperty("max")] public long Max { get; internal set; } - [JsonProperty("avg")] - public long Avg { get; internal set; } + [JsonProperty("min")] + public long Min { get; internal set; } } [JsonObject] public class ClusterOperatingSystemStats { - [JsonProperty("available_processors")] - public int AvailableProcessors { get; internal set; } - [JsonProperty("allocated_processors")] public int AllocatedProcessors { get; internal set; } + [JsonProperty("available_processors")] + public int AvailableProcessors { get; internal set; } + [JsonProperty("names")] public IReadOnlyCollection Names { get; internal set; } } @@ -155,19 +160,19 @@ public class ClusterOperatingSystemName [JsonObject] public class ClusterNodeCount { - [JsonProperty("total")] - public int Total { get; internal set; } - [JsonProperty("coordinating_only")] public int CoordinatingOnly { get; internal set; } - [JsonProperty("master")] - public int Master { get; internal set; } - [JsonProperty("data")] public int Data { get; internal set; } [JsonProperty("ingest")] public int Ingest { get; internal set; } + + [JsonProperty("master")] + public int Master { get; internal set; } + + [JsonProperty("total")] + public int Total { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterStats/ClusterStatsResponse.cs b/src/Nest/Cluster/ClusterStats/ClusterStatsResponse.cs index 42453e439e8..671e7eb05d5 100644 --- a/src/Nest/Cluster/ClusterStats/ClusterStatsResponse.cs +++ b/src/Nest/Cluster/ClusterStats/ClusterStatsResponse.cs @@ -7,29 +7,29 @@ public interface IClusterStatsResponse : INodesResponse [JsonProperty("cluster_name")] string ClusterName { get; } - [JsonProperty("timestamp")] - long Timestamp { get; } - - [JsonProperty("status")] - ClusterStatus Status { get; } - [JsonProperty("indices")] ClusterIndicesStats Indices { get; } [JsonProperty("nodes")] ClusterNodesStats Nodes { get; } + + [JsonProperty("status")] + ClusterStatus Status { get; } + + [JsonProperty("timestamp")] + long Timestamp { get; } } public class ClusterStatsResponse : NodesResponseBase, IClusterStatsResponse { public string ClusterName { get; internal set; } - public long Timestamp { get; internal set; } - - public ClusterStatus Status { get; internal set; } - public ClusterIndicesStats Indices { get; internal set; } public ClusterNodesStats Nodes { get; internal set; } + + public ClusterStatus Status { get; internal set; } + + public long Timestamp { get; internal set; } } } diff --git a/src/Nest/Cluster/ClusterStats/ElasticClient-ClusterStats.cs b/src/Nest/Cluster/ClusterStats/ElasticClient-ClusterStats.cs index bb53bb096a6..3599615a4eb 100644 --- a/src/Nest/Cluster/ClusterStats/ElasticClient-ClusterStats.cs +++ b/src/Nest/Cluster/ClusterStats/ElasticClient-ClusterStats.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -12,43 +12,50 @@ public partial interface IElasticClient /// (shard numbers, store size, memory usage) and information about the current nodes that form the /// cluster (number, roles, os, jvm versions, memory usage, cpu and installed plugins). /// - /// https://www.elastic.co/guide/en/elasticsearch/guide/current/_cluster_stats.html + /// + /// https://www.elastic.co/guide/en/elasticsearch/guide/current/_cluster_stats.html /// A descriptor that describes the cluster stats operation IClusterStatsResponse ClusterStats(Func selector = null); - /// - Task ClusterStatsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ClusterStatsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// IClusterStatsResponse ClusterStats(IClusterStatsRequest request); - /// + /// Task ClusterStatsAsync(IClusterStatsRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public IClusterStatsResponse ClusterStats(Func selector = null) => - this.ClusterStats(selector.InvokeOrDefault(new ClusterStatsDescriptor())); - - /// - public Task ClusterStatsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.ClusterStatsAsync(selector.InvokeOrDefault(new ClusterStatsDescriptor()), cancellationToken); + ClusterStats(selector.InvokeOrDefault(new ClusterStatsDescriptor())); - /// + /// public IClusterStatsResponse ClusterStats(IClusterStatsRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.ClusterStatsDispatch(p) + (p, d) => LowLevelDispatch.ClusterStatsDispatch(p) ); - /// - public Task ClusterStatsAsync(IClusterStatsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task ClusterStatsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ClusterStatsAsync(selector.InvokeOrDefault(new ClusterStatsDescriptor()), cancellationToken); + + /// + public Task ClusterStatsAsync(IClusterStatsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.ClusterStatsDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.ClusterStatsDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs b/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs index 0f47ba9dcf9..cdc2b4d1186 100644 --- a/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs +++ b/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs @@ -3,9 +3,9 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -20,48 +20,55 @@ public partial interface IElasticClient /// An optional descriptor to further describe the nodes hot threads operation INodesHotThreadsResponse NodesHotThreads(Func selector = null); - /// + /// INodesHotThreadsResponse NodesHotThreads(INodesHotThreadsRequest request); - /// - Task NodesHotThreadsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task NodesHotThreadsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// - Task NodesHotThreadsAsync(INodesHotThreadsRequest request, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task NodesHotThreadsAsync(INodesHotThreadsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ); } public partial class ElasticClient { - /// + //::: {Dragonfly}{lvtIV72sRIWBGik7ulbuaw}{127.0.0.1}{127.0.0.1:9300} + private static readonly Regex NodeRegex = new Regex(@"^\s\{(?.+?)\}\{(?.+?)\}(?.+)\n"); + + /// public INodesHotThreadsResponse NodesHotThreads(Func selector = null) => - this.NodesHotThreads(selector.InvokeOrDefault(new NodesHotThreadsDescriptor())); + NodesHotThreads(selector.InvokeOrDefault(new NodesHotThreadsDescriptor())); - /// + /// public INodesHotThreadsResponse NodesHotThreads(INodesHotThreadsRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, new NodesHotThreadConverter(DeserializeNodesHotThreadResponse), - (p, d) => this.LowLevelDispatch.NodesHotThreadsDispatch(p) + (p, d) => LowLevelDispatch.NodesHotThreadsDispatch(p) ); - /// - public Task NodesHotThreadsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.NodesHotThreadsAsync(selector.InvokeOrDefault(new NodesHotThreadsDescriptor()), cancellationToken); - - /// - public Task NodesHotThreadsAsync(INodesHotThreadsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task NodesHotThreadsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + NodesHotThreadsAsync(selector.InvokeOrDefault(new NodesHotThreadsDescriptor()), cancellationToken); + + /// + public Task NodesHotThreadsAsync(INodesHotThreadsRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, new NodesHotThreadConverter(DeserializeNodesHotThreadResponse), - (p, d, c) => this.LowLevelDispatch.NodesHotThreadsDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.NodesHotThreadsDispatchAsync(p, c) ); - //::: {Dragonfly}{lvtIV72sRIWBGik7ulbuaw}{127.0.0.1}{127.0.0.1:9300} - private static Regex NodeRegex = new Regex(@"^\s\{(?.+?)\}\{(?.+?)\}(?.+)\n"); - - /// /// Because the nodes.hot_threads endpoint returns plain text instead of JSON, we have to /// manually parse the response text into a typed response object. @@ -104,6 +111,5 @@ where matches.Success return new NodesHotThreadsResponse(info.ToList()); } } - } } diff --git a/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsRequest.cs b/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsRequest.cs index 602e0e07d4e..3bd21765196 100644 --- a/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsRequest.cs +++ b/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsRequest.cs @@ -1,8 +1,7 @@ - -namespace Nest +namespace Nest { public partial interface INodesHotThreadsRequest { } - + public partial class NodesHotThreadsRequest { } public partial class NodesHotThreadsDescriptor { } diff --git a/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsResponse.cs b/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsResponse.cs index b99b6deae4b..f1190e9b000 100644 --- a/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsResponse.cs +++ b/src/Nest/Cluster/NodesHotThreads/NodesHotThreadsResponse.cs @@ -1,14 +1,13 @@ using System.Collections.Generic; -using System.Linq; namespace Nest { public class HotThreadInformation { - public string NodeName { get; internal set; } + public IReadOnlyCollection Hosts { get; internal set; } = EmptyReadOnly.Collection; public string NodeId { get; internal set; } + public string NodeName { get; internal set; } public IReadOnlyCollection Threads { get; internal set; } = EmptyReadOnly.Collection; - public IReadOnlyCollection Hosts { get; internal set; } = EmptyReadOnly.Collection; } public interface INodesHotThreadsResponse : IResponse @@ -20,10 +19,7 @@ public class NodesHotThreadsResponse : ResponseBase, INodesHotThreadsResponse { public NodesHotThreadsResponse() { } - internal NodesHotThreadsResponse(IReadOnlyCollection threadInfo) - { - this.HotThreads = threadInfo; - } + internal NodesHotThreadsResponse(IReadOnlyCollection threadInfo) => HotThreads = threadInfo; public IReadOnlyCollection HotThreads { get; internal set; } = EmptyReadOnly.Collection; } diff --git a/src/Nest/Cluster/NodesInfo/ElasticClient-NodesInfo.cs b/src/Nest/Cluster/NodesInfo/ElasticClient-NodesInfo.cs index 07744a5b554..219ac4ee258 100644 --- a/src/Nest/Cluster/NodesInfo/ElasticClient-NodesInfo.cs +++ b/src/Nest/Cluster/NodesInfo/ElasticClient-NodesInfo.cs @@ -1,56 +1,60 @@ using System; using System.IO; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; namespace Nest { - using System.Threading; using NodesHotThreadConverter = Func; public partial interface IElasticClient { /// /// The cluster nodes info API allows to retrieve one or more (or all) of the cluster nodes information. - /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-info.html + /// + /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-info.html /// /// An optional descriptor to further describe the nodes info operation INodesInfoResponse NodesInfo(Func selector = null); - /// + /// INodesInfoResponse NodesInfo(INodesInfoRequest request); - /// - Task NodesInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task NodesInfoAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task NodesInfoAsync(INodesInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)); - } public partial class ElasticClient { - /// + /// public INodesInfoResponse NodesInfo(Func selector = null) => - this.NodesInfo(selector.InvokeOrDefault(new NodesInfoDescriptor())); + NodesInfo(selector.InvokeOrDefault(new NodesInfoDescriptor())); - /// + /// public INodesInfoResponse NodesInfo(INodesInfoRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.NodesInfoDispatch(p) + (p, d) => LowLevelDispatch.NodesInfoDispatch(p) ); - /// - public Task NodesInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.NodesInfoAsync(selector.InvokeOrDefault(new NodesInfoDescriptor()), cancellationToken); + /// + public Task NodesInfoAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + NodesInfoAsync(selector.InvokeOrDefault(new NodesInfoDescriptor()), cancellationToken); - /// + /// public Task NodesInfoAsync(INodesInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.NodesInfoDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.NodesInfoDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/NodesInfo/NodeInfo.cs b/src/Nest/Cluster/NodesInfo/NodeInfo.cs index afe0db5db80..d9ae3c7ae5b 100644 --- a/src/Nest/Cluster/NodesInfo/NodeInfo.cs +++ b/src/Nest/Cluster/NodesInfo/NodeInfo.cs @@ -7,23 +7,35 @@ namespace Nest [JsonObject] public class NodeInfo { - [JsonProperty("name")] - public string Name { get; internal set; } - - [JsonProperty("transport_address")] - public string TransportAddress { get; internal set; } + [JsonProperty("build_hash")] + public string BuildHash { get; internal set; } [JsonProperty("host")] public string Host { get; internal set; } + [JsonProperty("http")] + public NodeInfoHttp Http { get; internal set; } + [JsonProperty("ip")] public string Ip { get; internal set; } - [JsonProperty("version")] - public string Version { get; internal set; } + [JsonProperty("jvm")] + public NodeJvmInfo Jvm { get; internal set; } - [JsonProperty("build_hash")] - public string BuildHash { get; internal set; } + [JsonProperty("name")] + public string Name { get; internal set; } + + [JsonProperty("network")] + public NodeInfoNetwork Network { get; internal set; } + + [JsonProperty("os")] + public NodeOperatingSystemInfo OperatingSystem { get; internal set; } + + [JsonProperty("plugins")] + public List Plugins { get; internal set; } + + [JsonProperty("process")] + public NodeProcessInfo Process { get; internal set; } /// /// All of the different roles that the node fulfills. An empty @@ -37,47 +49,26 @@ public class NodeInfo [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public DynamicBody Settings { get; internal set; } - [JsonProperty("os")] - public NodeOperatingSystemInfo OperatingSystem { get; internal set; } - - [JsonProperty("process")] - public NodeProcessInfo Process { get; internal set; } - - [JsonProperty("jvm")] - public NodeJvmInfo Jvm { get; internal set; } - [JsonProperty("thread_pool")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public Dictionary ThreadPool { get; internal set; } - [JsonProperty("network")] - public NodeInfoNetwork Network { get; internal set; } - [JsonProperty("transport")] public NodeInfoTransport Transport { get; internal set; } - [JsonProperty("http")] - public NodeInfoHttp Http { get; internal set; } + [JsonProperty("transport_address")] + public string TransportAddress { get; internal set; } - [JsonProperty("plugins")] - public List Plugins { get; internal set; } + [JsonProperty("version")] + public string Version { get; internal set; } } [JsonObject] public class NodeOperatingSystemInfo { - [JsonProperty("name")] - public string Name { get; internal set; } - [JsonProperty("arch")] public string Architecture { get; internal set; } - [JsonProperty("version")] - public string Version { get; internal set; } - - [JsonProperty("refresh_interval_in_millis")] - public int RefreshInterval { get; internal set; } - [JsonProperty("available_processors")] public int AvailableProcessors { get; internal set; } @@ -87,29 +78,45 @@ public class NodeOperatingSystemInfo [JsonProperty("mem")] public NodeInfoMemory Mem { get; internal set; } + [JsonProperty("name")] + public string Name { get; internal set; } + + [JsonProperty("refresh_interval_in_millis")] + public int RefreshInterval { get; internal set; } + [JsonProperty("swap")] public NodeInfoMemory Swap { get; internal set; } + + [JsonProperty("version")] + public string Version { get; internal set; } } [JsonObject] public class NodeInfoOSCPU { - [JsonProperty("vendor")] - public string Vendor { get; internal set; } - [JsonProperty("model")] - public string Model { get; internal set; } + [JsonProperty("cache_size")] + public string CacheSize { get; internal set; } + + [JsonProperty("cache_size_in_bytes")] + public int CacheSizeInBytes { get; internal set; } + + [JsonProperty("cores_per_socket")] + public int CoresPerSocket { get; internal set; } + [JsonProperty("mhz")] public int Mhz { get; internal set; } + + [JsonProperty("model")] + public string Model { get; internal set; } + [JsonProperty("total_cores")] public int TotalCores { get; internal set; } + [JsonProperty("total_sockets")] public int TotalSockets { get; internal set; } - [JsonProperty("cores_per_socket")] - public int CoresPerSocket { get; internal set; } - [JsonProperty("cache_size")] - public string CacheSize { get; internal set; } - [JsonProperty("cache_size_in_bytes")] - public int CacheSizeInBytes { get; internal set; } + + [JsonProperty("vendor")] + public string Vendor { get; internal set; } } [JsonObject] @@ -117,6 +124,7 @@ public class NodeInfoMemory { [JsonProperty("total")] public string Total { get; internal set; } + [JsonProperty("total_in_bytes")] public long TotalInBytes { get; internal set; } } @@ -124,86 +132,108 @@ public class NodeInfoMemory [JsonObject] public class NodeProcessInfo { - [JsonProperty("refresh_interval_in_millis")] - public long RefreshIntervalInMilliseconds { get; internal set; } - [JsonProperty("id")] public long Id { get; internal set; } [JsonProperty("mlockall")] public bool MlockAll { get; internal set; } + + [JsonProperty("refresh_interval_in_millis")] + public long RefreshIntervalInMilliseconds { get; internal set; } } [JsonObject] public class NodeJvmInfo { + [JsonProperty("gc_collectors")] + public IEnumerable GCCollectors { get; internal set; } + + [JsonProperty("mem")] + public NodeInfoJVMMemory Memory { get; internal set; } + + [JsonProperty("memory_pools")] + public IEnumerable MemoryPools { get; internal set; } + [JsonProperty("pid")] public int PID { get; internal set; } + + [JsonProperty("start_time_in_millis")] + public long StartTime { get; internal set; } + [JsonProperty("version")] public string Version { get; internal set; } + [JsonProperty("vm_name")] public string VMName { get; internal set; } - [JsonProperty("vm_version")] - public string VMVersion { get; internal set; } + [JsonProperty("vm_vendor")] public string VMVendor { get; internal set; } - [JsonProperty("memory_pools")] - public IEnumerable MemoryPools { get; internal set; } - [JsonProperty("gc_collectors")] - public IEnumerable GCCollectors { get; internal set; } - [JsonProperty("start_time_in_millis")] - public long StartTime { get; internal set; } - [JsonProperty("mem")] - public NodeInfoJVMMemory Memory { get; internal set; } + + [JsonProperty("vm_version")] + public string VMVersion { get; internal set; } } [JsonObject] public class NodeInfoJVMMemory { + [JsonProperty("direct_max")] + public string DirectMax { get; internal set; } + + [JsonProperty("direct_max_in_bytes")] + public long DirectMaxInBytes { get; internal set; } + [JsonProperty("heap_init")] public string HeapInit { get; internal set; } + [JsonProperty("heap_init_in_bytes")] public long HeapInitInBytes { get; internal set; } + [JsonProperty("heap_max")] public string HeapMax { get; internal set; } + [JsonProperty("heap_max_in_bytes")] public long HeapMaxInBytes { get; internal set; } + [JsonProperty("non_heap_init")] public string NonHeapInit { get; internal set; } + [JsonProperty("non_heap_init_in_bytes")] public long NonHeapInitInBytes { get; internal set; } + [JsonProperty("non_heap_max")] public string NonHeapMax { get; internal set; } + [JsonProperty("non_heap_max_in_bytes")] public long NonHeapMaxInBytes { get; internal set; } - [JsonProperty("direct_max")] - public string DirectMax { get; internal set; } - [JsonProperty("direct_max_in_bytes")] - public long DirectMaxInBytes { get; internal set; } } [JsonObject] public class NodeThreadPoolInfo { - [JsonProperty("type")] - public string Type { get; internal set; } - [JsonProperty("min")] - public int? Min { get; internal set; } + [JsonProperty("keep_alive")] + public string KeepAlive { get; internal set; } + [JsonProperty("max")] public int? Max { get; internal set; } + + [JsonProperty("min")] + public int? Min { get; internal set; } + [JsonProperty("queue_size")] public int? QueueSize { get; internal set; } - [JsonProperty("keep_alive")] - public string KeepAlive { get; internal set; } + + [JsonProperty("type")] + public string Type { get; internal set; } } [JsonObject] public class NodeInfoNetwork { - [JsonProperty("refresh_interval")] - public int RefreshInterval { get; internal set; } [JsonProperty("primary_interface")] public NodeInfoNetworkInterface PrimaryInterface { get; internal set; } + + [JsonProperty("refresh_interval")] + public int RefreshInterval { get; internal set; } } [JsonObject] @@ -211,10 +241,12 @@ public class NodeInfoNetworkInterface { [JsonProperty("address")] public string Address { get; internal set; } - [JsonProperty("name")] - public string Name { get; internal set; } + [JsonProperty("mac_address")] public string MacAddress { get; internal set; } + + [JsonProperty("name")] + public string Name { get; internal set; } } [JsonObject] @@ -222,6 +254,7 @@ public class NodeInfoTransport { [JsonProperty("bound_address")] public IEnumerable BoundAddress { get; internal set; } + [JsonProperty("publish_address")] public string PublishAddress { get; internal set; } } @@ -231,11 +264,14 @@ public class NodeInfoHttp { [JsonProperty("bound_address")] public IEnumerable BoundAddress { get; internal set; } - [JsonProperty("publish_address")] - public string PublishAddress { get; internal set; } + [JsonProperty("max_content_length")] public string MaxContentLength { get; internal set; } + [JsonProperty("max_content_length_in_bytes")] public long MaxContentLengthInBytes { get; internal set; } + + [JsonProperty("publish_address")] + public string PublishAddress { get; internal set; } } } diff --git a/src/Nest/Cluster/NodesInfo/NodeRole.cs b/src/Nest/Cluster/NodesInfo/NodeRole.cs index f97fcd4e2b6..78055a39d91 100644 --- a/src/Nest/Cluster/NodesInfo/NodeRole.cs +++ b/src/Nest/Cluster/NodesInfo/NodeRole.cs @@ -1,11 +1,6 @@ -using Newtonsoft.Json; +using System.Runtime.Serialization; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace Nest { @@ -14,10 +9,13 @@ public enum NodeRole { [EnumMember(Value = "master")] Master, + [EnumMember(Value = "data")] Data, + [EnumMember(Value = "client")] Client, + [EnumMember(Value = "ingest")] Ingest } diff --git a/src/Nest/Cluster/NodesInfo/NodesInfoResponse.cs b/src/Nest/Cluster/NodesInfo/NodesInfoResponse.cs index 501a6ace95c..a199f187431 100644 --- a/src/Nest/Cluster/NodesInfo/NodesInfoResponse.cs +++ b/src/Nest/Cluster/NodesInfo/NodesInfoResponse.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Elasticsearch.Net; using Newtonsoft.Json; namespace Nest @@ -20,6 +19,4 @@ public class NodesInfoResponse : NodesResponseBase, INodesInfoResponse [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; } - - } diff --git a/src/Nest/Cluster/NodesResponseBase.cs b/src/Nest/Cluster/NodesResponseBase.cs index 89450aaa74c..c52a27454c1 100644 --- a/src/Nest/Cluster/NodesResponseBase.cs +++ b/src/Nest/Cluster/NodesResponseBase.cs @@ -6,6 +6,7 @@ public abstract class NodesResponseBase : ResponseBase, INodesResponse { public NodeStatistics NodeStatistics { get; internal set; } } + public interface INodesResponse : IResponse { [JsonProperty("_nodes")] @@ -16,15 +17,14 @@ public interface INodesResponse : IResponse public class NodeStatistics { [JsonProperty] - public int Total { get; internal set; } + public int Failed { get; internal set; } [JsonProperty] public int Successful { get; internal set; } [JsonProperty] - public int Failed { get; internal set; } + public int Total { get; internal set; } //TODO map failures - } } diff --git a/src/Nest/Cluster/NodesStats/AdaptiveSelectionStats.cs b/src/Nest/Cluster/NodesStats/AdaptiveSelectionStats.cs index 20bd34133d4..67bfa972826 100644 --- a/src/Nest/Cluster/NodesStats/AdaptiveSelectionStats.cs +++ b/src/Nest/Cluster/NodesStats/AdaptiveSelectionStats.cs @@ -5,18 +5,25 @@ namespace Nest [JsonObject] public class AdaptiveSelectionStats { - /// - /// The number of outstanding search requests from the node these stats are for to the keyed node. - /// - [JsonProperty("outgoing_searches")] - public long OutgoingSearches { get; internal set; } - /// /// The exponentially weighted moving average queue size of search requests on the keyed node. /// [JsonProperty("avg_queue_size")] public long AverageQueueSize { get; internal set; } + /// + /// The exponentially weighted moving average response time of search requests on the keyed node. + /// + /// only set when requesting human readable response + [JsonProperty("avg_response_time")] + public long AverageResponseTime { get; internal set; } + + /// + /// The exponentially weighted moving average response time of search requests on the keyed node. + /// + [JsonProperty("avg_response_time_ns")] + public long AverageResponseTimeInNanoseconds { get; internal set; } + /// /// The exponentially weighted moving average service time of search requests on the keyed node. /// @@ -31,17 +38,10 @@ public class AdaptiveSelectionStats public long AverageServiceTimeInNanoseconds { get; internal set; } /// - /// The exponentially weighted moving average response time of search requests on the keyed node. - /// - /// only set when requesting human readable response - [JsonProperty("avg_response_time")] - public long AverageResponseTime { get; internal set; } - - /// - /// The exponentially weighted moving average response time of search requests on the keyed node. + /// The number of outstanding search requests from the node these stats are for to the keyed node. /// - [JsonProperty("avg_response_time_ns")] - public long AverageResponseTimeInNanoseconds { get; internal set; } + [JsonProperty("outgoing_searches")] + public long OutgoingSearches { get; internal set; } /// /// The rank of this node; used for shard selection when routing search requests. @@ -49,4 +49,4 @@ public class AdaptiveSelectionStats [JsonProperty("rank")] public string Rank { get; internal set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cluster/NodesStats/ElasticClient-NodesStats.cs b/src/Nest/Cluster/NodesStats/ElasticClient-NodesStats.cs index 439782f631f..90bbb961b38 100644 --- a/src/Nest/Cluster/NodesStats/ElasticClient-NodesStats.cs +++ b/src/Nest/Cluster/NodesStats/ElasticClient-NodesStats.cs @@ -1,55 +1,61 @@ using System; using System.IO; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; namespace Nest { - using System.Threading; using NodesHotThreadConverter = Func; public partial interface IElasticClient { /// /// The cluster nodes stats API allows to retrieve one or more (or all) of the cluster nodes statistics. - /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html + /// + /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html /// /// An optional descriptor to further describe the nodes stats operation INodesStatsResponse NodesStats(Func selector = null); - /// + /// INodesStatsResponse NodesStats(INodesStatsRequest request); - /// - Task NodesStatsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task NodesStatsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task NodesStatsAsync(INodesStatsRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public INodesStatsResponse NodesStats(Func selector = null) => - this.NodesStats(selector.InvokeOrDefault(new NodesStatsDescriptor())); + NodesStats(selector.InvokeOrDefault(new NodesStatsDescriptor())); - /// + /// public INodesStatsResponse NodesStats(INodesStatsRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.NodesStatsDispatch(p) + (p, d) => LowLevelDispatch.NodesStatsDispatch(p) ); - /// - public Task NodesStatsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.NodesStatsAsync(selector.InvokeOrDefault(new NodesStatsDescriptor()), cancellationToken); + /// + public Task NodesStatsAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + NodesStatsAsync(selector.InvokeOrDefault(new NodesStatsDescriptor()), cancellationToken); - /// - public Task NodesStatsAsync(INodesStatsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task NodesStatsAsync(INodesStatsRequest request, CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.NodesStatsDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.NodesStatsDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/NodesStats/NodeStats.cs b/src/Nest/Cluster/NodesStats/NodeStats.cs index c3155ab06a5..9c505954cf8 100644 --- a/src/Nest/Cluster/NodesStats/NodeStats.cs +++ b/src/Nest/Cluster/NodesStats/NodeStats.cs @@ -6,31 +6,39 @@ namespace Nest [JsonObject] public class NodeStats { - [JsonProperty("timestamp")] - public long Timestamp { get; internal set; } + [JsonProperty("adaptive_selection")] + [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] + public IReadOnlyDictionary AdaptiveSelection { get; internal set; } + = EmptyReadOnly.Dictionary; - [JsonProperty("name")] - public string Name { get; internal set; } + [JsonProperty("breakers")] + [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] + public Dictionary Breakers { get; internal set; } - [JsonProperty("transport_address")] - public string TransportAddress { get; internal set; } + [JsonProperty("fs")] + public FileSystemStats FileSystem { get; internal set; } [JsonProperty("host")] public string Host { get; internal set; } + [JsonProperty("http")] + public HttpStats Http { get; internal set; } + + [JsonProperty("indices")] + public IndexStats Indices { get; internal set; } + + [JsonProperty("ingest")] + public NodeIngestStats Ingest { get; internal set; } + [JsonProperty("ip")] [JsonConverter(typeof(ReadSingleOrEnumerableJsonConverter))] public IEnumerable Ip { get; internal set; } - /// - /// All of the different roles that the node fulfills. An empty - /// collection means that the node is a coordinating only node. - /// - [JsonProperty("roles")] - public IEnumerable Roles { get; internal set; } + [JsonProperty("jvm")] + public NodeJvmStats Jvm { get; internal set; } - [JsonProperty("indices")] - public IndexStats Indices { get; internal set; } + [JsonProperty("name")] + public string Name { get; internal set; } [JsonProperty("os")] public OperatingSystemStats OperatingSystem { get; internal set; } @@ -38,36 +46,28 @@ public class NodeStats [JsonProperty("process")] public ProcessStats Process { get; internal set; } + /// + /// All of the different roles that the node fulfills. An empty + /// collection means that the node is a coordinating only node. + /// + [JsonProperty("roles")] + public IEnumerable Roles { get; internal set; } + [JsonProperty("script")] public ScriptStats Script { get; internal set; } - [JsonProperty("jvm")] - public NodeJvmStats Jvm { get; internal set; } - [JsonProperty("thread_pool")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public Dictionary ThreadPool { get; internal set; } - [JsonProperty("breakers")] - [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] - public Dictionary Breakers { get; internal set; } - - [JsonProperty("fs")] - public FileSystemStats FileSystem { get; internal set; } + [JsonProperty("timestamp")] + public long Timestamp { get; internal set; } [JsonProperty("transport")] public TransportStats Transport { get; internal set; } - [JsonProperty("http")] - public HttpStats Http { get; internal set; } - - [JsonProperty("ingest")] - public NodeIngestStats Ingest { get; internal set; } - - [JsonProperty("adaptive_selection")] - [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] - public IReadOnlyDictionary AdaptiveSelection { get; internal set; } - = EmptyReadOnly.Dictionary; + [JsonProperty("transport_address")] + public string TransportAddress { get; internal set; } } @@ -76,6 +76,7 @@ public class ScriptStats { [JsonProperty("cache_evictions")] public long CacheEvictions { get; internal set; } + [JsonProperty("compilations")] public long Compilations { get; internal set; } } @@ -85,14 +86,19 @@ public class BreakerStats { [JsonProperty("estimated_size")] public string EstimatedSize { get; internal set; } + [JsonProperty("estimated_size_in_bytes")] public long EstimatedSizeInBytes { get; internal set; } + [JsonProperty("limit_size")] public string LimitSize { get; internal set; } + [JsonProperty("limit_size_in_bytes")] public long LimitSizeInBytes { get; internal set; } + [JsonProperty("overhead")] public float Overhead { get; internal set; } + [JsonProperty("tripped")] public float Tripped { get; internal set; } } @@ -100,16 +106,17 @@ public class BreakerStats [JsonObject] public class OperatingSystemStats { - [JsonProperty("timestamp")] - public long Timestamp { get; internal set; } + [JsonProperty("cpu")] + public CPUStats Cpu { get; internal set; } [JsonProperty("mem")] public ExtendedMemoryStats Memory { get; internal set; } + [JsonProperty("swap")] public MemoryStats Swap { get; internal set; } - [JsonProperty("cpu")] - public CPUStats Cpu { get; internal set; } + [JsonProperty("timestamp")] + public long Timestamp { get; internal set; } [JsonObject] public class CPUStats @@ -123,32 +130,32 @@ public class CPUStats [JsonObject] public class LoadAverageStats { - [JsonProperty("1m")] - public float? OneMinute { get; internal set; } + [JsonProperty("15m")] + public float? FifteenMinute { get; internal set; } [JsonProperty("5m")] public float? FiveMinute { get; internal set; } - [JsonProperty("15m")] - public float? FifteenMinute { get; internal set; } + [JsonProperty("1m")] + public float? OneMinute { get; internal set; } } } [JsonObject] public class MemoryStats { - [JsonProperty("total")] - public string Total { get; internal set; } - - [JsonProperty("total_in_bytes")] - public long TotalInBytes { get; internal set; } - [JsonProperty("free")] public string Free { get; internal set; } [JsonProperty("free_in_bytes")] public long FreeInBytes { get; internal set; } + [JsonProperty("total")] + public string Total { get; internal set; } + + [JsonProperty("total_in_bytes")] + public long TotalInBytes { get; internal set; } + [JsonProperty("used")] public string Used { get; internal set; } @@ -161,6 +168,7 @@ public class ExtendedMemoryStats : MemoryStats { [JsonProperty("free_percent")] public int FreePercent { get; internal set; } + [JsonProperty("used_percent")] public int UsedPercent { get; internal set; } } @@ -169,33 +177,41 @@ public class ExtendedMemoryStats : MemoryStats [JsonObject] public class ProcessStats { - [JsonProperty("timestamp")] - public long Timestamp { get; internal set; } - [JsonProperty("open_file_descriptors")] - public int OpenFileDescriptors { get; internal set; } - [JsonProperty("cpu")] public CPUStats CPU { get; internal set; } + [JsonProperty("mem")] public MemoryStats Memory { get; internal set; } + [JsonProperty("open_file_descriptors")] + public int OpenFileDescriptors { get; internal set; } + + [JsonProperty("timestamp")] + public long Timestamp { get; internal set; } + [JsonObject] public class CPUStats { [JsonProperty("percent")] public int Percent { get; internal set; } + [JsonProperty("sys")] public string System { get; internal set; } + [JsonProperty("sys_in_millis")] public long SystemInMilliseconds { get; internal set; } - [JsonProperty("user")] - public string User { get; internal set; } - [JsonProperty("user_in_millis")] - public long UserInMilliseconds { get; internal set; } + [JsonProperty("total")] public string Total { get; internal set; } + [JsonProperty("total_in_millis")] public long TotalInMilliseconds { get; internal set; } + + [JsonProperty("user")] + public string User { get; internal set; } + + [JsonProperty("user_in_millis")] + public long UserInMilliseconds { get; internal set; } } [JsonObject] @@ -203,14 +219,19 @@ public class MemoryStats { [JsonProperty("resident")] public string Resident { get; internal set; } + [JsonProperty("resident_in_bytes")] public long ResidentInBytes { get; internal set; } + [JsonProperty("share")] public string Share { get; internal set; } + [JsonProperty("share_in_bytes")] public long ShareInBytes { get; internal set; } + [JsonProperty("total_virtual")] public string TotalVirtual { get; internal set; } + [JsonProperty("total_virtual_in_bytes")] public long TotalVirtualInBytes { get; internal set; } } @@ -219,19 +240,6 @@ public class MemoryStats [JsonObject] public class NodeJvmStats { - [JsonProperty("timestamp")] - public long Timestamp { get; internal set; } - [JsonProperty("uptime")] - public string Uptime { get; internal set; } - [JsonProperty("uptime_in_millis")] - public long UptimeInMilliseconds { get; internal set; } - [JsonProperty("mem")] - public MemoryStats Memory { get; internal set; } - [JsonProperty("threads")] - public ThreadStats Threads { get; internal set; } - [JsonProperty("gc")] - public GarbageCollectionStats GarbageCollection { get; internal set; } - [JsonProperty("buffer_pools")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public Dictionary BufferPools { get; internal set; } @@ -239,13 +247,33 @@ public class NodeJvmStats [JsonProperty("classes")] public JvmClassesStats Classes { get; internal set; } + [JsonProperty("gc")] + public GarbageCollectionStats GarbageCollection { get; internal set; } + + [JsonProperty("mem")] + public MemoryStats Memory { get; internal set; } + + [JsonProperty("threads")] + public ThreadStats Threads { get; internal set; } + + [JsonProperty("timestamp")] + public long Timestamp { get; internal set; } + + [JsonProperty("uptime")] + public string Uptime { get; internal set; } + + [JsonProperty("uptime_in_millis")] + public long UptimeInMilliseconds { get; internal set; } + [JsonObject] public class JvmClassesStats { [JsonProperty("current_loaded_count")] public long CurrentLoadedCount { get; internal set; } + [JsonProperty("total_loaded_count")] public long TotalLoadedCount { get; internal set; } + [JsonProperty("total_unloaded_count")] public long TotalUnloadedCount { get; internal set; } } @@ -253,28 +281,39 @@ public class JvmClassesStats [JsonObject] public class MemoryStats { - [JsonProperty("heap_used")] - public string HeapUsed { get; internal set; } - [JsonProperty("heap_used_in_bytes")] - public long HeapUsedInBytes { get; internal set; } - [JsonProperty("heap_used_percent")] - public long HeapUsedPercent { get; internal set; } [JsonProperty("heap_committed")] public string HeapCommitted { get; internal set; } + [JsonProperty("heap_committed_in_bytes")] public long HeapCommittedInBytes { get; internal set; } + [JsonProperty("heap_max")] public string HeapMax { get; internal set; } + [JsonProperty("heap_max_in_bytes")] public long HeapMaxInBytes { get; internal set; } - [JsonProperty("non_heap_used")] - public string NonHeapUsed { get; internal set; } - [JsonProperty("non_heap_used_in_bytes")] - public long NonHeapUsedInBytes { get; internal set; } + + [JsonProperty("heap_used")] + public string HeapUsed { get; internal set; } + + [JsonProperty("heap_used_in_bytes")] + public long HeapUsedInBytes { get; internal set; } + + [JsonProperty("heap_used_percent")] + public long HeapUsedPercent { get; internal set; } + [JsonProperty("non_heap_committed")] public string NonHeapCommitted { get; internal set; } + [JsonProperty("non_heap_committed_in_bytes")] public long NonHeapCommittedInBytes { get; internal set; } + + [JsonProperty("non_heap_used")] + public string NonHeapUsed { get; internal set; } + + [JsonProperty("non_heap_used_in_bytes")] + public long NonHeapUsedInBytes { get; internal set; } + [JsonProperty("pools")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public Dictionary Pools { get; internal set; } @@ -282,22 +321,29 @@ public class MemoryStats [JsonObject] public class JVMPool { - [JsonProperty("used")] - public string Used { get; internal set; } - [JsonProperty("used_in_bytes")] - public long UsedInBytes { get; internal set; } [JsonProperty("max")] public string Max { get; internal set; } + [JsonProperty("max_in_bytes")] public long MaxInBytes { get; internal set; } - [JsonProperty("peak_used")] - public string PeakUsed { get; internal set; } - [JsonProperty("peak_used_in_bytes")] - public long PeakUsedInBytes { get; internal set; } + [JsonProperty("peak_max")] public string PeakMax { get; internal set; } + [JsonProperty("peak_max_in_bytes")] public long PeakMaxInBytes { get; internal set; } + + [JsonProperty("peak_used")] + public string PeakUsed { get; internal set; } + + [JsonProperty("peak_used_in_bytes")] + public long PeakUsedInBytes { get; internal set; } + + [JsonProperty("used")] + public string Used { get; internal set; } + + [JsonProperty("used_in_bytes")] + public long UsedInBytes { get; internal set; } } } @@ -306,6 +352,7 @@ public class ThreadStats { [JsonProperty("count")] public long Count { get; internal set; } + [JsonProperty("peak_count")] public long PeakCount { get; internal set; } } @@ -323,8 +370,10 @@ public class GarbageCollectionGenerationStats { [JsonProperty("collection_count")] public long CollectionCount { get; internal set; } + [JsonProperty("collection_time")] public string CollectionTime { get; internal set; } + [JsonProperty("collection_time_in_millis")] public long CollectionTimeInMilliseconds { get; internal set; } } @@ -334,58 +383,72 @@ public class NodeBufferPool { [JsonProperty("count")] public long Count { get; internal set; } - [JsonProperty("used")] - public string Used { get; internal set; } - [JsonProperty("used_in_bytes")] - public long UsedInBytes { get; internal set; } + [JsonProperty("total_capacity")] public string TotalCapacity { get; internal set; } + [JsonProperty("total_capacity_in_bytes")] public long TotalCapacityInBytes { get; internal set; } + + [JsonProperty("used")] + public string Used { get; internal set; } + + [JsonProperty("used_in_bytes")] + public long UsedInBytes { get; internal set; } } } [JsonObject] public class ThreadCountStats { - [JsonProperty("threads")] - public long Threads { get; internal set; } - [JsonProperty("queue")] - public long Queue { get; internal set; } [JsonProperty("active")] public long Active { get; internal set; } - [JsonProperty("rejected")] - public long Rejected { get; internal set; } - [JsonProperty("largest")] - public long Largest { get; internal set; } + [JsonProperty("completed")] public long Completed { get; internal set; } + + [JsonProperty("largest")] + public long Largest { get; internal set; } + + [JsonProperty("queue")] + public long Queue { get; internal set; } + + [JsonProperty("rejected")] + public long Rejected { get; internal set; } + + [JsonProperty("threads")] + public long Threads { get; internal set; } } [JsonObject] public class FileSystemStats { + [JsonProperty("data")] + public IEnumerable Data { get; internal set; } + [JsonProperty("timestamp")] public long Timestamp { get; internal set; } + [JsonProperty("total")] public TotalFileSystemStats Total { get; internal set; } - [JsonProperty("data")] - public IEnumerable Data { get; internal set; } public class TotalFileSystemStats { [JsonProperty("available")] public string Available { get; internal set; } + [JsonProperty("available_in_bytes")] public long AvailableInBytes { get; internal set; } [JsonProperty("free")] public string Free { get; internal set; } + [JsonProperty("free_in_bytes")] public long FreeInBytes { get; internal set; } [JsonProperty("total")] public string Total { get; internal set; } + [JsonProperty("total_in_bytes")] public long TotalInBytes { get; internal set; } } @@ -393,56 +456,77 @@ public class TotalFileSystemStats [JsonObject] public class DataPathStats { - [JsonProperty("path")] - public string Path { get; internal set; } - [JsonProperty("mount")] - public string Mount { get; internal set; } - [JsonProperty("type")] - public string Type { get; internal set; } - [JsonProperty("total")] - public string Total { get; internal set; } - [JsonProperty("total_in_bytes")] - public long TotalInBytes { get; internal set; } - [JsonProperty("free")] - public string Free { get; internal set; } - [JsonProperty("free_in_bytes")] - public long FreeInBytes { get; internal set; } [JsonProperty("available")] public string Available { get; internal set; } + [JsonProperty("available_in_bytes")] public long AvailableInBytes { get; internal set; } + + [JsonProperty("disk_queue")] + public string DiskQueue { get; internal set; } + [JsonProperty("disk_reads")] public long DiskReads { get; internal set; } - [JsonProperty("disk_writes")] - public long DiskWrites { get; internal set; } + [JsonProperty("disk_read_size")] public string DiskReadSize { get; internal set; } + [JsonProperty("disk_read_size_in_bytes")] public long DiskReadSizeInBytes { get; internal set; } + + [JsonProperty("disk_writes")] + public long DiskWrites { get; internal set; } + [JsonProperty("disk_write_size")] public string DiskWriteSize { get; internal set; } + [JsonProperty("disk_write_size_in_bytes")] public long DiskWriteSizeInBytes { get; internal set; } - [JsonProperty("disk_queue")] - public string DiskQueue { get; internal set; } + + [JsonProperty("free")] + public string Free { get; internal set; } + + [JsonProperty("free_in_bytes")] + public long FreeInBytes { get; internal set; } + + [JsonProperty("mount")] + public string Mount { get; internal set; } + + [JsonProperty("path")] + public string Path { get; internal set; } + + [JsonProperty("total")] + public string Total { get; internal set; } + + [JsonProperty("total_in_bytes")] + public long TotalInBytes { get; internal set; } + + [JsonProperty("type")] + public string Type { get; internal set; } } } [JsonObject] public class TransportStats { - [JsonProperty("server_open")] - public int ServerOpen { get; internal set; } [JsonProperty("rx_count")] public long RXCount { get; internal set; } + [JsonProperty("rx_size")] public string RXSize { get; internal set; } + [JsonProperty("rx_size_in_bytes")] public long RXSizeInBytes { get; internal set; } + + [JsonProperty("server_open")] + public int ServerOpen { get; internal set; } + [JsonProperty("tx_count")] public long TXCount { get; internal set; } + [JsonProperty("tx_size")] public string TXSize { get; internal set; } + [JsonProperty("tx_size_in_bytes")] public long TXSizeInBytes { get; internal set; } } @@ -452,6 +536,7 @@ public class HttpStats { [JsonProperty("current_open")] public int CurrentOpen { get; internal set; } + [JsonProperty("total_opened")] public long TotalOpened { get; internal set; } } diff --git a/src/Nest/Cluster/NodesStats/NodeStatsResponse.cs b/src/Nest/Cluster/NodesStats/NodeStatsResponse.cs index d934a39c0b4..38b62fe687d 100644 --- a/src/Nest/Cluster/NodesStats/NodeStatsResponse.cs +++ b/src/Nest/Cluster/NodesStats/NodeStatsResponse.cs @@ -18,6 +18,5 @@ public class NodesStatsResponse : NodesResponseBase, INodesStatsResponse public string ClusterName { get; internal set; } public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; - } } diff --git a/src/Nest/Cluster/NodesStats/Statistics/IngestStats.cs b/src/Nest/Cluster/NodesStats/Statistics/IngestStats.cs index 30683ca9ce2..46afb481de6 100644 --- a/src/Nest/Cluster/NodesStats/Statistics/IngestStats.cs +++ b/src/Nest/Cluster/NodesStats/Statistics/IngestStats.cs @@ -11,12 +11,6 @@ public class IngestStats [JsonProperty("count")] public long Count { get; set; } - /// - /// The total time spent on ingest preprocessing documents during the lifetime of this node - /// - [JsonProperty("time_in_millis")] - public long TimeInMilliseconds { get; set; } - /// /// The total number of documents currently being ingested. /// @@ -28,5 +22,11 @@ public class IngestStats /// [JsonProperty("failed")] public long Failed { get; set; } + + /// + /// The total time spent on ingest preprocessing documents during the lifetime of this node + /// + [JsonProperty("time_in_millis")] + public long TimeInMilliseconds { get; set; } } } diff --git a/src/Nest/Cluster/NodesStats/Statistics/NodeIngestStats.cs b/src/Nest/Cluster/NodesStats/Statistics/NodeIngestStats.cs index 3fac482f7dd..ac076625019 100644 --- a/src/Nest/Cluster/NodesStats/Statistics/NodeIngestStats.cs +++ b/src/Nest/Cluster/NodesStats/Statistics/NodeIngestStats.cs @@ -5,14 +5,14 @@ namespace Nest { public class NodeIngestStats { - /// Overal global ingest statistics - [JsonProperty("total")] - public IngestStats Total { get; set; } - /// Per pipeline ingest statistics [JsonProperty("pipelines")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public IReadOnlyDictionary Pipelines { get; internal set; } = EmptyReadOnly.Dictionary; + + /// Overal global ingest statistics + [JsonProperty("total")] + public IngestStats Total { get; set; } } } diff --git a/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs b/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs index 8c75b05cf8f..b51741e15f7 100644 --- a/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs +++ b/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs @@ -1,55 +1,61 @@ using System; using System.IO; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; namespace Nest { - using System.Threading; using NodesHotThreadConverter = Func; public partial interface IElasticClient { /// /// The cluster nodes usage API allows to retrieve information on the usage of features for each node. - /// https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html /// /// An optional descriptor to further describe the nodes usage operation INodesUsageResponse NodesUsage(Func selector = null); - /// + /// INodesUsageResponse NodesUsage(INodesUsageRequest request); - /// - Task NodesUsageAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task NodesUsageAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task NodesUsageAsync(INodesUsageRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public INodesUsageResponse NodesUsage(Func selector = null) => - this.NodesUsage(selector.InvokeOrDefault(new NodesUsageDescriptor())); + NodesUsage(selector.InvokeOrDefault(new NodesUsageDescriptor())); - /// + /// public INodesUsageResponse NodesUsage(INodesUsageRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.NodesUsageDispatch(p) + (p, d) => LowLevelDispatch.NodesUsageDispatch(p) ); - /// - public Task NodesUsageAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.NodesUsageAsync(selector.InvokeOrDefault(new NodesUsageDescriptor()), cancellationToken); + /// + public Task NodesUsageAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + NodesUsageAsync(selector.InvokeOrDefault(new NodesUsageDescriptor()), cancellationToken); - /// - public Task NodesUsageAsync(INodesUsageRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task NodesUsageAsync(INodesUsageRequest request, CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.NodesUsageDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.NodesUsageDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/NodesUsage/NodeUsageInformation.cs b/src/Nest/Cluster/NodesUsage/NodeUsageInformation.cs index 4fc69e47dda..0c8da6e12df 100644 --- a/src/Nest/Cluster/NodesUsage/NodeUsageInformation.cs +++ b/src/Nest/Cluster/NodesUsage/NodeUsageInformation.cs @@ -6,15 +6,15 @@ namespace Nest { public class NodeUsageInformation { - [JsonProperty("timestamp")] - [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] - public DateTimeOffset Timestamp { get; internal set; } + [JsonProperty("rest_actions")] + public IReadOnlyDictionary RestActions { get; internal set; } [JsonProperty("since")] [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] - public DateTimeOffset Since { get; internal set; } + public DateTimeOffset Since { get; internal set; } - [JsonProperty("rest_actions")] - public IReadOnlyDictionary RestActions { get; internal set; } + [JsonProperty("timestamp")] + [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] + public DateTimeOffset Timestamp { get; internal set; } } -} \ No newline at end of file +} diff --git a/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs index 0684bbc9487..0ca6dfdd9b4 100644 --- a/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs +++ b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs @@ -16,6 +16,7 @@ public class NodesUsageResponse : NodesResponseBase, INodesUsageResponse public string ClusterName { get; internal set; } [JsonProperty("nodes")] - public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; + public IReadOnlyDictionary Nodes { get; internal set; } = + EmptyReadOnly.Dictionary; } } diff --git a/src/Nest/Cluster/Ping/ElasticClient-Ping.cs b/src/Nest/Cluster/Ping/ElasticClient-Ping.cs index 18112bcf3d0..42bdefb4f2c 100644 --- a/src/Nest/Cluster/Ping/ElasticClient-Ping.cs +++ b/src/Nest/Cluster/Ping/ElasticClient-Ping.cs @@ -1,11 +1,11 @@ using System; using System.IO; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; namespace Nest { - using System.Threading; using PingConverter = Func; public partial interface IElasticClient @@ -15,45 +15,50 @@ public partial interface IElasticClient /// IPingResponse Ping(Func selector = null); - /// - Task PingAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task PingAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// IPingResponse Ping(IPingRequest request); - /// + /// Task PingAsync(IPingRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public IPingResponse Ping(Func selector = null) => - this.Ping(selector.InvokeOrDefault(new PingDescriptor())); + Ping(selector.InvokeOrDefault(new PingDescriptor())); - /// - public Task PingAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.PingAsync(selector.InvokeOrDefault(new PingDescriptor()), cancellationToken); - - /// + /// public IPingResponse Ping(IPingRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( SetPingTimeout(request), - (p, d) => this.LowLevelDispatch.PingDispatch(p) + (p, d) => LowLevelDispatch.PingDispatch(p) ); - /// + /// + public Task PingAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + PingAsync(selector.InvokeOrDefault(new PingDescriptor()), cancellationToken); + + /// public Task PingAsync(IPingRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + Dispatcher.DispatchAsync( SetPingTimeout(request), cancellationToken, - (p, d, c) => this.LowLevelDispatch.PingDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.PingDispatchAsync(p, c) ); private IPingRequest SetPingTimeout(IPingRequest pingRequest) { - if (!this.ConnectionSettings.PingTimeout.HasValue) return pingRequest; - var timeout = this.ConnectionSettings.PingTimeout.Value; + if (!ConnectionSettings.PingTimeout.HasValue) return pingRequest; + + var timeout = ConnectionSettings.PingTimeout.Value; return ForceConfiguration(pingRequest, r => r.RequestTimeout = timeout); } } diff --git a/src/Nest/Cluster/Ping/PingResponse.cs b/src/Nest/Cluster/Ping/PingResponse.cs index dc8c58b67d6..dd19ae33854 100644 --- a/src/Nest/Cluster/Ping/PingResponse.cs +++ b/src/Nest/Cluster/Ping/PingResponse.cs @@ -2,12 +2,8 @@ namespace Nest { - public interface IPingResponse : IResponse - { - } + public interface IPingResponse : IResponse { } [JsonObject] - public class PingResponse : ResponseBase, IPingResponse - { - } + public class PingResponse : ResponseBase, IPingResponse { } } diff --git a/src/Nest/Cluster/RemoteInfo/ElasticClient-RemoteInfo.cs b/src/Nest/Cluster/RemoteInfo/ElasticClient-RemoteInfo.cs index cb85115088e..4c938e7addd 100644 --- a/src/Nest/Cluster/RemoteInfo/ElasticClient-RemoteInfo.cs +++ b/src/Nest/Cluster/RemoteInfo/ElasticClient-RemoteInfo.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -9,44 +9,50 @@ public partial interface IElasticClient { /// /// The cluster remote info API allows to retrieve all of the configured remote cluster information. - /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/remote-info.html + /// + /// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/remote-info.html /// /// An optional descriptor to further describe the remote info operation IRemoteInfoResponse RemoteInfo(Func selector = null); - /// + /// IRemoteInfoResponse RemoteInfo(IRemoteInfoRequest request); - /// - Task RemoteInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task RemoteInfoAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task RemoteInfoAsync(IRemoteInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public IRemoteInfoResponse RemoteInfo(Func selector = null) => - this.RemoteInfo(selector.InvokeOrDefault(new RemoteInfoDescriptor())); + RemoteInfo(selector.InvokeOrDefault(new RemoteInfoDescriptor())); - /// + /// public IRemoteInfoResponse RemoteInfo(IRemoteInfoRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.ClusterRemoteInfoDispatch(p) + (p, d) => LowLevelDispatch.ClusterRemoteInfoDispatch(p) ); - /// - public Task RemoteInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.RemoteInfoAsync(selector.InvokeOrDefault(new RemoteInfoDescriptor()), cancellationToken); + /// + public Task RemoteInfoAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + RemoteInfoAsync(selector.InvokeOrDefault(new RemoteInfoDescriptor()), cancellationToken); - /// - public Task RemoteInfoAsync(IRemoteInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task RemoteInfoAsync(IRemoteInfoRequest request, CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.ClusterRemoteInfoDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.ClusterRemoteInfoDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/RemoteInfo/RemoteInfoResponse.cs b/src/Nest/Cluster/RemoteInfo/RemoteInfoResponse.cs index 66acf43a99b..156859e6f67 100644 --- a/src/Nest/Cluster/RemoteInfo/RemoteInfoResponse.cs +++ b/src/Nest/Cluster/RemoteInfo/RemoteInfoResponse.cs @@ -5,7 +5,7 @@ namespace Nest { public interface IRemoteInfoResponse : IResponse { - IReadOnlyDictionary Remotes { get; } + IReadOnlyDictionary Remotes { get; } } [JsonObject] @@ -20,17 +20,20 @@ public class RemoteInfo { [JsonProperty("connected")] public bool Connected { get; internal set; } - [JsonProperty("num_nodes_connected")] - public long NumNodesConnected { get; internal set; } - [JsonProperty("max_connections_per_cluster")] - public int MaxConnectionsPerCluster { get; internal set; } + + [JsonProperty("http_addresses")] + public IReadOnlyCollection HttpAddresses { get; internal set; } = EmptyReadOnly.Collection; + [JsonProperty("initial_connect_timeout")] public Time InitialConnectTimeout { get; internal set; } - [JsonProperty("seeds")] - public IReadOnlyCollection Seeds { get; internal set; }= EmptyReadOnly.Collection; + [JsonProperty("max_connections_per_cluster")] + public int MaxConnectionsPerCluster { get; internal set; } - [JsonProperty("http_addresses")] - public IReadOnlyCollection HttpAddresses { get; internal set; }= EmptyReadOnly.Collection; + [JsonProperty("num_nodes_connected")] + public long NumNodesConnected { get; internal set; } + + [JsonProperty("seeds")] + public IReadOnlyCollection Seeds { get; internal set; } = EmptyReadOnly.Collection; } } diff --git a/src/Nest/Cluster/RootNodeInfo/ElasticClient-RootNodeInfo.cs b/src/Nest/Cluster/RootNodeInfo/ElasticClient-RootNodeInfo.cs index b0409717f47..d27d9a238d7 100644 --- a/src/Nest/Cluster/RootNodeInfo/ElasticClient-RootNodeInfo.cs +++ b/src/Nest/Cluster/RootNodeInfo/ElasticClient-RootNodeInfo.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -13,39 +13,45 @@ public partial interface IElasticClient /// A descriptor to further describe the root operation IRootNodeInfoResponse RootNodeInfo(Func selector = null); - /// + /// IRootNodeInfoResponse RootNodeInfo(IRootNodeInfoRequest request); - /// - Task RootNodeInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task RootNodeInfoAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task RootNodeInfoAsync(IRootNodeInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public IRootNodeInfoResponse RootNodeInfo(Func selector = null) => - this.RootNodeInfo(selector.InvokeOrDefault(new RootNodeInfoDescriptor())); + RootNodeInfo(selector.InvokeOrDefault(new RootNodeInfoDescriptor())); - /// + /// public IRootNodeInfoResponse RootNodeInfo(IRootNodeInfoRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.InfoDispatch(p) + (p, d) => LowLevelDispatch.InfoDispatch(p) ); - /// - public Task RootNodeInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.RootNodeInfoAsync(selector.InvokeOrDefault(new RootNodeInfoDescriptor()), cancellationToken); - - /// - public Task RootNodeInfoAsync(IRootNodeInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task RootNodeInfoAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + RootNodeInfoAsync(selector.InvokeOrDefault(new RootNodeInfoDescriptor()), cancellationToken); + + /// + public Task RootNodeInfoAsync(IRootNodeInfoRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.InfoDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.InfoDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/RootNodeInfo/RootVersionInfoResponse.cs b/src/Nest/Cluster/RootNodeInfo/RootVersionInfoResponse.cs index c0999df2f05..3b7de83a6f9 100644 --- a/src/Nest/Cluster/RootNodeInfo/RootVersionInfoResponse.cs +++ b/src/Nest/Cluster/RootNodeInfo/RootVersionInfoResponse.cs @@ -5,8 +5,8 @@ namespace Nest public interface IRootNodeInfoResponse : IResponse { string Name { get; } - string Tagline { get; } - ElasticsearchVersionInfo Version { get; } + string Tagline { get; } + ElasticsearchVersionInfo Version { get; } } [JsonObject] @@ -20,6 +20,5 @@ public class RootNodeInfoResponse : ResponseBase, IRootNodeInfoResponse [JsonProperty("version")] public ElasticsearchVersionInfo Version { get; internal set; } - } } diff --git a/src/Nest/Cluster/TaskManagement/CancelTasks/CancelTasksResponse.cs b/src/Nest/Cluster/TaskManagement/CancelTasks/CancelTasksResponse.cs index a90075fe38b..2dbce5b2758 100644 --- a/src/Nest/Cluster/TaskManagement/CancelTasks/CancelTasksResponse.cs +++ b/src/Nest/Cluster/TaskManagement/CancelTasks/CancelTasksResponse.cs @@ -1,27 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using Newtonsoft.Json; -using System.Linq; +using System.Collections.Generic; using Elasticsearch.Net; +using Newtonsoft.Json; namespace Nest { [JsonObject(MemberSerialization.OptIn)] - public interface ICancelTasksResponse: IResponse + public interface ICancelTasksResponse : IResponse { - [JsonProperty("nodes")] - IReadOnlyDictionary Nodes { get; } - [JsonProperty("node_failures")] IReadOnlyCollection NodeFailures { get; } + + [JsonProperty("nodes")] + IReadOnlyDictionary Nodes { get; } } public class CancelTasksResponse : ResponseBase, ICancelTasksResponse { - public override bool IsValid => base.IsValid && !this.NodeFailures.HasAny(); + public override bool IsValid => base.IsValid && !NodeFailures.HasAny(); + public IReadOnlyCollection NodeFailures { get; internal set; } = EmptyReadOnly.Collection; public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; - public IReadOnlyCollection NodeFailures { get; internal set; } = EmptyReadOnly.Collection; } } diff --git a/src/Nest/Cluster/TaskManagement/CancelTasks/ElasticClient-CancelTasks.cs b/src/Nest/Cluster/TaskManagement/CancelTasks/ElasticClient-CancelTasks.cs index 0e975cc4376..755421f135a 100644 --- a/src/Nest/Cluster/TaskManagement/CancelTasks/ElasticClient-CancelTasks.cs +++ b/src/Nest/Cluster/TaskManagement/CancelTasks/ElasticClient-CancelTasks.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -13,39 +13,45 @@ public partial interface IElasticClient /// A descriptor to further describe the root operation ICancelTasksResponse CancelTasks(Func selector = null); - /// + /// ICancelTasksResponse CancelTasks(ICancelTasksRequest request); - /// - Task CancelTasksAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task CancelTasksAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task CancelTasksAsync(ICancelTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public ICancelTasksResponse CancelTasks(Func selector = null) => - this.CancelTasks(selector.InvokeOrDefault(new CancelTasksDescriptor())); + CancelTasks(selector.InvokeOrDefault(new CancelTasksDescriptor())); - /// + /// public ICancelTasksResponse CancelTasks(ICancelTasksRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.TasksCancelDispatch(p) + (p, d) => LowLevelDispatch.TasksCancelDispatch(p) ); - /// - public Task CancelTasksAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.CancelTasksAsync(selector.InvokeOrDefault(new CancelTasksDescriptor()), cancellationToken); - - /// - public Task CancelTasksAsync(ICancelTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + /// + public Task CancelTasksAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + CancelTasksAsync(selector.InvokeOrDefault(new CancelTasksDescriptor()), cancellationToken); + + /// + public Task CancelTasksAsync(ICancelTasksRequest request, + CancellationToken cancellationToken = default(CancellationToken) + ) => + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.TasksCancelDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.TasksCancelDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/TaskManagement/GetTask/ElasticClient-GetTask.cs b/src/Nest/Cluster/TaskManagement/GetTask/ElasticClient-GetTask.cs index 2e67a117148..4e5346b0482 100644 --- a/src/Nest/Cluster/TaskManagement/GetTask/ElasticClient-GetTask.cs +++ b/src/Nest/Cluster/TaskManagement/GetTask/ElasticClient-GetTask.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -11,7 +11,9 @@ public partial interface IElasticClient IGetTaskResponse GetTask(IGetTaskRequest request); - Task GetTaskAsync(TaskId id, Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + Task GetTaskAsync(TaskId id, Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); Task GetTaskAsync(IGetTaskRequest request, CancellationToken cancellationToken = default(CancellationToken)); } @@ -19,22 +21,24 @@ public partial interface IElasticClient public partial class ElasticClient { public IGetTaskResponse GetTask(TaskId id, Func selector = null) => - this.GetTask(selector.InvokeOrDefault(new GetTaskDescriptor(id))); + GetTask(selector.InvokeOrDefault(new GetTaskDescriptor(id))); public IGetTaskResponse GetTask(IGetTaskRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.TasksGetDispatch(p) + (p, d) => LowLevelDispatch.TasksGetDispatch(p) ); - public Task GetTaskAsync(TaskId id, Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.GetTaskAsync(selector.InvokeOrDefault(new GetTaskDescriptor(id)), cancellationToken); + public Task GetTaskAsync(TaskId id, Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + GetTaskAsync(selector.InvokeOrDefault(new GetTaskDescriptor(id)), cancellationToken); public Task GetTaskAsync(IGetTaskRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.TasksGetDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.TasksGetDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/TaskManagement/GetTask/GetTaskRequest.cs b/src/Nest/Cluster/TaskManagement/GetTask/GetTaskRequest.cs index ba7d5d089f0..098da689d9b 100644 --- a/src/Nest/Cluster/TaskManagement/GetTask/GetTaskRequest.cs +++ b/src/Nest/Cluster/TaskManagement/GetTask/GetTaskRequest.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Nest { @@ -17,6 +13,6 @@ public partial class GetTaskDescriptor public GetTaskDescriptor() { } [Obsolete("Maintained for binary compatibility. Use the constructor that accepts a task id. Will be removed in 7.0")] - public GetTaskDescriptor TaskId(TaskId taskId) => this.Assign(a => a.RouteValues.Required("task_id", taskId)); + public GetTaskDescriptor TaskId(TaskId taskId) => Assign(a => a.RouteValues.Required("task_id", taskId)); } } diff --git a/src/Nest/Cluster/TaskManagement/GetTask/GetTaskResponse.cs b/src/Nest/Cluster/TaskManagement/GetTask/GetTaskResponse.cs index 88ff856e120..e16c6efe2e2 100644 --- a/src/Nest/Cluster/TaskManagement/GetTask/GetTaskResponse.cs +++ b/src/Nest/Cluster/TaskManagement/GetTask/GetTaskResponse.cs @@ -1,9 +1,4 @@ using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Nest { diff --git a/src/Nest/Cluster/TaskManagement/GetTask/TaskInfo.cs b/src/Nest/Cluster/TaskManagement/GetTask/TaskInfo.cs index d400c7618bd..6b7fa92ed8c 100644 --- a/src/Nest/Cluster/TaskManagement/GetTask/TaskInfo.cs +++ b/src/Nest/Cluster/TaskManagement/GetTask/TaskInfo.cs @@ -1,46 +1,42 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Nest { [JsonObject(MemberSerialization.OptIn)] public class TaskInfo { - [JsonProperty("node")] - public string Node { get; internal set; } - - [JsonProperty("id")] - public long Id { get; internal set; } - - [JsonProperty("type")] - public string Type { get; internal set; } - [JsonProperty("action")] public string Action { get; internal set; } - [JsonProperty("status")] - public TaskStatus Status { get; internal set; } + [JsonProperty("cancellable")] + public bool Cancellable { get; internal set; } + + [JsonProperty("children")] + public IReadOnlyCollection Children { get; internal set; } = EmptyReadOnly.Collection; [JsonProperty("description")] public string Description { get; internal set; } - [JsonProperty("start_time_in_millis")] - public long StartTimeInMilliseconds { get; internal set; } + [JsonProperty("headers")] + public IReadOnlyDictionary Headers { get; internal set; } = EmptyReadOnly.Dictionary; + + [JsonProperty("id")] + public long Id { get; internal set; } + + [JsonProperty("node")] + public string Node { get; internal set; } [JsonProperty("running_time_in_nanos")] public long RunningTimeInNanoseconds { get; internal set; } - [JsonProperty("cancellable")] - public bool Cancellable { get; internal set; } + [JsonProperty("start_time_in_millis")] + public long StartTimeInMilliseconds { get; internal set; } - [JsonProperty("headers")] - public IReadOnlyDictionary Headers { get; internal set; } = EmptyReadOnly.Dictionary; + [JsonProperty("status")] + public TaskStatus Status { get; internal set; } - [JsonProperty("children")] - public IReadOnlyCollection Children { get; internal set; } = EmptyReadOnly.Collection; + [JsonProperty("type")] + public string Type { get; internal set; } } } diff --git a/src/Nest/Cluster/TaskManagement/ListTasks/ElasticClient-ListTasks.cs b/src/Nest/Cluster/TaskManagement/ListTasks/ElasticClient-ListTasks.cs index fa221324674..1d6bd726807 100644 --- a/src/Nest/Cluster/TaskManagement/ListTasks/ElasticClient-ListTasks.cs +++ b/src/Nest/Cluster/TaskManagement/ListTasks/ElasticClient-ListTasks.cs @@ -1,7 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -13,39 +13,43 @@ public partial interface IElasticClient /// A descriptor to further describe the tasks to retrieve information for IListTasksResponse ListTasks(Func selector = null); - /// + /// IListTasksResponse ListTasks(IListTasksRequest request); - /// - Task ListTasksAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + Task ListTasksAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); - /// + /// Task ListTasksAsync(IListTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)); } public partial class ElasticClient { - /// + /// public IListTasksResponse ListTasks(Func selector = null) => - this.ListTasks(selector.InvokeOrDefault(new ListTasksDescriptor())); + ListTasks(selector.InvokeOrDefault(new ListTasksDescriptor())); - /// + /// public IListTasksResponse ListTasks(IListTasksRequest request) => - this.Dispatcher.Dispatch( + Dispatcher.Dispatch( request, - (p, d) => this.LowLevelDispatch.TasksListDispatch(p) + (p, d) => LowLevelDispatch.TasksListDispatch(p) ); - /// - public Task ListTasksAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.ListTasksAsync(selector.InvokeOrDefault(new ListTasksDescriptor()), cancellationToken); + /// + public Task ListTasksAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + ListTasksAsync(selector.InvokeOrDefault(new ListTasksDescriptor()), cancellationToken); - /// + /// public Task ListTasksAsync(IListTasksRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( + Dispatcher.DispatchAsync( request, cancellationToken, - (p, d, c) => this.LowLevelDispatch.TasksListDispatchAsync(p, c) + (p, d, c) => LowLevelDispatch.TasksListDispatchAsync(p, c) ); } } diff --git a/src/Nest/Cluster/TaskManagement/ListTasks/ListTasksResponse.cs b/src/Nest/Cluster/TaskManagement/ListTasks/ListTasksResponse.cs index bf5b8ff7e6b..4cfd59c7e94 100644 --- a/src/Nest/Cluster/TaskManagement/ListTasks/ListTasksResponse.cs +++ b/src/Nest/Cluster/TaskManagement/ListTasks/ListTasksResponse.cs @@ -1,93 +1,85 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using Newtonsoft.Json; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; using Elasticsearch.Net; +using Newtonsoft.Json; namespace Nest { [JsonObject(MemberSerialization.OptIn)] - public interface IListTasksResponse: IResponse + public interface IListTasksResponse : IResponse { - [JsonProperty("nodes")] - IReadOnlyDictionary Nodes { get; } - [JsonProperty("node_failures")] IReadOnlyCollection NodeFailures { get; } + [JsonProperty("nodes")] + IReadOnlyDictionary Nodes { get; } } public class ListTasksResponse : ResponseBase, IListTasksResponse { - public override bool IsValid => base.IsValid && !this.NodeFailures.HasAny(); + public override bool IsValid => base.IsValid && !NodeFailures.HasAny(); + public IReadOnlyCollection NodeFailures { get; internal set; } = EmptyReadOnly.Collection; public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; - public IReadOnlyCollection NodeFailures { get; internal set; } = EmptyReadOnly.Collection; } public class TaskExecutingNode { - [JsonProperty("name")] - public string Name { get; internal set; } - - [JsonProperty("transport_address")] - public string TransportAddress { get; internal set; } - [JsonProperty("host")] public string Host { get; internal set; } [JsonProperty("ip")] public string Ip { get; internal set; } + [JsonProperty("name")] + public string Name { get; internal set; } + [JsonProperty("tasks")] public IReadOnlyDictionary Tasks { get; internal set; } = EmptyReadOnly.Dictionary; + + [JsonProperty("transport_address")] + public string TransportAddress { get; internal set; } } public class TaskState { - [JsonProperty("node")] - public string Node { get; internal set; } - - [JsonProperty("id")] - public long Id { get; internal set; } - - [JsonProperty("type")] - public string Type { get; internal set; } - [JsonProperty("action")] public string Action { get; internal set; } - [JsonProperty("status")] - public TaskStatus Status { get; internal set; } + [JsonProperty("cancellable")] + public bool Cancellable { get; internal set; } [JsonProperty("description")] public string Description { get; internal set; } - [JsonProperty("start_time_in_millis")] - public long StartTimeInMilliseconds { get; internal set; } + [JsonProperty("headers")] + public IReadOnlyDictionary Headers { get; internal set; } = EmptyReadOnly.Dictionary; - [JsonProperty("running_time_in_nanos")] - public long RunningTimeInNanoSeconds { get; internal set; } + [JsonProperty("id")] + public long Id { get; internal set; } + + [JsonProperty("node")] + public string Node { get; internal set; } [JsonProperty("parent_task_id")] public TaskId ParentTaskId { get; internal set; } - [JsonProperty("cancellable")] - public bool Cancellable { get; internal set; } + [JsonProperty("running_time_in_nanos")] + public long RunningTimeInNanoSeconds { get; internal set; } - [JsonProperty("headers")] - public IReadOnlyDictionary Headers { get; internal set; } = EmptyReadOnly.Dictionary; + [JsonProperty("start_time_in_millis")] + public long StartTimeInMilliseconds { get; internal set; } + + [JsonProperty("status")] + public TaskStatus Status { get; internal set; } + + [JsonProperty("type")] + public string Type { get; internal set; } } public class TaskStatus { - [JsonProperty("total")] - public long Total { get; internal set; } - - [JsonProperty("updated")] - public long Updated { get; internal set; } + [JsonProperty("batches")] + public long Batches { get; internal set; } [JsonProperty("created")] public long Created { get; internal set; } @@ -95,26 +87,29 @@ public class TaskStatus [JsonProperty("deleted")] public long Deleted { get; internal set; } - [JsonProperty("batches")] - public long Batches { get; internal set; } - - [JsonProperty("version_conflicts")] - public long VersionConflicts { get; internal set; } - [JsonProperty("noops")] public long Noops { get; internal set; } + [JsonProperty("requests_per_second")] + public long RequestsPerSecond { get; internal set; } + [JsonProperty("retries")] public TaskRetries Retries { get; internal set; } [JsonProperty("throttled_millis")] public long ThrottledMilliseconds { get; internal set; } - [JsonProperty("requests_per_second")] - public long RequestsPerSecond { get; internal set; } - [JsonProperty("throttled_until_millis")] public long ThrottledUntilMilliseconds { get; internal set; } + + [JsonProperty("total")] + public long Total { get; internal set; } + + [JsonProperty("updated")] + public long Updated { get; internal set; } + + [JsonProperty("version_conflicts")] + public long VersionConflicts { get; internal set; } } public class TaskRetries diff --git a/src/Nest/CommonAbstractions/ConnectionSettings/ClrPropertyMapping.cs b/src/Nest/CommonAbstractions/ConnectionSettings/ClrPropertyMapping.cs index 4db5de2a669..2296428db60 100644 --- a/src/Nest/CommonAbstractions/ConnectionSettings/ClrPropertyMapping.cs +++ b/src/Nest/CommonAbstractions/ConnectionSettings/ClrPropertyMapping.cs @@ -6,24 +6,24 @@ namespace Nest public abstract class ClrPropertyMappingBase : IClrPropertyMapping where TDocument : class { - Expression> IClrPropertyMapping.Property { get; set; } - bool IClrPropertyMapping.Ignore { get; set; } - string IClrPropertyMapping.NewName { get; set; } + protected ClrPropertyMappingBase(Expression> property) => Self.Property = property; protected IClrPropertyMapping Self => this; - - protected ClrPropertyMappingBase(Expression> property) => Self.Property = property; + bool IClrPropertyMapping.Ignore { get; set; } + string IClrPropertyMapping.NewName { get; set; } + Expression> IClrPropertyMapping.Property { get; set; } IPropertyMapping IClrPropertyMapping.ToPropertyMapping() => Self.Ignore ? PropertyMapping.Ignored - : new PropertyMapping {Name = Self.NewName}; + : new PropertyMapping { Name = Self.NewName }; } public interface IClrPropertyMapping where TDocument : class { - Expression> Property { get; set; } bool Ignore { get; set; } string NewName { get; set; } + Expression> Property { get; set; } + IPropertyMapping ToPropertyMapping(); } diff --git a/src/Nest/CommonAbstractions/ConnectionSettings/ClrTypeDefaults.cs b/src/Nest/CommonAbstractions/ConnectionSettings/ClrTypeDefaults.cs index e0d72d786fe..52af7481964 100644 --- a/src/Nest/CommonAbstractions/ConnectionSettings/ClrTypeDefaults.cs +++ b/src/Nest/CommonAbstractions/ConnectionSettings/ClrTypeDefaults.cs @@ -12,25 +12,24 @@ public interface IClrTypeMapping Type ClrType { get; } /// - /// The default Elasticsearch index name for + /// The property for to resolve ids from. /// - string IndexName { get; set; } + string IdPropertyName { get; set; } /// - /// The default Elasticsearch type name for + /// The default Elasticsearch index name for /// - string TypeName { get; set; } + string IndexName { get; set; } /// - /// The relation name for to resolve to. + /// The relation name for to resolve to. /// string RelationName { get; set; } /// - /// The property for to resolve ids from. + /// The default Elasticsearch type name for /// - string IdPropertyName { get; set; } - + string TypeName { get; set; } } public interface IClrTypeMapping : IClrTypeMapping where TDocument : class @@ -38,19 +37,19 @@ public interface IClrTypeMapping : IClrTypeMapping where TDocument : /// Set a default Id property on CLR type that NEST will evaluate Expression> IdProperty { get; set; } - /// Provide a default routing parameter lookup based on - Expression> RoutingProperty { get; set; } - /// /// Ignore or rename certain properties of CLR type /// IList> Properties { get; set; } + + /// Provide a default routing parameter lookup based on + Expression> RoutingProperty { get; set; } } public class ClrTypeMapping : IClrTypeMapping { /// - /// Initializes a new instance of + /// Initializes a new instance of /// public ClrTypeMapping(Type type) => ClrType = type; @@ -58,17 +57,18 @@ public class ClrTypeMapping : IClrTypeMapping public Type ClrType { get; } /// - public string IndexName { get; set; } + public string IdPropertyName { get; set; } /// - public string TypeName { get; set; } + public string IndexName { get; set; } /// public string RelationName { get; set; } /// - public string IdPropertyName { get; set; } + public string TypeName { get; set; } } + public class ClrTypeMapping : ClrTypeMapping, IClrTypeMapping where TDocument : class { public ClrTypeMapping() : base(typeof(TDocument)) { } @@ -77,27 +77,27 @@ public ClrTypeMapping() : base(typeof(TDocument)) { } public Expression> IdProperty { get; set; } /// - public Expression> RoutingProperty { get; set; } + public IList> Properties { get; set; } /// - public IList> Properties { get; set; } + public Expression> RoutingProperty { get; set; } } - public class ClrTypeMappingDescriptor : DescriptorBase , IClrTypeMapping + public class ClrTypeMappingDescriptor : DescriptorBase, IClrTypeMapping { private readonly Type _type; /// - /// Instantiates a new instance of + /// Instantiates a new instance of /// /// The CLR type to map public ClrTypeMappingDescriptor(Type type) => _type = type; Type IClrTypeMapping.ClrType => _type; + string IClrTypeMapping.IdPropertyName { get; set; } string IClrTypeMapping.IndexName { get; set; } - string IClrTypeMapping.TypeName { get; set; } string IClrTypeMapping.RelationName { get; set; } - string IClrTypeMapping.IdPropertyName { get; set; } + string IClrTypeMapping.TypeName { get; set; } /// /// The default Elasticsearch index name for the CLR type @@ -121,20 +121,20 @@ public class ClrTypeMappingDescriptor : DescriptorBase - : DescriptorBase,IClrTypeMapping>, IClrTypeMapping + : DescriptorBase, IClrTypeMapping>, IClrTypeMapping where TDocument : class { - Type IClrTypeMapping.ClrType { get; } = typeof (TDocument); + Type IClrTypeMapping.ClrType { get; } = typeof(TDocument); + Expression> IClrTypeMapping.IdProperty { get; set; } + string IClrTypeMapping.IdPropertyName { get; set; } string IClrTypeMapping.IndexName { get; set; } - string IClrTypeMapping.TypeName { get; set; } + IList> IClrTypeMapping.Properties { get; set; } = new List>(); string IClrTypeMapping.RelationName { get; set; } - string IClrTypeMapping.IdPropertyName { get; set; } - Expression> IClrTypeMapping.IdProperty { get; set; } Expression> IClrTypeMapping.RoutingProperty { get; set; } - IList> IClrTypeMapping.Properties { get; set; } = new List>(); + string IClrTypeMapping.TypeName { get; set; } /// - /// The default Elasticsearch index name for + /// The default Elasticsearch index name for /// public ClrTypeMappingDescriptor IndexName(string indexName) => Assign(a => a.IndexName = indexName); @@ -159,7 +159,8 @@ public class ClrTypeMappingDescriptor public ClrTypeMappingDescriptor IdProperty(string property) => Assign(a => a.IdPropertyName = property); /// Provide a default routing parameter lookup based on - public ClrTypeMappingDescriptor RoutingProperty(Expression> property) => Assign(a => a.RoutingProperty = property); + public ClrTypeMappingDescriptor RoutingProperty(Expression> property) => + Assign(a => a.RoutingProperty = property); /// /// Ignore on CLR type @@ -172,6 +173,5 @@ public ClrTypeMappingDescriptor Ignore(Expression public ClrTypeMappingDescriptor PropertyName(Expression> property, string newName) => Assign(a => a.Properties.Add(new RenameClrPropertyMapping(property, newName))); - } } diff --git a/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsBase.cs b/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsBase.cs index 212a52299ab..0925d70993f 100644 --- a/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsBase.cs +++ b/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsBase.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Linq.Expressions; @@ -10,7 +9,7 @@ namespace Nest { /// - /// Provides the connection settings for NEST's + /// Provides the connection settings for NEST's /// public class ConnectionSettings : ConnectionSettingsBase { @@ -20,8 +19,8 @@ public ConnectionSettings(Uri uri = null) : this(new SingleNodeConnectionPool(uri ?? new Uri("http://localhost:9200"))) { } /// - /// Instantiate connection settings using a using the provided - /// that never uses any IO. + /// Instantiate connection settings using a using the provided + /// that never uses any IO. /// public ConnectionSettings(InMemoryConnection connection) : this(new SingleNodeConnectionPool(new Uri("http://localhost:9200")), connection) { } @@ -40,56 +39,43 @@ public ConnectionSettings( IConnectionPool connectionPool, IConnection connection, SourceSerializerFactory sourceSerializer, - IPropertyMappingProvider propertyMappingProvider) + IPropertyMappingProvider propertyMappingProvider + ) : base(connectionPool, connection, sourceSerializer, propertyMappingProvider) { } } /// - /// Provides the connection settings for NEST's + /// Provides the connection settings for NEST's /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public abstract class ConnectionSettingsBase : ConnectionConfiguration, IConnectionSettingsValues where TConnectionSettings : ConnectionSettingsBase, IConnectionSettingsValues { - private string _defaultIndex; - string IConnectionSettingsValues.DefaultIndex => this._defaultIndex; - - private string _defaultTypeName; - string IConnectionSettingsValues.DefaultTypeName => this._defaultTypeName; - - private readonly Inferrer _inferrer; - Inferrer IConnectionSettingsValues.Inferrer => _inferrer; - - private Func _defaultTypeNameInferrer; - Func IConnectionSettingsValues.DefaultTypeNameInferrer => _defaultTypeNameInferrer; - private readonly FluentDictionary _defaultIndices; - FluentDictionary IConnectionSettingsValues.DefaultIndices => _defaultIndices; - - private readonly FluentDictionary _defaultTypeNames; - FluentDictionary IConnectionSettingsValues.DefaultTypeNames => _defaultTypeNames; private readonly FluentDictionary _defaultRelationNames; - FluentDictionary IConnectionSettingsValues.DefaultRelationNames => _defaultRelationNames; - private Func _defaultFieldNameInferrer; - Func IConnectionSettingsValues.DefaultFieldNameInferrer => _defaultFieldNameInferrer; + private readonly FluentDictionary _defaultTypeNames; private readonly FluentDictionary _idProperties = new FluentDictionary(); - FluentDictionary IConnectionSettingsValues.IdProperties => _idProperties; - private readonly FluentDictionary _routeProperties = new FluentDictionary(); - FluentDictionary IConnectionSettingsValues.RouteProperties => _routeProperties; + private readonly Inferrer _inferrer; + + private readonly IPropertyMappingProvider _propertyMappingProvider; private readonly FluentDictionary _propertyMappings = new FluentDictionary(); - FluentDictionary IConnectionSettingsValues.PropertyMappings => _propertyMappings; + + private readonly FluentDictionary _routeProperties = new FluentDictionary(); private readonly IElasticsearchSerializer _sourceSerializer; - IElasticsearchSerializer IConnectionSettingsValues.SourceSerializer => _sourceSerializer; - private readonly IPropertyMappingProvider _propertyMappingProvider; - IPropertyMappingProvider IConnectionSettingsValues.PropertyMappingProvider => _propertyMappingProvider; + private Func _defaultFieldNameInferrer; + private string _defaultIndex; + + private string _defaultTypeName; + + private Func _defaultTypeNameInferrer; protected ConnectionSettingsBase( IConnectionPool connectionPool, @@ -100,40 +86,55 @@ IPropertyMappingProvider propertyMappingProvider : base(connectionPool, connection, null) { var defaultSerializer = new InternalSerializer(this); - this._sourceSerializer = sourceSerializerFactory?.Invoke(defaultSerializer, this) ?? defaultSerializer; - this.UseThisRequestResponseSerializer = defaultSerializer; - this._propertyMappingProvider = propertyMappingProvider ?? new PropertyMappingProvider(); + _sourceSerializer = sourceSerializerFactory?.Invoke(defaultSerializer, this) ?? defaultSerializer; + UseThisRequestResponseSerializer = defaultSerializer; + _propertyMappingProvider = propertyMappingProvider ?? new PropertyMappingProvider(); - this._defaultTypeNameInferrer = (t => !this._defaultTypeName.IsNullOrEmpty() ? this._defaultTypeName : t.Name.ToLowerInvariant()); - this._defaultFieldNameInferrer = (p => p.ToCamelCase()); - this._defaultIndices = new FluentDictionary(); - this._defaultTypeNames = new FluentDictionary(); - this._defaultRelationNames = new FluentDictionary(); + _defaultTypeNameInferrer = t => !_defaultTypeName.IsNullOrEmpty() ? _defaultTypeName : t.Name.ToLowerInvariant(); + _defaultFieldNameInferrer = p => p.ToCamelCase(); + _defaultIndices = new FluentDictionary(); + _defaultTypeNames = new FluentDictionary(); + _defaultRelationNames = new FluentDictionary(); - this._inferrer = new Inferrer(this); + _inferrer = new Inferrer(this); } + Func IConnectionSettingsValues.DefaultFieldNameInferrer => _defaultFieldNameInferrer; + string IConnectionSettingsValues.DefaultIndex => _defaultIndex; + FluentDictionary IConnectionSettingsValues.DefaultIndices => _defaultIndices; + FluentDictionary IConnectionSettingsValues.DefaultRelationNames => _defaultRelationNames; + string IConnectionSettingsValues.DefaultTypeName => _defaultTypeName; + Func IConnectionSettingsValues.DefaultTypeNameInferrer => _defaultTypeNameInferrer; + FluentDictionary IConnectionSettingsValues.DefaultTypeNames => _defaultTypeNames; + FluentDictionary IConnectionSettingsValues.IdProperties => _idProperties; + Inferrer IConnectionSettingsValues.Inferrer => _inferrer; + IPropertyMappingProvider IConnectionSettingsValues.PropertyMappingProvider => _propertyMappingProvider; + FluentDictionary IConnectionSettingsValues.PropertyMappings => _propertyMappings; + FluentDictionary IConnectionSettingsValues.RouteProperties => _routeProperties; + IElasticsearchSerializer IConnectionSettingsValues.SourceSerializer => _sourceSerializer; + /// /// The default index to use when no index is specified. /// - /// When null/empty/not set might throw - /// later on when not specifying index explicitly while indexing. + /// + /// When null/empty/not set might throw + /// later on when not specifying index explicitly while indexing. /// public TConnectionSettings DefaultIndex(string defaultIndex) { - this._defaultIndex = defaultIndex; - return (TConnectionSettings) this; + _defaultIndex = defaultIndex; + return (TConnectionSettings)this; } /// - /// Sets a default type name to use within Elasticsearch for all CLR types. If is also set, a configured - /// default type name will only be used when returns null or empty. If unset, the default type + /// Sets a default type name to use within Elasticsearch for all CLR types. If is also set, a configured + /// default type name will only be used when returns null or empty. If unset, the default type /// name for types will be the lowercased CLR type name. /// public TConnectionSettings DefaultTypeName(string defaultTypeName) { - this._defaultTypeName = defaultTypeName; - return (TConnectionSettings) this; + _defaultTypeName = defaultTypeName; + return (TConnectionSettings)this; } /// @@ -144,20 +145,20 @@ public TConnectionSettings DefaultTypeName(string defaultTypeName) /// public TConnectionSettings DefaultFieldNameInferrer(Func fieldNameInferrer) { - this._defaultFieldNameInferrer = fieldNameInferrer; - return (TConnectionSettings) this; + _defaultFieldNameInferrer = fieldNameInferrer; + return (TConnectionSettings)this; } /// /// Specify how type names are inferred from POCO types. - /// By default, type names are inferred by calling - /// on the type's name. + /// By default, type names are inferred by calling + /// on the type's name. /// public TConnectionSettings DefaultTypeNameInferrer(Func typeNameInferrer) { typeNameInferrer.ThrowIfNull(nameof(typeNameInferrer)); - this._defaultTypeNameInferrer = typeNameInferrer; - return (TConnectionSettings) this; + _defaultTypeNameInferrer = typeNameInferrer; + return (TConnectionSettings)this; } /// @@ -171,15 +172,15 @@ private void MapIdPropertyFor(Expression> obj var memberInfo = new MemberInfoResolver(objectPath); var fieldName = memberInfo.Members.Single().Name; - if (this._idProperties.ContainsKey(typeof(TDocument))) + if (_idProperties.ContainsKey(typeof(TDocument))) { - if (this._idProperties[typeof(TDocument)].Equals(fieldName)) return; + if (_idProperties[typeof(TDocument)].Equals(fieldName)) return; throw new ArgumentException( - $"Cannot map '{fieldName}' as the id property for type '{typeof(TDocument).Name}': it already has '{this._idProperties[typeof(TDocument)]}' mapped."); + $"Cannot map '{fieldName}' as the id property for type '{typeof(TDocument).Name}': it already has '{_idProperties[typeof(TDocument)]}' mapped."); } - this._idProperties.Add(typeof(TDocument), fieldName); + _idProperties.Add(typeof(TDocument), fieldName); } private void MapRoutePropertyFor(Expression> objectPath) @@ -189,15 +190,15 @@ private void MapRoutePropertyFor(Expression> var memberInfo = new MemberInfoResolver(objectPath); var fieldName = memberInfo.Members.Single().Name; - if (this._routeProperties.ContainsKey(typeof(TDocument))) + if (_routeProperties.ContainsKey(typeof(TDocument))) { - if (this._routeProperties[typeof(TDocument)].Equals(fieldName)) return; + if (_routeProperties[typeof(TDocument)].Equals(fieldName)) return; throw new ArgumentException( - $"Cannot map '{fieldName}' as the route property for type '{typeof(TDocument).Name}': it already has '{this._routeProperties[typeof(TDocument)]}' mapped."); + $"Cannot map '{fieldName}' as the route property for type '{typeof(TDocument).Name}': it already has '{_routeProperties[typeof(TDocument)]}' mapped."); } - this._routeProperties.Add(typeof(TDocument), fieldName); + _routeProperties.Add(typeof(TDocument), fieldName); } private void ApplyPropertyMappings(IList> mappings) @@ -225,7 +226,9 @@ private void ApplyPropertyMappings(IList(Func()); if (!inferMapping.IndexName.IsNullOrEmpty()) - this._defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName); + _defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName); if (!inferMapping.TypeName.IsNullOrEmpty()) - this._defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName); + _defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName); if (!inferMapping.RelationName.IsNullOrEmpty()) - this._defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName); + _defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName); if (!string.IsNullOrWhiteSpace(inferMapping.IdPropertyName)) - this._idProperties[inferMapping.ClrType] = inferMapping.IdPropertyName; + _idProperties[inferMapping.ClrType] = inferMapping.IdPropertyName; if (inferMapping.IdProperty != null) - this.MapIdPropertyFor(inferMapping.IdProperty); + MapIdPropertyFor(inferMapping.IdProperty); if (inferMapping.RoutingProperty != null) - this.MapRoutePropertyFor(inferMapping.RoutingProperty); + MapRoutePropertyFor(inferMapping.RoutingProperty); if (inferMapping.Properties != null) - this.ApplyPropertyMappings(inferMapping.Properties); + ApplyPropertyMappings(inferMapping.Properties); - return (TConnectionSettings) this; + return (TConnectionSettings)this; } /// @@ -281,18 +284,18 @@ public TConnectionSettings DefaultMappingFor(Type documentType, Func @@ -301,20 +304,21 @@ public TConnectionSettings DefaultMappingFor(Type documentType, FuncThe mappings for the POCO types you wish to configure public TConnectionSettings DefaultMappingFor(IEnumerable typeMappings) { - if (typeMappings == null) return (TConnectionSettings) this; + if (typeMappings == null) return (TConnectionSettings)this; + foreach (var inferMapping in typeMappings) { if (!inferMapping.IndexName.IsNullOrEmpty()) - this._defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName); + _defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName); if (!inferMapping.TypeName.IsNullOrEmpty()) - this._defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName); + _defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName); if (!inferMapping.RelationName.IsNullOrEmpty()) - this._defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName); + _defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName); } - return (TConnectionSettings) this; + return (TConnectionSettings)this; } } } diff --git a/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsValuesExtensions.cs b/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsValuesExtensions.cs index a23677b2458..9124f846253 100644 --- a/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsValuesExtensions.cs +++ b/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsValuesExtensions.cs @@ -1,5 +1,4 @@ using System; -using Elasticsearch.Net; using Newtonsoft.Json; namespace Nest @@ -8,8 +7,9 @@ internal static class ConnectionSettingsValuesExtensions { public static InternalSerializer CreateStateful(this IConnectionSettingsValues settings, JsonConverter converter) { - var s = (settings as ConnectionSettings) - ?? throw new NullReferenceException($"Stateful serializer expected {nameof(IConnectionSettingsValues)} to be {nameof(ConnectionSettings)}"); + var s = settings as ConnectionSettings + ?? throw new NullReferenceException( + $"Stateful serializer expected {nameof(IConnectionSettingsValues)} to be {nameof(ConnectionSettings)}"); return StatefulSerializerFactory.CreateStateful(s, converter); } diff --git a/src/Nest/CommonAbstractions/ConnectionSettings/IConnectionSettingsValues.cs b/src/Nest/CommonAbstractions/ConnectionSettings/IConnectionSettingsValues.cs index 454ce57cd59..f1fbb261a6b 100644 --- a/src/Nest/CommonAbstractions/ConnectionSettings/IConnectionSettingsValues.cs +++ b/src/Nest/CommonAbstractions/ConnectionSettings/IConnectionSettingsValues.cs @@ -1,28 +1,26 @@ using System; -using System.Collections.ObjectModel; using System.Reflection; using Elasticsearch.Net; -using Newtonsoft.Json; namespace Nest { public interface IConnectionSettingsValues : IConnectionConfigurationValues { - Inferrer Inferrer { get; } - FluentDictionary DefaultIndices { get; } - FluentDictionary DefaultTypeNames { get; } - FluentDictionary DefaultRelationNames { get; } - FluentDictionary IdProperties { get; } - FluentDictionary RouteProperties { get; } - FluentDictionary PropertyMappings { get; } + Func DefaultFieldNameInferrer { get; } string DefaultIndex { get; } + FluentDictionary DefaultIndices { get; } + FluentDictionary DefaultRelationNames { get; } string DefaultTypeName { get; } Func DefaultTypeNameInferrer { get; } - Func DefaultFieldNameInferrer { get; } + FluentDictionary DefaultTypeNames { get; } + FluentDictionary IdProperties { get; } + Inferrer Inferrer { get; } + IPropertyMappingProvider PropertyMappingProvider { get; } + FluentDictionary PropertyMappings { get; } + FluentDictionary RouteProperties { get; } IElasticsearchSerializer SourceSerializer { get; } - IPropertyMappingProvider PropertyMappingProvider { get; } } } diff --git a/src/Nest/CommonAbstractions/ConnectionSettings/MemberInfoResolver.cs b/src/Nest/CommonAbstractions/ConnectionSettings/MemberInfoResolver.cs index 54bd1d60406..51ef47da4b8 100644 --- a/src/Nest/CommonAbstractions/ConnectionSettings/MemberInfoResolver.cs +++ b/src/Nest/CommonAbstractions/ConnectionSettings/MemberInfoResolver.cs @@ -9,18 +9,14 @@ namespace Nest /// public class MemberInfoResolver : ExpressionVisitor { - private readonly IList _members = new List(); - public IList Members { get { return _members; } } + public MemberInfoResolver(Expression expression) => Visit(expression); - public MemberInfoResolver(Expression expression) - { - base.Visit(expression); - } + public IList Members { get; } = new List(); protected override Expression VisitMember(MemberExpression expression) { - this._members.Add(expression.Member); + Members.Add(expression.Member); return base.VisitMember(expression); } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IIsADictionary.cs b/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IIsADictionary.cs index de9424ae5ae..c0856b15774 100644 --- a/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IIsADictionary.cs +++ b/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IIsADictionary.cs @@ -2,7 +2,7 @@ namespace Nest { - public interface IIsADictionary {} - public interface IIsADictionary : IDictionary, IIsADictionary {} + public interface IIsADictionary { } + public interface IIsADictionary : IDictionary, IIsADictionary { } } diff --git a/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryBase.cs b/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryBase.cs index 75e77f23cf4..9c3154ac0f3 100644 --- a/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryBase.cs +++ b/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryBase.cs @@ -1,66 +1,74 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Linq; namespace Nest { public abstract class IsADictionaryBase : IIsADictionary { - protected Dictionary BackingDictionary { get; } - private ICollection> Self => BackingDictionary; - - protected IsADictionaryBase() => this.BackingDictionary = new Dictionary(); + protected IsADictionaryBase() => BackingDictionary = new Dictionary(); protected IsADictionaryBase(IDictionary backingDictionary) { if (backingDictionary != null) - foreach (var key in backingDictionary.Keys) ValidateKey(Sanitize(key)); + foreach (var key in backingDictionary.Keys) + ValidateKey(Sanitize(key)); - this.BackingDictionary = backingDictionary != null + BackingDictionary = backingDictionary != null ? new Dictionary(backingDictionary) : new Dictionary(); } - IEnumerator IEnumerable.GetEnumerator() => this.BackingDictionary.GetEnumerator(); - - IEnumerator> IEnumerable>.GetEnumerator() => this.BackingDictionary.GetEnumerator(); + public TValue this[TKey key] + { + get => BackingDictionary[Sanitize(key)]; + set => BackingDictionary[ValidateKey(Sanitize(key))] = value; + } - void ICollection>.Clear() => this.BackingDictionary.Clear(); - [EditorBrowsable(EditorBrowsableState.Never)] - bool ICollection>.Contains(KeyValuePair item) => Self.Contains(item); - void ICollection>.CopyTo( KeyValuePair[] array, int arrayIndex) => Self.CopyTo(array, arrayIndex); - int ICollection>.Count => this.BackingDictionary.Count; + protected Dictionary BackingDictionary { get; } + int ICollection>.Count => BackingDictionary.Count; bool ICollection>.IsReadOnly => Self.IsReadOnly; - bool ICollection>.Remove(KeyValuePair item) => Self.Remove(item); + + TValue IDictionary.this[TKey key] + { + get => BackingDictionary[Sanitize(key)]; + set => BackingDictionary[ValidateKey(Sanitize(key))] = value; + } + + ICollection IDictionary.Keys => BackingDictionary.Keys; + private ICollection> Self => BackingDictionary; + ICollection IDictionary.Values => BackingDictionary.Values; + void ICollection>.Add(KeyValuePair item) { ValidateKey(Sanitize(item.Key)); Self.Add(item); } - ICollection IDictionary.Keys => this.BackingDictionary.Keys; - ICollection IDictionary.Values => this.BackingDictionary.Values; + void ICollection>.Clear() => BackingDictionary.Clear(); + + [EditorBrowsable(EditorBrowsableState.Never)] + bool ICollection>.Contains(KeyValuePair item) => Self.Contains(item); + + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) => Self.CopyTo(array, arrayIndex); + + bool ICollection>.Remove(KeyValuePair item) => Self.Remove(item); + + void IDictionary.Add(TKey key, TValue value) => BackingDictionary.Add(ValidateKey(Sanitize(key)), value); [EditorBrowsable(EditorBrowsableState.Never)] - bool IDictionary.ContainsKey(TKey key) => this.BackingDictionary.ContainsKey(Sanitize(key)); - void IDictionary.Add(TKey key, TValue value) => this.BackingDictionary.Add(ValidateKey(Sanitize(key)), value); - bool IDictionary.Remove(TKey key) => this.BackingDictionary.Remove(Sanitize(key)); - bool IDictionary.TryGetValue(TKey key, out TValue value) => this.BackingDictionary.TryGetValue(Sanitize(key), out value); + bool IDictionary.ContainsKey(TKey key) => BackingDictionary.ContainsKey(Sanitize(key)); - protected virtual TKey ValidateKey(TKey key) => key; - protected virtual TKey Sanitize(TKey key) => key; + bool IDictionary.Remove(TKey key) => BackingDictionary.Remove(Sanitize(key)); - TValue IDictionary.this[TKey key] - { - get => this.BackingDictionary[Sanitize(key)]; - set => this.BackingDictionary[ValidateKey(Sanitize(key))] = value; - } + bool IDictionary.TryGetValue(TKey key, out TValue value) => BackingDictionary.TryGetValue(Sanitize(key), out value); - public TValue this[TKey key] - { - get => this.BackingDictionary[Sanitize(key)]; - set => this.BackingDictionary[ValidateKey(Sanitize(key))] = value; - } + IEnumerator IEnumerable.GetEnumerator() => BackingDictionary.GetEnumerator(); + + IEnumerator> IEnumerable>.GetEnumerator() => BackingDictionary.GetEnumerator(); + + protected virtual TKey ValidateKey(TKey key) => key; + + protected virtual TKey Sanitize(TKey key) => key; } } diff --git a/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryDescriptorBase.cs b/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryDescriptorBase.cs index f750420010e..f245cc7a0fc 100644 --- a/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryDescriptorBase.cs +++ b/src/Nest/CommonAbstractions/DictionaryLike/IsADictionary/IsADictionaryDescriptorBase.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Nest { public abstract class IsADictionaryDescriptorBase @@ -7,7 +5,7 @@ public abstract class IsADictionaryDescriptorBase where TInterface : class, IIsADictionary { - protected IsADictionaryDescriptorBase(TInterface instance) : base(instance) {} + protected IsADictionaryDescriptorBase(TInterface instance) : base(instance) { } protected TDescriptor Assign(TKey key, TValue value) => Assign(a => a.Add(key, value)); } diff --git a/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IIsAReadOnlyDictionary.cs b/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IIsAReadOnlyDictionary.cs index 7bd3d87be96..02828760442 100644 --- a/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IIsAReadOnlyDictionary.cs +++ b/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IIsAReadOnlyDictionary.cs @@ -2,7 +2,7 @@ namespace Nest { - public interface IIsAReadOnlyDictionary {} - public interface IIsAReadOnlyDictionary : IReadOnlyDictionary, IIsAReadOnlyDictionary {} + public interface IIsAReadOnlyDictionary { } + public interface IIsAReadOnlyDictionary : IReadOnlyDictionary, IIsAReadOnlyDictionary { } } diff --git a/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IsADictionaryBase.cs b/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IsADictionaryBase.cs index 9f41d61a755..f8b79653ade 100644 --- a/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IsADictionaryBase.cs +++ b/src/Nest/CommonAbstractions/DictionaryLike/IsAReadOnlyDictionary/IsADictionaryBase.cs @@ -1,13 +1,10 @@ using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; namespace Nest { public abstract class IsAReadOnlyDictionaryBase : IIsAReadOnlyDictionary { - protected internal IReadOnlyDictionary BackingDictionary { get; } = EmptyReadOnly.Dictionary; - protected IsAReadOnlyDictionaryBase(IReadOnlyDictionary backingDictionary) { if (backingDictionary == null) return; @@ -18,27 +15,28 @@ protected IsAReadOnlyDictionaryBase(IReadOnlyDictionary backingDic // expect all implementations of Sanitize to be pure dictionary[Sanitize(key)] = backingDictionary[key]; - this.BackingDictionary = dictionary; + BackingDictionary = dictionary; } - protected virtual TKey Sanitize(TKey key) => key; + public int Count => BackingDictionary.Count; - IEnumerator> IEnumerable>.GetEnumerator() => - this.BackingDictionary.GetEnumerator(); + public TValue this[TKey key] => BackingDictionary[key]; - IEnumerator IEnumerable.GetEnumerator() => this.BackingDictionary.GetEnumerator(); + public IEnumerable Keys => BackingDictionary.Keys; - public int Count => this.BackingDictionary.Count; + public IEnumerable Values => BackingDictionary.Values; + protected internal IReadOnlyDictionary BackingDictionary { get; } = EmptyReadOnly.Dictionary; - public bool ContainsKey(TKey key) => this.BackingDictionary.ContainsKey(key); + IEnumerator IEnumerable.GetEnumerator() => BackingDictionary.GetEnumerator(); - public bool TryGetValue(TKey key, out TValue value) => - this.BackingDictionary.TryGetValue(key, out value); + IEnumerator> IEnumerable>.GetEnumerator() => + BackingDictionary.GetEnumerator(); - public TValue this[TKey key] => this.BackingDictionary[key]; + public bool ContainsKey(TKey key) => BackingDictionary.ContainsKey(key); - public IEnumerable Keys => this.BackingDictionary.Keys; + public bool TryGetValue(TKey key, out TValue value) => + BackingDictionary.TryGetValue(key, out value); - public IEnumerable Values => this.BackingDictionary.Values; + protected virtual TKey Sanitize(TKey key) => key; } } diff --git a/src/Nest/CommonAbstractions/DictionaryLike/PerFieldAnalyzer/PerFieldAnalyzer.cs b/src/Nest/CommonAbstractions/DictionaryLike/PerFieldAnalyzer/PerFieldAnalyzer.cs index 197667e0425..c260f3e78d5 100644 --- a/src/Nest/CommonAbstractions/DictionaryLike/PerFieldAnalyzer/PerFieldAnalyzer.cs +++ b/src/Nest/CommonAbstractions/DictionaryLike/PerFieldAnalyzer/PerFieldAnalyzer.cs @@ -11,18 +11,19 @@ public interface IPerFieldAnalyzer : IIsADictionary { } public class PerFieldAnalyzer : IsADictionaryBase, IPerFieldAnalyzer { - public PerFieldAnalyzer() {} + public PerFieldAnalyzer() { } + public PerFieldAnalyzer(IDictionary container) : base(container) { } + public PerFieldAnalyzer(Dictionary container) - : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) - {} + : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) { } public void Add(Field field, string analyzer) => BackingDictionary.Add(field, analyzer); } public class PerFieldAnalyzer : PerFieldAnalyzer where T : class { - public void Add(Expression> field, string analyzer) => BackingDictionary.Add(field, analyzer); + public void Add(Expression> field, string analyzer) => BackingDictionary.Add(field, analyzer); } public class PerFieldAnalyzerDescriptor : IsADictionaryDescriptorBase, IPerFieldAnalyzer, Field, string> diff --git a/src/Nest/CommonAbstractions/Extensions/ExceptionExtensions.cs b/src/Nest/CommonAbstractions/Extensions/ExceptionExtensions.cs index 7dafef7de39..5e08562c9b2 100644 --- a/src/Nest/CommonAbstractions/Extensions/ExceptionExtensions.cs +++ b/src/Nest/CommonAbstractions/Extensions/ExceptionExtensions.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using System.Runtime.ExceptionServices; @@ -27,6 +25,5 @@ internal static T ThrowWhen(this T @object, Func predicate, string e return @object; } - } } diff --git a/src/Nest/CommonAbstractions/Extensions/ExpressionExtensions.cs b/src/Nest/CommonAbstractions/Extensions/ExpressionExtensions.cs index bead4b1151e..f1b3be2e511 100644 --- a/src/Nest/CommonAbstractions/Extensions/ExpressionExtensions.cs +++ b/src/Nest/CommonAbstractions/Extensions/ExpressionExtensions.cs @@ -7,8 +7,11 @@ namespace Nest { public static class ExpressionExtensions { + private static readonly Regex ExpressionRegex = new Regex(@"^\s*(.*)\s*\=\>\s*\1\."); + private static readonly Regex MemberExpressionRegex = new Regex(@"^[^\.]*\."); + /// - /// Appends to the path separating it with a dot. + /// Appends to the path separating it with a dot. /// This is especially useful with multi fields. /// /// the expression to which the suffix should be applied @@ -19,34 +22,6 @@ public static Expression> AppendSuffix(this Expression>(newBody, expression.Parameters[0]); } - /// - /// Calls on a member expression. - /// - private class SuffixExpressionVisitor : ExpressionVisitor - { - private readonly string _suffix; - - public SuffixExpressionVisitor(string suffix) - { - this._suffix = suffix; - } - - public override Expression Visit(Expression node) - { - return Expression.Call( - typeof(SuffixExtensions), - nameof(SuffixExtensions.Suffix), - null, - node, - Expression.Constant(_suffix)); - } - - protected override Expression VisitUnary(UnaryExpression node) => node; - } - - private static readonly Regex ExpressionRegex = new Regex(@"^\s*(.*)\s*\=\>\s*\1\."); - private static readonly Regex MemberExpressionRegex = new Regex(@"^[^\.]*\."); - internal static object ComparisonValueFromExpression(this Expression expression, out Type type) { type = null; @@ -62,5 +37,24 @@ internal static object ComparisonValueFromExpression(this Expression expression, ? MemberExpressionRegex.Replace(memberExpression.ToString(), string.Empty) : ExpressionRegex.Replace(expression.ToString(), string.Empty); } + + /// + /// Calls on a member expression. + /// + private class SuffixExpressionVisitor : ExpressionVisitor + { + private readonly string _suffix; + + public SuffixExpressionVisitor(string suffix) => _suffix = suffix; + + public override Expression Visit(Expression node) => Expression.Call( + typeof(SuffixExtensions), + nameof(SuffixExtensions.Suffix), + null, + node, + Expression.Constant(_suffix)); + + protected override Expression VisitUnary(UnaryExpression node) => node; + } } } diff --git a/src/Nest/CommonAbstractions/Extensions/Extensions.cs b/src/Nest/CommonAbstractions/Extensions/Extensions.cs index 7a71c60f316..2489f946771 100644 --- a/src/Nest/CommonAbstractions/Extensions/Extensions.cs +++ b/src/Nest/CommonAbstractions/Extensions/Extensions.cs @@ -7,12 +7,11 @@ using System.Reflection; using System.Runtime.Serialization; using System.Text; -using Elasticsearch.Net; +using System.Threading; +using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -using System.Threading.Tasks; -using System.Threading; namespace Nest { @@ -20,6 +19,7 @@ internal static class EmptyReadOnly { public static readonly IReadOnlyCollection Collection = new ReadOnlyCollection(new TElement[0]); } + internal static class EmptyReadOnly { public static readonly IReadOnlyDictionary Dictionary = new ReadOnlyDictionary(new Dictionary(0)); @@ -41,6 +41,7 @@ internal static TReturn InvokeOrDefault(this Func DistinctBy(this IEnumerable items, Func property) - { - return items.GroupBy(property).Select(x => x.First()); - } + internal static IEnumerable DistinctBy(this IEnumerable items, Func property) => + items.GroupBy(property).Select(x => x.First()); internal static ConcurrentDictionary _enumCache = new ConcurrentDictionary(); @@ -95,7 +94,7 @@ internal static string ToEnumValue(this T enumValue) where T : struct var enumMemberAttribute = enumFieldInfo.GetCustomAttribute(); if (enumMemberAttribute?.Value.Equals(str, comparison) ?? false) { - var v = (T) Enum.Parse(enumType, name); + var v = (T)Enum.Parse(enumType, name); _enumCache.TryAdd(key, v); return v; } @@ -103,7 +102,7 @@ internal static string ToEnumValue(this T enumValue) where T : struct var alternativeEnumMemberAttribute = enumFieldInfo.GetCustomAttribute(); if (alternativeEnumMemberAttribute?.Value.Equals(str, comparison) ?? false) { - var v = (T) Enum.Parse(enumType, name); + var v = (T)Enum.Parse(enumType, name); _enumCache.TryAdd(key, v); return v; } @@ -118,19 +117,12 @@ internal static string ToEnumValue(this T enumValue) where T : struct internal static string Utf8String(this byte[] bytes) => bytes == null ? null : Encoding.UTF8.GetString(bytes, 0, bytes.Length); #endif - internal static byte[] Utf8Bytes(this string s) - { - return s.IsNullOrEmpty() ? null : Encoding.UTF8.GetBytes(s); - } + internal static byte[] Utf8Bytes(this string s) => s.IsNullOrEmpty() ? null : Encoding.UTF8.GetBytes(s); + + internal static bool IsNullOrEmpty(this TypeName value) => value == null || value.GetHashCode() == 0; + + internal static bool IsNullOrEmpty(this IndexName value) => value == null || value.GetHashCode() == 0; - internal static bool IsNullOrEmpty(this TypeName value) - { - return value == null || value.GetHashCode() == 0; - } - internal static bool IsNullOrEmpty(this IndexName value) - { - return value == null || value.GetHashCode() == 0; - } internal static bool IsValueType(this Type type) { #if DOTNETCORE @@ -154,46 +146,39 @@ internal static void ThrowIfEmpty(this IEnumerable @object, string paramet throw new ArgumentException("Argument can not be an empty collection", parameterName); } - internal static List AsInstanceOrToListOrDefault(this IEnumerable list) - { - return list as List ?? list?.ToList() ?? new List(); - } - internal static List AsInstanceOrToListOrNull(this IEnumerable list) - { - return list as List ?? list?.ToList(); - } + internal static List AsInstanceOrToListOrDefault(this IEnumerable list) => list as List ?? list?.ToList() ?? new List(); + + internal static List AsInstanceOrToListOrNull(this IEnumerable list) => list as List ?? list?.ToList(); internal static List EagerConcat(this IEnumerable list, IEnumerable other) { var first = list.AsInstanceOrToListOrDefault(); if (other == null) return first; + var second = other.AsInstanceOrToListOrDefault(); var newList = new List(first.Count + second.Count); newList.AddRange(first); newList.AddRange(second); return newList; } + internal static IEnumerable AddIfNotNull(this IEnumerable list, T other) { if (other == null) return list; + var l = list.AsInstanceOrToListOrDefault(); l.Add(other); return l; } - internal static bool HasAny(this IEnumerable list, Func predicate) - { - return list != null && list.Any(predicate); - } + internal static bool HasAny(this IEnumerable list, Func predicate) => list != null && list.Any(predicate); - internal static bool HasAny(this IEnumerable list) - { - return list != null && list.Any(); - } + internal static bool HasAny(this IEnumerable list) => list != null && list.Any(); internal static bool IsEmpty(this IEnumerable list) { if (list == null) return true; + var enumerable = list as T[] ?? list.ToArray(); return !enumerable.Any() || enumerable.All(t => t == null); } @@ -204,24 +189,23 @@ internal static void ThrowIfNull(this T value, string name, string message = else if (value == null) throw new ArgumentNullException(name, "Argument can not be null when " + message); } - internal static bool IsNullOrEmpty(this string value) - { - return string.IsNullOrWhiteSpace(value); - } + internal static bool IsNullOrEmpty(this string value) => string.IsNullOrWhiteSpace(value); + internal static bool IsNullOrEmptyCommaSeparatedList(this string value, out string[] split) { split = null; if (string.IsNullOrWhiteSpace(value)) return true; - split = value.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries) - .Where(t=>!t.IsNullOrEmpty()) - .Select(t=>t.Trim()) + + split = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) + .Where(t => !t.IsNullOrEmpty()) + .Select(t => t.Trim()) .ToArray(); return split.Length == 0; } internal static void ForEach(this IEnumerable enumerable, Action handler) { - foreach (T item in enumerable) handler(item); + foreach (var item in enumerable) handler(item); } internal static List ToListOrNullIfEmpty(this IEnumerable enumerable) @@ -233,12 +217,15 @@ internal static List ToListOrNullIfEmpty(this IEnumerable enumerable) internal static void AddIfNotNull(this IList list, T item) where T : class { if (item == null) return; + list.Add(item); } + internal static void AddRangeIfNotNull(this List list, IEnumerable item) where T : class { if (item == null) return; - list.AddRange(item.Where(x=>x!=null)); + + list.AddRange(item.Where(x => x != null)); } internal static Dictionary NullIfNoKeys(this Dictionary dictionary) @@ -258,13 +245,13 @@ internal static async Task ForEachAsync( SemaphoreSlim additionalRateLimitter = null ) { - var semaphore = new SemaphoreSlim(initialCount: maxDegreeOfParallelism, maxCount: maxDegreeOfParallelism); + var semaphore = new SemaphoreSlim(maxDegreeOfParallelism, maxDegreeOfParallelism); long page = 0; try { var tasks = new List(maxDegreeOfParallelism); - int i = 0; + var i = 0; foreach (var item in lazyList) { tasks.Add(ProcessAsync(item, taskSelector, resultProcessor, semaphore, additionalRateLimitter, page++)); @@ -292,7 +279,8 @@ private static async Task ProcessAsync( Action resultProcessor, SemaphoreSlim localRateLimiter, SemaphoreSlim additionalRateLimiter, - long page) + long page + ) { if (localRateLimiter != null) await localRateLimiter.WaitAsync().ConfigureAwait(false); if (additionalRateLimiter != null) await additionalRateLimiter.WaitAsync().ConfigureAwait(false); @@ -312,8 +300,8 @@ internal static bool NullOrEquals(this T o, T other) { if (o == null && other == null) return true; if (o == null || other == null) return false; + return o.Equals(other); } - } } diff --git a/src/Nest/CommonAbstractions/Extensions/JsonExtensions.cs b/src/Nest/CommonAbstractions/Extensions/JsonExtensions.cs index e80e310f5e8..21a2801b2a9 100644 --- a/src/Nest/CommonAbstractions/Extensions/JsonExtensions.cs +++ b/src/Nest/CommonAbstractions/Extensions/JsonExtensions.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Elasticsearch.Net; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace Nest { @@ -15,6 +10,7 @@ public static IConnectionSettingsValues GetConnectionSettings(this JsonSerialize var contract = serializer.ContractResolver as ElasticContractResolver; if (contract?.ConnectionSettings == null) throw new Exception("If you use a custom contract resolver be sure to subclass from " + nameof(ElasticContractResolver)); + return contract.ConnectionSettings; } @@ -29,6 +25,7 @@ public static TConverter GetStatefulConverter(this JsonSerializer se public static void WriteProperty(this JsonWriter writer, JsonSerializer serializer, string propertyName, object value) { if (value == null) return; + writer.WritePropertyName(propertyName); serializer.Serialize(writer, value); } diff --git a/src/Nest/CommonAbstractions/Extensions/StringExtensions.cs b/src/Nest/CommonAbstractions/Extensions/StringExtensions.cs index 489c798ea98..9e7d749e159 100644 --- a/src/Nest/CommonAbstractions/Extensions/StringExtensions.cs +++ b/src/Nest/CommonAbstractions/Extensions/StringExtensions.cs @@ -1,5 +1,4 @@ using System.Collections.Specialized; -using System.Globalization; namespace Nest { @@ -26,6 +25,7 @@ internal static NameValueCollection ToNameValueCollection(this string queryStrin return queryParameters; } + internal static string ToCamelCase(this string s) { if (string.IsNullOrEmpty(s)) @@ -34,13 +34,11 @@ internal static string ToCamelCase(this string s) if (!char.IsUpper(s[0])) return s; - string camelCase = char.ToLowerInvariant(s[0]).ToString(); + var camelCase = char.ToLowerInvariant(s[0]).ToString(); if (s.Length > 1) camelCase += s.Substring(1); return camelCase; } - - } } diff --git a/src/Nest/CommonAbstractions/Extensions/SuffixExtensions.cs b/src/Nest/CommonAbstractions/Extensions/SuffixExtensions.cs index b39b95a2a18..cd34959b9d1 100644 --- a/src/Nest/CommonAbstractions/Extensions/SuffixExtensions.cs +++ b/src/Nest/CommonAbstractions/Extensions/SuffixExtensions.cs @@ -4,12 +4,9 @@ public static class SuffixExtensions { /// /// This extension method should only be used in expressions which are analysed by Nest. - /// When analysed it will append to the path separating it with a dot. + /// When analysed it will append to the path separating it with a dot. /// This is especially useful with multi fields. /// - public static object Suffix(this object @object, string suffix) - { - return @object; - } + public static object Suffix(this object @object, string suffix) => @object; } } diff --git a/src/Nest/CommonAbstractions/Extensions/TypeExtensions.cs b/src/Nest/CommonAbstractions/Extensions/TypeExtensions.cs index 1a96cb82f1f..23861f68120 100644 --- a/src/Nest/CommonAbstractions/Extensions/TypeExtensions.cs +++ b/src/Nest/CommonAbstractions/Extensions/TypeExtensions.cs @@ -15,12 +15,12 @@ internal static class TypeExtensions private static readonly MethodInfo GetActivatorMethodInfo = typeof(TypeExtensions).GetMethod(nameof(GetActivator), BindingFlags.Static | BindingFlags.NonPublic); - private static readonly ConcurrentDictionary> CachedDefaultValues = - new ConcurrentDictionary>(); - private static readonly ConcurrentDictionary> CachedActivators = new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> CachedDefaultValues = + new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary CachedGenericClosedTypes = new ConcurrentDictionary(); @@ -30,10 +30,13 @@ internal static class TypeExtensions private static readonly ConcurrentDictionary> CachedTypePropertyInfos = new ConcurrentDictionary>(); - private delegate T ObjectActivator(params object[] args); + + //this contract is only used to resolve properties in class WE OWN. + //these are not subject to change depending on what the user passes as connectionsettings + private static readonly ElasticContractResolver JsonContract = new ElasticContractResolver(new ConnectionSettings()); internal static object CreateGenericInstance(this Type t, Type closeOver, params object[] args) => - t.CreateGenericInstance(new[] {closeOver}, args); + t.CreateGenericInstance(new[] { closeOver }, args); internal static object CreateGenericInstance(this Type t, Type[] closeOver, params object[] args) { @@ -47,7 +50,7 @@ internal static object CreateGenericInstance(this Type t, Type[] closeOver, para return closedType.CreateInstance(args); } - internal static T CreateInstance(this Type t, params object[] args) => (T) t.CreateInstance(args); + internal static T CreateInstance(this Type t, params object[] args) => (T)t.CreateInstance(args); internal static object CreateInstance(this Type t, params object[] args) { @@ -58,15 +61,16 @@ internal static object CreateInstance(this Type t, params object[] args) var generic = GetActivatorMethodInfo.MakeGenericMethod(t); var constructors = from c in t.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) - let p = c.GetParameters() - let k = string.Join(",", p.Select(a => a.ParameterType.Name)) - where p.Length == args.Length - select c; + let p = c.GetParameters() + let k = string.Join(",", p.Select(a => a.ParameterType.Name)) + where p.Length == args.Length + select c; var ctor = constructors.FirstOrDefault(); if (ctor == null) throw new Exception($"Cannot create an instance of {t.FullName} because it has no constructor taking {args.Length} arguments"); - activator = (ObjectActivator) generic.Invoke(null, new object[] {ctor}); + + activator = (ObjectActivator)generic.Invoke(null, new object[] { ctor }); CachedActivators.TryAdd(key, activator); return activator(args); } @@ -74,10 +78,12 @@ internal static object CreateInstance(this Type t, params object[] args) internal static object DefaultValue(this Type type) => type.IsValueType() ? CachedDefaultValues.GetOrAdd(type, t => - Expression.Lambda>( - Expression.Convert(Expression.Default(type), typeof(object)) - ).Compile() - ).Invoke() + Expression.Lambda>( + Expression.Convert(Expression.Default(type), typeof(object)) + ) + .Compile() + ) + .Invoke() : null; //do not remove this is referenced through GetActivatorMethod @@ -111,19 +117,17 @@ private static ObjectActivator GetActivator(ConstructorInfo ctor) var lambda = Expression.Lambda(typeof(ObjectActivator), newExp, param); //compile it - var compiled = (ObjectActivator) lambda.Compile(); + var compiled = (ObjectActivator)lambda.Compile(); return compiled; } - //this contract is only used to resolve properties in class WE OWN. - //these are not subject to change depending on what the user passes as connectionsettings - private static readonly ElasticContractResolver JsonContract = new ElasticContractResolver(new ConnectionSettings()); - internal static IList GetCachedObjectProperties(this Type t, - MemberSerialization memberSerialization = MemberSerialization.OptIn) + MemberSerialization memberSerialization = MemberSerialization.OptIn + ) { if (CachedTypeProperties.TryGetValue(t, out var propertyDictionary)) return propertyDictionary; + propertyDictionary = JsonContract.PropertiesOfAll(t, memberSerialization); CachedTypeProperties.TryAdd(t, propertyDictionary); return propertyDictionary; @@ -133,6 +137,7 @@ internal static IList AllPropertiesCached(this Type t) { if (CachedTypePropertyInfos.TryGetValue(t, out var propertyInfos)) return propertyInfos; + propertyInfos = t.AllPropertiesNotCached().ToList(); CachedTypePropertyInfos.TryAdd(t, propertyInfos); return propertyInfos; @@ -150,15 +155,10 @@ private static IEnumerable AllPropertiesNotCached(this Type type) { if (propertiesByName.ContainsKey(propertyInfo.Name)) { - if (IsHidingMember(propertyInfo)) - { - propertiesByName[propertyInfo.Name] = propertyInfo; - } + if (IsHidingMember(propertyInfo)) propertiesByName[propertyInfo.Name] = propertyInfo; } else - { propertiesByName.Add(propertyInfo.Name, propertyInfo); - } } #if DOTNETCORE type = type.GetTypeInfo()?.BaseType; @@ -182,9 +182,11 @@ private static bool IsHidingMember(PropertyInfo propertyInfo) #endif var baseProperty = baseType?.GetProperty(propertyInfo.Name); if (baseProperty == null) return false; + var derivedGetMethod = propertyInfo.GetGetMethod().GetBaseDefinition(); return derivedGetMethod?.ReturnType != propertyInfo.PropertyType; } + + private delegate T ObjectActivator(params object[] args); } } - diff --git a/src/Nest/CommonAbstractions/Fields/FieldValues.cs b/src/Nest/CommonAbstractions/Fields/FieldValues.cs index c8de281d885..4f88f8a8554 100644 --- a/src/Nest/CommonAbstractions/Fields/FieldValues.cs +++ b/src/Nest/CommonAbstractions/Fields/FieldValues.cs @@ -1,11 +1,8 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Linq.Expressions; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace Nest { @@ -14,15 +11,20 @@ public class FieldValues : IsADictionaryBase { public static readonly FieldValues Empty = new FieldValues(); + private static readonly HashSet NumericTypes = new HashSet + { + typeof(int), typeof(double), typeof(decimal), + typeof(long), typeof(short), typeof(sbyte), + typeof(byte), typeof(ulong), typeof(ushort), + typeof(uint), typeof(float) + }; + private readonly Inferrer _inferrer; protected FieldValues() : base() { } internal FieldValues(Inferrer inferrer, IDictionary container) - : base(container) - { - _inferrer = inferrer; - } + : base(container) => _inferrer = inferrer; public TValue Value(Field field) { @@ -43,34 +45,29 @@ public TValue ValueOf(Expression> objectPath) public TValue[] ValuesOf(Field field) { - if (this._inferrer == null) return new TValue[0]; - var path = this._inferrer.Field(field); - return this.FieldArray(path); + if (_inferrer == null) return new TValue[0]; + + var path = _inferrer.Field(field); + return FieldArray(path); } public TValue[] Values(Expression> objectPath) where T : class { - if (this._inferrer == null) return new TValue[0]; - var field = this._inferrer.Field(objectPath); - return this.FieldArray(field); - } + if (_inferrer == null) return new TValue[0]; - private static readonly HashSet NumericTypes = new HashSet - { - typeof(int), typeof(double), typeof(decimal), - typeof(long), typeof(short), typeof(sbyte), - typeof(byte), typeof(ulong), typeof(ushort), - typeof(uint), typeof(float) - }; + var field = _inferrer.Field(objectPath); + return FieldArray(field); + } public static bool IsNumeric(Type myType) => NumericTypes.Contains(Nullable.GetUnderlyingType(myType) ?? myType); + public static bool IsNullable(Type type) => type.IsGeneric() && type.GetGenericTypeDefinition() == typeof(Nullable<>); private TValue[] FieldArray(string field) { //unknown field - if (this.BackingDictionary == null || !this.BackingDictionary.TryGetValue(field, out var o)) + if (BackingDictionary == null || !BackingDictionary.TryGetValue(field, out var o)) return null; //numerics are always returned as doubles by elasticsearch. @@ -79,15 +76,17 @@ private TValue[] FieldArray(string field) //here we support casting to the desired numeric type whether its nullable or not. if (!IsNullable(typeof(TValue))) - return o.As().Select(d => (TValue) Convert.ChangeType(d, typeof(TValue))).ToArray(); + return o.As().Select(d => (TValue)Convert.ChangeType(d, typeof(TValue))).ToArray(); var underlyingType = Nullable.GetUnderlyingType(typeof(TValue)); - return o.As().Select(d=> - { - if (d == null) return default(TValue); - return (TValue) Convert.ChangeType(d, underlyingType); - }).ToArray(); + return o.As() + .Select(d => + { + if (d == null) return default(TValue); + return (TValue)Convert.ChangeType(d, underlyingType); + }) + .ToArray(); } } } diff --git a/src/Nest/CommonAbstractions/Fields/FieldValuesJsonConverter.cs b/src/Nest/CommonAbstractions/Fields/FieldValuesJsonConverter.cs index 262b5ec8e6c..faf28b96d06 100644 --- a/src/Nest/CommonAbstractions/Fields/FieldValuesJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Fields/FieldValuesJsonConverter.cs @@ -1,10 +1,7 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; +using System; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Nest { @@ -12,10 +9,7 @@ internal class FieldValuesJsonConverter : JsonConverter { public override bool CanWrite => false; - public override bool CanConvert(Type objectType) - { - throw new NotSupportedException(); - } + public override bool CanConvert(Type objectType) => throw new NotSupportedException(); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { @@ -27,9 +21,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return fieldValues; } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); } } diff --git a/src/Nest/CommonAbstractions/Fluent/DescriptorBase.cs b/src/Nest/CommonAbstractions/Fluent/DescriptorBase.cs index 86b717f5dae..d55a0646182 100644 --- a/src/Nest/CommonAbstractions/Fluent/DescriptorBase.cs +++ b/src/Nest/CommonAbstractions/Fluent/DescriptorBase.cs @@ -11,17 +11,14 @@ public abstract class DescriptorBase : IDescriptor { private readonly TDescriptor _self; - protected DescriptorBase() - { - _self = (TDescriptor)this; - } + protected DescriptorBase() => _self = (TDescriptor)this; protected TInterface Self => _self; protected TDescriptor Assign(Action assigner) => Fluent.Assign(_self, assigner); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -30,7 +27,7 @@ protected DescriptorBase() public override bool Equals(object obj) => base.Equals(obj); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -39,7 +36,7 @@ protected DescriptorBase() public override int GetHashCode() => base.GetHashCode(); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Nest/CommonAbstractions/Fluent/Fluent.cs b/src/Nest/CommonAbstractions/Fluent/Fluent.cs index 77006c555a5..2b58e0783b2 100644 --- a/src/Nest/CommonAbstractions/Fluent/Fluent.cs +++ b/src/Nest/CommonAbstractions/Fluent/Fluent.cs @@ -11,5 +11,4 @@ internal static TDescriptor Assign(TDescriptor self, Ac return self; } } - -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Fluent/FluentDictionary.cs b/src/Nest/CommonAbstractions/Fluent/FluentDictionary.cs index 01a52b6dbf1..fe6ec9099ab 100644 --- a/src/Nest/CommonAbstractions/Fluent/FluentDictionary.cs +++ b/src/Nest/CommonAbstractions/Fluent/FluentDictionary.cs @@ -4,9 +4,7 @@ namespace Nest { public class FluentDictionary : Dictionary { - public FluentDictionary() - { - } + public FluentDictionary() { } public FluentDictionary(IDictionary copy) { @@ -29,4 +27,4 @@ public FluentDictionary(IDictionary copy) return this; } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Fluent/Promise/DescriptorPromiseBase.cs b/src/Nest/CommonAbstractions/Fluent/Promise/DescriptorPromiseBase.cs index f8364d1c024..276bf801d77 100644 --- a/src/Nest/CommonAbstractions/Fluent/Promise/DescriptorPromiseBase.cs +++ b/src/Nest/CommonAbstractions/Fluent/Promise/DescriptorPromiseBase.cs @@ -8,40 +8,41 @@ public interface IPromise where TValue : class TValue Value { get; } } - public abstract class DescriptorPromiseBase : IDescriptor, IPromise + public abstract class DescriptorPromiseBase : IDescriptor, IPromise where TDescriptor : DescriptorPromiseBase where TValue : class { internal readonly TValue PromisedValue; - TValue IPromise.Value => PromisedValue; - protected DescriptorPromiseBase(TValue instance) { this.PromisedValue = instance; } + protected DescriptorPromiseBase(TValue instance) => PromisedValue = instance; + + TValue IPromise.Value => PromisedValue; protected TDescriptor Assign(Action assigner) { - assigner(this.PromisedValue); - return (TDescriptor) this; + assigner(PromisedValue); + return (TDescriptor)this; } /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => base.Equals(obj); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => base.GetHashCode(); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public override string ToString() => base.ToString(); } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Fluent/SelectorBase.cs b/src/Nest/CommonAbstractions/Fluent/SelectorBase.cs index f3357b270f7..f645e920f96 100644 --- a/src/Nest/CommonAbstractions/Fluent/SelectorBase.cs +++ b/src/Nest/CommonAbstractions/Fluent/SelectorBase.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; namespace Nest { @@ -8,7 +7,7 @@ public interface ISelector { } public abstract class SelectorBase : ISelector where TInterface : class { /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -17,7 +16,7 @@ public abstract class SelectorBase : ISelector where TInterface : cl public override bool Equals(object obj) => base.Equals(obj); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -26,7 +25,7 @@ public abstract class SelectorBase : ISelector where TInterface : cl public override int GetHashCode() => base.GetHashCode(); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Nest/CommonAbstractions/ForAttribute.cs b/src/Nest/CommonAbstractions/ForAttribute.cs index eca5770260b..184f81876b0 100644 --- a/src/Nest/CommonAbstractions/ForAttribute.cs +++ b/src/Nest/CommonAbstractions/ForAttribute.cs @@ -7,25 +7,22 @@ namespace Nest /// This is used by the code generator and is only meant for internal use to map our more aptly named requests to /// the original elasticsearch rest spec /// - [AttributeUsage(System.AttributeTargets.Class, AllowMultiple = false)] + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] internal class DescriptorForAttribute : Attribute { - // ReSharper disable once UnusedParameter.Local - public DescriptorForAttribute (string operation) { } - + public DescriptorForAttribute(string operation) { } } + /// /// DescriptorFor is a marker to rename unintuitive generated elasticsearch operation names /// This is used by the code generator and is only meant for internal use to map our more aptly named requests to /// the original elasticsearch rest spec /// - [AttributeUsage(System.AttributeTargets.Interface, AllowMultiple = false)] + [AttributeUsage(AttributeTargets.Interface, AllowMultiple = false)] internal class MapsApiAttribute : Attribute { - // ReSharper disable once UnusedParameter.Local - public MapsApiAttribute (string restSpecName) { } - + public MapsApiAttribute(string restSpecName) { } } } diff --git a/src/Nest/CommonAbstractions/Infer/ActionIds/ActionIds.cs b/src/Nest/CommonAbstractions/Infer/ActionIds/ActionIds.cs index 72a8489068a..478ad5a865e 100644 --- a/src/Nest/CommonAbstractions/Infer/ActionIds/ActionIds.cs +++ b/src/Nest/CommonAbstractions/Infer/ActionIds/ActionIds.cs @@ -10,40 +10,37 @@ namespace Nest public class ActionIds : IUrlParameter, IEquatable { private readonly List _actionIds; - internal IReadOnlyList Ids => _actionIds; - - public ActionIds(IEnumerable actionIds) - { - this._actionIds = actionIds?.ToList() ?? new List(); - } - - public ActionIds(string actionIds) - { - this._actionIds = actionIds.IsNullOrEmpty() - ? new List() - : actionIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) - .Select(s => s.Trim()) - .ToList(); - } - private string DebugDisplay => ((IUrlParameter)this).GetString(null); + public ActionIds(IEnumerable actionIds) => _actionIds = actionIds?.ToList() ?? new List(); - string IUrlParameter.GetString(IConnectionConfigurationValues settings) => string.Join(",", this._actionIds); + public ActionIds(string actionIds) => _actionIds = actionIds.IsNullOrEmpty() + ? new List() + : actionIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) + .Select(s => s.Trim()) + .ToList(); - public static implicit operator ActionIds(string actionIds) => actionIds.IsNullOrEmptyCommaSeparatedList(out var list) ? null : new ActionIds(list); + internal IReadOnlyList Ids => _actionIds; - public static implicit operator ActionIds(string[] actionIds) => actionIds.IsEmpty() ? null : new ActionIds(actionIds); + private string DebugDisplay => ((IUrlParameter)this).GetString(null); public bool Equals(ActionIds other) { - if (this.Ids == null && other.Ids == null) return true; - if (this.Ids == null || other.Ids == null) return false; - return this.Ids.Count == other.Ids.Count && !this.Ids.Except(other.Ids).Any(); + if (Ids == null && other.Ids == null) return true; + if (Ids == null || other.Ids == null) return false; + + return Ids.Count == other.Ids.Count && !Ids.Except(other.Ids).Any(); } + string IUrlParameter.GetString(IConnectionConfigurationValues settings) => string.Join(",", _actionIds); + + public static implicit operator ActionIds(string actionIds) => + actionIds.IsNullOrEmptyCommaSeparatedList(out var list) ? null : new ActionIds(list); + + public static implicit operator ActionIds(string[] actionIds) => actionIds.IsEmpty() ? null : new ActionIds(actionIds); + public override bool Equals(object obj) => obj is ActionIds other && Equals(other); - public override int GetHashCode() => this._actionIds.GetHashCode(); + public override int GetHashCode() => _actionIds.GetHashCode(); public static bool operator ==(ActionIds left, ActionIds right) => Equals(left, right); diff --git a/src/Nest/CommonAbstractions/Infer/CategoryId/CategoryId.cs b/src/Nest/CommonAbstractions/Infer/CategoryId/CategoryId.cs index df4e1801e22..f00a8437140 100644 --- a/src/Nest/CommonAbstractions/Infer/CategoryId/CategoryId.cs +++ b/src/Nest/CommonAbstractions/Infer/CategoryId/CategoryId.cs @@ -10,26 +10,27 @@ public class CategoryId : IUrlParameter, IEquatable public CategoryId(long value) => Value = value; - public static implicit operator CategoryId(long categoryId) => new CategoryId(categoryId); - public static implicit operator long(CategoryId categoryId) => categoryId.Value; + public bool Equals(CategoryId other) => Value == other.Value; // ReSharper disable once ImpureMethodCallOnReadonlyValueField public string GetString(IConnectionConfigurationValues settings) => Value.ToString(CultureInfo.InvariantCulture); - public bool Equals(CategoryId other) => this.Value == other.Value; + public static implicit operator CategoryId(long categoryId) => new CategoryId(categoryId); + + public static implicit operator long(CategoryId categoryId) => categoryId.Value; public override bool Equals(object obj) { switch (obj) { - case int l: return this.Value == l; - case long l: return this.Value == l; - case CategoryId i: return this.Value == i.Value; + case int l: return Value == l; + case long l: return Value == l; + case CategoryId i: return Value == i.Value; default: return false; } } - public override int GetHashCode() => this.Value.GetHashCode(); + public override int GetHashCode() => Value.GetHashCode(); public static bool operator ==(CategoryId left, CategoryId right) => Equals(left, right); diff --git a/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs b/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs index cf49fdb5c86..5297dda181b 100644 --- a/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs +++ b/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs @@ -11,13 +11,8 @@ public interface IDocumentPath public class DocumentPath : IEquatable>, IDocumentPath where T : class { - internal IDocumentPath Self => this; - internal T Document { get; set; } - Id IDocumentPath.Id { get; set; } - IndexName IDocumentPath.Index { get; set; } - TypeName IDocumentPath.Type { get; set; } + public DocumentPath(T document) : this(Nest.Id.From(document)) => Document = document; - public DocumentPath(T document) : this(Nest.Id.From(document)) { this.Document = document; } public DocumentPath(Id id) { Self.Id = id; @@ -25,24 +20,45 @@ public DocumentPath(Id id) Self.Type = typeof(T); } + internal T Document { get; set; } + internal IDocumentPath Self => this; + Id IDocumentPath.Id { get; set; } + IndexName IDocumentPath.Index { get; set; } + TypeName IDocumentPath.Type { get; set; } + + public bool Equals(DocumentPath other) + { + IDocumentPath o = other, s = Self; + return s.Index.NullOrEquals(o.Index) && s.Type.NullOrEquals(o.Type) && s.Id.NullOrEquals(o.Id) + && (Document?.Equals(other.Document) ?? true); + } + public static DocumentPath Id(Id id) => new DocumentPath(id); + public static DocumentPath Id(T @object) => new DocumentPath(@object); public static implicit operator DocumentPath(T @object) => @object == null ? null : new DocumentPath(@object); + public static implicit operator DocumentPath(Id id) => id == null ? null : new DocumentPath(id); + public static implicit operator DocumentPath(long id) => new DocumentPath(id); + public static implicit operator DocumentPath(string id) => id.IsNullOrEmpty() ? null : new DocumentPath(id); + public static implicit operator DocumentPath(Guid id) => new DocumentPath(id); public DocumentPath Index(IndexName index) { if (index == null) return this; + Self.Index = index; return this; } + public DocumentPath Type(TypeName type) { if (type == null) return this; + Self.Type = type; return this; } @@ -58,24 +74,17 @@ public override int GetHashCode() } } - public bool Equals(DocumentPath other) - { - IDocumentPath o = other, s = Self; - return s.Index.NullOrEquals(o.Index) && s.Type.NullOrEquals(o.Type) && s.Id.NullOrEquals(o.Id) - && (this.Document?.Equals(other.Document) ?? true); - } - public override bool Equals(object obj) { switch (obj) { - case DocumentPath d: return this.Equals(d); + case DocumentPath d: return Equals(d); default: return false; } } public static bool operator ==(DocumentPath x, DocumentPath y) => Equals(x, y); - public static bool operator !=(DocumentPath x, DocumentPath y)=> !Equals(x, y); + public static bool operator !=(DocumentPath x, DocumentPath y) => !Equals(x, y); } } diff --git a/src/Nest/CommonAbstractions/Infer/Field/Field.cs b/src/Nest/CommonAbstractions/Infer/Field/Field.cs index a2e1715dc8c..5018be3bb51 100644 --- a/src/Nest/CommonAbstractions/Infer/Field/Field.cs +++ b/src/Nest/CommonAbstractions/Infer/Field/Field.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics; using System.Globalization; -using System.Linq; using System.Linq.Expressions; using System.Reflection; using Elasticsearch.Net; @@ -15,30 +14,6 @@ public class Field : IEquatable, IUrlParameter private readonly object _comparisonValue; private readonly Type _type; - public string Name { get; } - - public Expression Expression { get; } - - public PropertyInfo Property { get; } - - public double? Boost { get; set; } - - public bool CachableExpression { get; } - - internal string DebugDisplay => - $"{Expression?.ToString() ?? PropertyDebug ?? Name}{(Boost.HasValue ? "^" + Boost.Value: "")}{(_type == null ? "" : " typeof: " + _type.Name)}"; - - private string PropertyDebug => Property == null ? null : $"PropertyInfo: {Property.Name}"; - - public Fields And(Field field) => new Fields(new [] { this, field }); - - public Fields And(Expression> field, double? boost = null) where T : class => - new Fields(new [] { this, new Field(field, boost) }); - - public Fields And(string field, double? boost = null) => new Fields(new [] { this, new Field(field, boost) }); - - public Fields And(PropertyInfo property, double? boost = null) => new Fields(new [] { this, new Field(property, boost) }); - public Field(string name, double? boost = null) { name.ThrowIfNullOrEmpty(nameof(name)); @@ -65,13 +40,51 @@ public Field(PropertyInfo property, double? boost = null) _type = property.DeclaringType; } + public double? Boost { get; set; } + + public bool CachableExpression { get; } + + public Expression Expression { get; } + + public string Name { get; } + + public PropertyInfo Property { get; } + + internal string DebugDisplay => + $"{Expression?.ToString() ?? PropertyDebug ?? Name}{(Boost.HasValue ? "^" + Boost.Value : "")}{(_type == null ? "" : " typeof: " + _type.Name)}"; + + private string PropertyDebug => Property == null ? null : $"PropertyInfo: {Property.Name}"; + + public bool Equals(Field other) => _type != null + ? other != null && _type == other._type && _comparisonValue.Equals(other._comparisonValue) + : other != null && _comparisonValue.Equals(other._comparisonValue); + + string IUrlParameter.GetString(IConnectionConfigurationValues settings) + { + if (!(settings is IConnectionSettingsValues nestSettings)) + throw new ArgumentNullException(nameof(settings), + $"Can not resolve {nameof(Field)} if no {nameof(IConnectionSettingsValues)} is provided"); + + return nestSettings.Inferrer.Field(this); + } + + public Fields And(Field field) => new Fields(new[] { this, field }); + + public Fields And(Expression> field, double? boost = null) where T : class => + new Fields(new[] { this, new Field(field, boost) }); + + public Fields And(string field, double? boost = null) => new Fields(new[] { this, new Field(field, boost) }); + + public Fields And(PropertyInfo property, double? boost = null) => new Fields(new[] { this, new Field(property, boost) }); + private static string ParseFieldName(string name, out double? boost) { boost = null; if (name == null) return null; - var parts = name.Split(new [] { '^' }, StringSplitOptions.RemoveEmptyEntries); + var parts = name.Split(new[] { '^' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length <= 1) return name; + name = parts[0]; boost = double.Parse(parts[1], CultureInfo.InvariantCulture); return name; @@ -93,35 +106,19 @@ public override int GetHashCode() } } - public bool Equals(Field other) - { - return _type != null - ? other != null && _type == other._type && _comparisonValue.Equals(other._comparisonValue) - : other != null && _comparisonValue.Equals(other._comparisonValue); - } - public override bool Equals(object obj) { switch (obj) { - case string s: return this.Equals(s); - case PropertyInfo p: return this.Equals(p); - case Field f: return this.Equals(f); + case string s: return Equals(s); + case PropertyInfo p: return Equals(p); + case Field f: return Equals(f); default: return false; } } public static bool operator ==(Field x, Field y) => Equals(x, y); - public static bool operator !=(Field x, Field y)=> !Equals(x, y); - - string IUrlParameter.GetString(IConnectionConfigurationValues settings) - { - if (!(settings is IConnectionSettingsValues nestSettings)) - throw new ArgumentNullException(nameof(settings), $"Can not resolve {nameof(Field)} if no {nameof(IConnectionSettingsValues)} is provided"); - - return nestSettings.Inferrer.Field(this); - } - + public static bool operator !=(Field x, Field y) => !Equals(x, y); } } diff --git a/src/Nest/CommonAbstractions/Infer/Field/FieldExpressionVisitor.cs b/src/Nest/CommonAbstractions/Infer/Field/FieldExpressionVisitor.cs index e937d5115ba..72c0e241367 100644 --- a/src/Nest/CommonAbstractions/Infer/Field/FieldExpressionVisitor.cs +++ b/src/Nest/CommonAbstractions/Infer/Field/FieldExpressionVisitor.cs @@ -1,6 +1,4 @@ -using Elasticsearch.Net; -using System; -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -8,29 +6,30 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Text; -using System.Threading.Tasks; namespace Nest { internal class HasVariableExpressionVisitor : ExpressionVisitor { private bool _found; + + public HasVariableExpressionVisitor(Expression e) => Visit(e); + public bool Found { get => _found; // This is only set to true once to prevent clobbering from subsequent node visits - private set { if (!_found) _found = value; } - } - - public HasVariableExpressionVisitor(Expression e) - { - this.Visit(e); + private set + { + if (!_found) _found = value; + } } public override Expression Visit(Expression node) { - if (!this.Found) + if (!Found) return base.Visit(node); + return node; } @@ -39,7 +38,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node) if (node.Method.Name == nameof(SuffixExtensions.Suffix) && node.Arguments.Any()) { var lastArg = node.Arguments.Last(); - this.Found = !(lastArg is ConstantExpression); + Found = !(lastArg is ConstantExpression); } else if (node.Method.Name == "get_Item" && node.Arguments.Any()) { @@ -47,12 +46,13 @@ protected override Expression VisitMethodCall(MethodCallExpression node) var isDict = typeof(IDictionary).IsAssignableFrom(t) || typeof(IDictionary<,>).IsAssignableFrom(t) - || (t.IsGeneric() && t.GetGenericTypeDefinition() == typeof(IDictionary<,>)); + || t.IsGeneric() && t.GetGenericTypeDefinition() == typeof(IDictionary<,>); if (!isDict) return base.VisitMethodCall(node); + var lastArg = node.Arguments.Last(); - this.Found = !(lastArg is ConstantExpression); + Found = !(lastArg is ConstantExpression); } return base.VisitMethodCall(node); } @@ -60,24 +60,21 @@ protected override Expression VisitMethodCall(MethodCallExpression node) internal class FieldExpressionVisitor : ExpressionVisitor { - private readonly Stack _stack = new Stack(); - private readonly IConnectionSettingsValues _settings; + private readonly Stack _stack = new Stack(); - public FieldExpressionVisitor(IConnectionSettingsValues settings) - { - _settings = settings; - } + public FieldExpressionVisitor(IConnectionSettingsValues settings) => _settings = settings; public string Resolve(Expression expression, bool toLastToken = false) { Visit(expression); if (toLastToken) return _stack.Last(); + return _stack .Aggregate( new StringBuilder(), (sb, name) => - (sb.Length > 0 ? sb.Append(".") : sb).Append(name)) + (sb.Length > 0 ? sb.Append(".") : sb).Append(name)) .ToString(); } @@ -88,7 +85,7 @@ public string Resolve(MemberInfo info) var name = info.Name; - if (this._settings.PropertyMappings.TryGetValue(info, out var propertyMapping)) + if (_settings.PropertyMappings.TryGetValue(info, out var propertyMapping)) return propertyMapping.Name; var att = ElasticsearchPropertyAttributeBase.From(info); @@ -101,7 +98,8 @@ public string Resolve(MemberInfo info) protected override Expression VisitMember(MemberExpression expression) { if (_stack == null) return base.VisitMember(expression); - var name = this.Resolve(expression.Member); + + var name = Resolve(expression.Member); _stack.Push(name); return base.VisitMember(expression); } @@ -114,7 +112,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCall) var callingMember = new ReadOnlyCollection( new List { { methodCall.Arguments.First() } } ); - base.Visit(callingMember); + Visit(callingMember); return methodCall; } else if (methodCall.Method.Name == "get_Item" && methodCall.Arguments.Any()) @@ -123,22 +121,17 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCall) var isDict = typeof(IDictionary).IsAssignableFrom(t) || typeof(IDictionary<,>).IsAssignableFrom(t) - || (t.IsGeneric() && t.GetGenericTypeDefinition() == typeof(IDictionary<,>)); + || t.IsGeneric() && t.GetGenericTypeDefinition() == typeof(IDictionary<,>); + + if (!isDict) return base.VisitMethodCall(methodCall); - if (!isDict) - { - return base.VisitMethodCall(methodCall); - } VisitConstantOrVariable(methodCall, _stack); Visit(methodCall.Object); return methodCall; } else if (IsLinqOperator(methodCall.Method)) { - for (int i = 1; i < methodCall.Arguments.Count; i++) - { - Visit(methodCall.Arguments[i]); - } + for (var i = 1; i < methodCall.Arguments.Count; i++) Visit(methodCall.Arguments[i]); Visit(methodCall.Arguments[0]); return methodCall; } diff --git a/src/Nest/CommonAbstractions/Infer/Field/FieldExtensions.cs b/src/Nest/CommonAbstractions/Infer/Field/FieldExtensions.cs index ae58e6e36cd..cec777345fb 100644 --- a/src/Nest/CommonAbstractions/Infer/Field/FieldExtensions.cs +++ b/src/Nest/CommonAbstractions/Infer/Field/FieldExtensions.cs @@ -4,10 +4,9 @@ namespace Nest { internal static class FieldExtensions { - internal static bool IsConditionless(this Field field) - { - return field == null || (field.Name.IsNullOrEmpty() && field.Expression == null && field.Property == null); - } + internal static bool IsConditionless(this Field field) => + field == null || field.Name.IsNullOrEmpty() && field.Expression == null && field.Property == null; + internal static bool IsConditionless(this Fields field) => field?.ListOfFields == null || field.ListOfFields.All(l => l.IsConditionless()); } } diff --git a/src/Nest/CommonAbstractions/Infer/Field/FieldJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/Field/FieldJsonConverter.cs index dee9b6291c1..1cdfdc8da47 100644 --- a/src/Nest/CommonAbstractions/Infer/Field/FieldJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/Field/FieldJsonConverter.cs @@ -22,12 +22,13 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s var settings = serializer.GetConnectionSettings(); writer.WriteValue(settings.Inferrer.Field(field)); } + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.String) return null; + var field = reader.Value.ToString(); return (Field)field; } } } - diff --git a/src/Nest/CommonAbstractions/Infer/Field/FieldResolver.cs b/src/Nest/CommonAbstractions/Infer/Field/FieldResolver.cs index b258d5fb31c..3e70e01dc83 100644 --- a/src/Nest/CommonAbstractions/Infer/Field/FieldResolver.cs +++ b/src/Nest/CommonAbstractions/Infer/Field/FieldResolver.cs @@ -1,29 +1,21 @@ using System; -using System.Collections; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Globalization; -using System.Linq; using System.Linq.Expressions; using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text; -using Elasticsearch.Net; namespace Nest { public class FieldResolver { - private readonly IConnectionSettingsValues _settings; - protected readonly ConcurrentDictionary Fields = new ConcurrentDictionary(); protected readonly ConcurrentDictionary Properties = new ConcurrentDictionary(); + private readonly IConnectionSettingsValues _settings; public FieldResolver(IConnectionSettingsValues settings) { settings.ThrowIfNull(nameof(settings)); - this._settings = settings; + _settings = settings; } public string Resolve(Field field) @@ -37,16 +29,13 @@ private string ResolveFieldName(Field field) { if (field.IsConditionless()) return null; if (!field.Name.IsNullOrEmpty()) return field.Name; - if (field.Expression != null && !field.CachableExpression) - { - return this.Resolve(field.Expression, field.Property); - } + if (field.Expression != null && !field.CachableExpression) return Resolve(field.Expression, field.Property); - if (this.Fields.TryGetValue(field, out var fieldName)) + if (Fields.TryGetValue(field, out var fieldName)) return fieldName; - fieldName = this.Resolve(field.Expression, field.Property); - this.Fields.TryAdd(field, fieldName); + fieldName = Resolve(field.Expression, field.Property); + Fields.TryAdd(field, fieldName); return fieldName; } @@ -55,16 +44,13 @@ public string Resolve(PropertyName property) if (property.IsConditionless()) return null; if (!property.Name.IsNullOrEmpty()) return property.Name; - if (property.Expression != null && !property.CacheableExpression) - { - return this.Resolve(property.Expression, property.Property); - } + if (property.Expression != null && !property.CacheableExpression) return Resolve(property.Expression, property.Property); - if (this.Properties.TryGetValue(property, out var propertyName)) + if (Properties.TryGetValue(property, out var propertyName)) return propertyName; - propertyName = this.Resolve(property.Expression, property.Property, true); - this.Properties.TryAdd(property, propertyName); + propertyName = Resolve(property.Expression, property.Property, true); + Properties.TryAdd(property, propertyName); return propertyName; } diff --git a/src/Nest/CommonAbstractions/Infer/Fields/Fields.cs b/src/Nest/CommonAbstractions/Infer/Fields/Fields.cs index e25d80bdccd..357a819e756 100644 --- a/src/Nest/CommonAbstractions/Infer/Fields/Fields.cs +++ b/src/Nest/CommonAbstractions/Infer/Fields/Fields.cs @@ -15,89 +15,92 @@ public class Fields : IUrlParameter, IEnumerable, IEquatable { internal readonly List ListOfFields; + internal Fields() => ListOfFields = new List(); + + internal Fields(IEnumerable fieldNames) => ListOfFields = fieldNames.ToList(); + + private string DebugDisplay => + $"Count: {ListOfFields.Count} [" + string.Join(",", ListOfFields.Select((t, i) => $"({i + 1}: {t?.DebugDisplay ?? "NULL"})")) + "]"; + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + public IEnumerator GetEnumerator() => ListOfFields.GetEnumerator(); + + public bool Equals(Fields other) => EqualsAllFields(ListOfFields, other.ListOfFields); + string IUrlParameter.GetString(IConnectionConfigurationValues settings) { if (!(settings is IConnectionSettingsValues nestSettings)) - throw new ArgumentNullException(nameof(settings), $"Can not resolve {nameof(Fields)} if no {nameof(IConnectionSettingsValues)} is provided"); + throw new ArgumentNullException(nameof(settings), + $"Can not resolve {nameof(Fields)} if no {nameof(IConnectionSettingsValues)} is provided"); return string.Join(",", ListOfFields.Where(f => f != null).Select(f => ((IUrlParameter)f).GetString(nestSettings))); } - private string DebugDisplay => - $"Count: {ListOfFields.Count} [" + string.Join(",", ListOfFields.Select((t, i) => $"({i + 1}: {t?.DebugDisplay ?? "NULL"})")) + "]"; - - internal Fields() { this.ListOfFields = new List(); } - internal Fields(IEnumerable fieldNames) { this.ListOfFields = fieldNames.ToList(); } - public static implicit operator Fields(string[] fields) => fields.IsEmpty() ? null : new Fields(fields.Select(f => (Field)f)); public static implicit operator Fields(string field) => field.IsNullOrEmptyCommaSeparatedList(out var split) - ? null : new Fields(split.Select(f=>(Field)f)); + ? null + : new Fields(split.Select(f => (Field)f)); public static implicit operator Fields(Expression[] fields) => fields.IsEmpty() ? null : new Fields(fields.Select(f => (Field)f)); - public static implicit operator Fields(Expression field) => field == null ? null : new Fields(new [] { (Field)field }); + public static implicit operator Fields(Expression field) => field == null ? null : new Fields(new[] { (Field)field }); public static implicit operator Fields(Field field) => field == null ? null : new Fields(new[] { field }); public static implicit operator Fields(PropertyInfo field) => field == null ? null : new Fields(new Field[] { field }); - public static implicit operator Fields(PropertyInfo[] fields) => fields.IsEmpty() ? null : new Fields(fields.Select(f=>(Field)f)); + public static implicit operator Fields(PropertyInfo[] fields) => fields.IsEmpty() ? null : new Fields(fields.Select(f => (Field)f)); public static implicit operator Fields(Field[] fields) => fields.IsEmpty() ? null : new Fields(fields); public Fields And(Expression> field, double? boost = null) where T : class { - this.ListOfFields.Add(new Field(field, boost)); + ListOfFields.Add(new Field(field, boost)); return this; } public Fields And(string field, double? boost = null) { - this.ListOfFields.Add(new Field(field, boost)); + ListOfFields.Add(new Field(field, boost)); return this; } public Fields And(PropertyInfo property, double? boost = null) { - this.ListOfFields.Add(new Field(property, boost)); + ListOfFields.Add(new Field(property, boost)); return this; } public Fields And(params Expression>[] fields) where T : class { - this.ListOfFields.AddRange(fields.Select(f => (Field)f)); + ListOfFields.AddRange(fields.Select(f => (Field)f)); return this; } public Fields And(params string[] fields) { - this.ListOfFields.AddRange(fields.Select(f => (Field)f)); + ListOfFields.AddRange(fields.Select(f => (Field)f)); return this; } public Fields And(params PropertyInfo[] properties) { - this.ListOfFields.AddRange(properties.Select(f => (Field)f)); + ListOfFields.AddRange(properties.Select(f => (Field)f)); return this; } public Fields And(params Field[] fields) { - this.ListOfFields.AddRange(fields); + ListOfFields.AddRange(fields); return this; } - public IEnumerator GetEnumerator() => this.ListOfFields.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); - public static bool operator ==(Fields left, Fields right) => Equals(left, right); public static bool operator !=(Fields left, Fields right) => !Equals(left, right); - public bool Equals(Fields other) => EqualsAllFields(this.ListOfFields, other.ListOfFields); - public override bool Equals(object obj) { switch (obj) @@ -117,9 +120,10 @@ private static bool EqualsAllFields(IReadOnlyList thisTypes, IReadOnlyLis if (thisTypes == null && otherTypes == null) return true; if (thisTypes == null || otherTypes == null) return false; if (thisTypes.Count != otherTypes.Count) return false; + return thisTypes.Count == otherTypes.Count && !thisTypes.Except(otherTypes).Any(); } - public override int GetHashCode() => this.ListOfFields.GetHashCode(); + public override int GetHashCode() => ListOfFields.GetHashCode(); } } diff --git a/src/Nest/CommonAbstractions/Infer/Fields/FieldsDescriptor.cs b/src/Nest/CommonAbstractions/Infer/Fields/FieldsDescriptor.cs index 73c7391b38e..64723a8caec 100644 --- a/src/Nest/CommonAbstractions/Infer/Fields/FieldsDescriptor.cs +++ b/src/Nest/CommonAbstractions/Infer/Fields/FieldsDescriptor.cs @@ -10,11 +10,15 @@ public class FieldsDescriptor : DescriptorPromiseBase, Fi public FieldsDescriptor() : base(new Fields()) { } public FieldsDescriptor Fields(params Expression>[] fields) => Assign(f => f.And(fields)); + public FieldsDescriptor Fields(params string[] fields) => Assign(f => f.And(fields)); + public FieldsDescriptor Fields(IEnumerable fields) => Assign(f => f.ListOfFields.AddRange(fields)); public FieldsDescriptor Field(Expression> field, double? boost = null) => Assign(f => f.And(field, boost)); + public FieldsDescriptor Field(string field, double? boost = null) => Assign(f => f.And(field, boost)); + public FieldsDescriptor Field(Field field) => Assign(f => f.And(field)); } } diff --git a/src/Nest/CommonAbstractions/Infer/Fields/FieldsJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/Fields/FieldsJsonConverter.cs index 144b044548b..630aa1fddeb 100644 --- a/src/Nest/CommonAbstractions/Infer/Fields/FieldsJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/Fields/FieldsJsonConverter.cs @@ -1,6 +1,4 @@ using System; -using System.Linq; -using Elasticsearch.Net; using Newtonsoft.Json; namespace Nest @@ -20,10 +18,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s if (fields != null) { var infer = serializer.GetConnectionSettings().Inferrer; - foreach (var f in fields.ListOfFields) - { - writer.WriteValue(infer.Field(f)); - } + foreach (var f in fields.ListOfFields) writer.WriteValue(infer.Field(f)); } writer.WriteEndArray(); } @@ -31,6 +26,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.StartArray) return null; + var fields = new Fields(); while (reader.TokenType != JsonToken.EndArray) { @@ -46,10 +42,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist reader.Read(); // "field"; var field = reader.ReadAsString(); fields.And(field); - while (reader.TokenType != JsonToken.EndObject) - { - reader.Read(); - } + while (reader.TokenType != JsonToken.EndObject) reader.Read(); reader.Read(); // "}"; break; } @@ -58,4 +51,3 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } } } - diff --git a/src/Nest/CommonAbstractions/Infer/Id/Id.cs b/src/Nest/CommonAbstractions/Infer/Id/Id.cs index afb2e259e11..092d7a68fee 100644 --- a/src/Nest/CommonAbstractions/Infer/Id/Id.cs +++ b/src/Nest/CommonAbstractions/Infer/Id/Id.cs @@ -10,47 +10,66 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class Id : IEquatable, IUrlParameter { - internal string StringValue { get; } - internal long? LongValue { get; } - internal string StringOrLongValue => this.StringValue ?? this.LongValue?.ToString(CultureInfo.InvariantCulture); - internal object Document { get; } - internal int Tag { get; } + public Id(string id) + { + Tag = 0; + StringValue = id; + } - public Id(string id) { Tag = 0; StringValue = id; } - public Id(long id) { Tag = 1; LongValue = id; } - public Id(object document) { Tag = 2; Document = document; } + public Id(long id) + { + Tag = 1; + LongValue = id; + } - public static implicit operator Id(string id) => id.IsNullOrEmpty() ? null : new Id(id); - public static implicit operator Id(long id) => new Id(id); - public static implicit operator Id(Guid id) => new Id(id.ToString("D")); + public Id(object document) + { + Tag = 2; + Document = document; + } - public static Id From(T document) where T : class => new Id(document); + internal object Document { get; } + internal long? LongValue { get; } + internal string StringOrLongValue => StringValue ?? LongValue?.ToString(CultureInfo.InvariantCulture); + internal string StringValue { get; } + internal int Tag { get; } private string DebugDisplay => StringOrLongValue ?? "Id from instance typeof: " + Document?.GetType().Name; - public override string ToString() => StringOrLongValue; - - string IUrlParameter.GetString(IConnectionConfigurationValues settings) - { - var nestSettings = (IConnectionSettingsValues)settings; - return nestSettings.Inferrer.Id(this.Document) ?? this.StringOrLongValue; - } + private static int TypeHashCode { get; } = typeof(Id).GetHashCode(); public bool Equals(Id other) { - if (this.Tag + other.Tag == 1) - return this.StringOrLongValue == other.StringOrLongValue; - else if (this.Tag != other.Tag) return false; - switch (this.Tag) + if (Tag + other.Tag == 1) + return StringOrLongValue == other.StringOrLongValue; + else if (Tag != other.Tag) return false; + + switch (Tag) { case 0: case 1: - return this.StringOrLongValue == other.StringOrLongValue; + return StringOrLongValue == other.StringOrLongValue; default: - return this.Document?.Equals(other.Document) ?? false; + return Document?.Equals(other.Document) ?? false; } } + string IUrlParameter.GetString(IConnectionConfigurationValues settings) + { + var nestSettings = (IConnectionSettingsValues)settings; + return nestSettings.Inferrer.Id(Document) ?? StringOrLongValue; + } + + public static implicit operator Id(string id) => id.IsNullOrEmpty() ? null : new Id(id); + + public static implicit operator Id(long id) => new Id(id); + + public static implicit operator Id(Guid id) => new Id(id.ToString("D")); + + public static Id From(T document) where T : class => new Id(document); + + public override string ToString() => StringOrLongValue; + public override bool Equals(object obj) { switch (obj) @@ -64,15 +83,14 @@ public override bool Equals(object obj) return Equals(new Id(obj)); } - private static int TypeHashCode { get; } = typeof(Id).GetHashCode(); public override int GetHashCode() { unchecked { var result = TypeHashCode; - result = (result * 397) ^ (this.StringValue?.GetHashCode() ?? 0); - result = (result * 397) ^ (this.LongValue?.GetHashCode() ?? 0); - result = (result * 397) ^ (this.Document?.GetHashCode() ?? 0); + result = (result * 397) ^ (StringValue?.GetHashCode() ?? 0); + result = (result * 397) ^ (LongValue?.GetHashCode() ?? 0); + result = (result * 397) ^ (Document?.GetHashCode() ?? 0); return result; } } diff --git a/src/Nest/CommonAbstractions/Infer/Id/IdExtensions.cs b/src/Nest/CommonAbstractions/Infer/Id/IdExtensions.cs index 70853750430..793ac155024 100644 --- a/src/Nest/CommonAbstractions/Infer/Id/IdExtensions.cs +++ b/src/Nest/CommonAbstractions/Infer/Id/IdExtensions.cs @@ -1,15 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Nest +namespace Nest { internal static class IdExtensions - { - internal static bool IsConditionless(this Id id) - { - return id == null || (id.StringOrLongValue == null && id.Document == null); - } + { + internal static bool IsConditionless(this Id id) => id == null || id.StringOrLongValue == null && id.Document == null; } } diff --git a/src/Nest/CommonAbstractions/Infer/Id/IdResolver.cs b/src/Nest/CommonAbstractions/Infer/Id/IdResolver.cs index 7bc0ccdca7d..0ba12d3cc66 100644 --- a/src/Nest/CommonAbstractions/Infer/Id/IdResolver.cs +++ b/src/Nest/CommonAbstractions/Infer/Id/IdResolver.cs @@ -6,22 +6,22 @@ namespace Nest { public class IdResolver { + private static readonly ConcurrentDictionary> IdDelegates = new ConcurrentDictionary>(); + + private static readonly MethodInfo MakeDelegateMethodInfo = + typeof(IdResolver).GetMethod(nameof(MakeDelegate), BindingFlags.Static | BindingFlags.NonPublic); + private readonly IConnectionSettingsValues _connectionSettings; private readonly ConcurrentDictionary> LocalIdDelegates = new ConcurrentDictionary>(); - private static readonly ConcurrentDictionary> IdDelegates = new ConcurrentDictionary>(); - private static readonly MethodInfo MakeDelegateMethodInfo = typeof(IdResolver).GetMethod(nameof(IdResolver.MakeDelegate), BindingFlags.Static | BindingFlags.NonPublic); - PropertyInfo GetPropertyCaseInsensitive(Type type, string fieldName) - => type.GetProperty(fieldName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); + public IdResolver(IConnectionSettingsValues connectionSettings) => _connectionSettings = connectionSettings; - public IdResolver(IConnectionSettingsValues connectionSettings) - { - _connectionSettings = connectionSettings; - } + private PropertyInfo GetPropertyCaseInsensitive(Type type, string fieldName) + => type.GetProperty(fieldName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); internal Func CreateIdSelector() where T : class { - Func idSelector = this.Resolve; + Func idSelector = Resolve; return idSelector; } @@ -37,7 +37,7 @@ public string Resolve(Type type, object @object) { if (type == null || @object == null) return null; - var preferLocal = this._connectionSettings.IdProperties.TryGetValue(type, out _); + var preferLocal = _connectionSettings.IdProperties.TryGetValue(type, out _); if (LocalIdDelegates.TryGetValue(type, out var cachedLookup)) return cachedLookup(@object); @@ -46,10 +46,8 @@ public string Resolve(Type type, object @object) return cachedLookup(@object); var idProperty = GetInferredId(type); - if (idProperty == null) - { - return null; - } + if (idProperty == null) return null; + var getMethod = idProperty.GetGetMethod(); var generic = MakeDelegateMethodInfo.MakeGenericMethod(type, getMethod.ReturnType); var func = (Func)generic.Invoke(null, new object[] { getMethod }); @@ -71,12 +69,12 @@ private PropertyInfo GetInferredId(Type type) // if the type specifies through ElasticAttribute what the id prop is // use that no matter what - this._connectionSettings.IdProperties.TryGetValue(type, out var propertyName); + _connectionSettings.IdProperties.TryGetValue(type, out var propertyName); if (!propertyName.IsNullOrEmpty()) return GetPropertyCaseInsensitive(type, propertyName); var esTypeAtt = ElasticsearchTypeAttribute.From(type); - propertyName = (esTypeAtt?.IdProperty.IsNullOrEmpty() ?? true) ? "Id" : esTypeAtt?.IdProperty; + propertyName = esTypeAtt?.IdProperty.IsNullOrEmpty() ?? true ? "Id" : esTypeAtt?.IdProperty; return GetPropertyCaseInsensitive(type, propertyName); } diff --git a/src/Nest/CommonAbstractions/Infer/IndexName/IndexName.cs b/src/Nest/CommonAbstractions/Infer/IndexName/IndexName.cs index 5a1f28f7590..82bf251e4a0 100644 --- a/src/Nest/CommonAbstractions/Infer/IndexName/IndexName.cs +++ b/src/Nest/CommonAbstractions/Infer/IndexName/IndexName.cs @@ -10,39 +10,56 @@ public class IndexName : IEquatable, IUrlParameter { private const char ClusterSeparator = ':'; - private static int TypeHashCode { get; } = typeof(IndexName).GetHashCode(); - - internal string DebugDisplay => Type == null ? Name : $"{nameof(IndexName)} for typeof: {Type?.Name}"; - - public string Cluster { get; } - public string Name { get; } - public Type Type { get; } - private IndexName(string index, string cluster = null) { - this.Name = index; - this.Cluster = cluster; + Name = index; + Cluster = cluster; } + private IndexName(Type type, string cluster = null) { - this.Type = type; - this.Cluster = cluster; + Type = type; + Cluster = cluster; } + private IndexName(string index, Type type, string cluster = null) { - this.Name = index; - this.Type = type; - this.Cluster = cluster; + Name = index; + Type = type; + Cluster = cluster; + } + + public string Cluster { get; } + public string Name { get; } + public Type Type { get; } + + internal string DebugDisplay => Type == null ? Name : $"{nameof(IndexName)} for typeof: {Type?.Name}"; + + private static int TypeHashCode { get; } = typeof(IndexName).GetHashCode(); + + bool IEquatable.Equals(IndexName other) => EqualsMarker(other); + + public string GetString(IConnectionConfigurationValues settings) + { + if (!(settings is IConnectionSettingsValues nestSettings)) + throw new Exception("Tried to pass index name on querystring but it could not be resolved because no nest settings are available"); + + return nestSettings.Inferrer.IndexName(this); } public static IndexName From() => typeof(T); + public static IndexName From(string clusterName) => From(typeof(T), clusterName); + private static IndexName From(Type t, string clusterName) => new IndexName(t, clusterName); + // TODO private? public static IndexName Rebuild(string index, Type t, string clusterName = null) => new IndexName(index, t, clusterName); public Indices And() => new Indices(new[] { this, typeof(T) }); + public Indices And(string clusterName) => new Indices(new[] { this, From(typeof(T), clusterName) }); + public Indices And(IndexName index) => new Indices(new[] { this, index }); private static IndexName Parse(string indexName) @@ -62,19 +79,18 @@ private static IndexName Parse(string indexName) } public static implicit operator IndexName(string indexName) => Parse(indexName); - public static implicit operator IndexName(Type type) => type == null ? null : new IndexName(type); - bool IEquatable.Equals(IndexName other) => EqualsMarker(other); + public static implicit operator IndexName(Type type) => type == null ? null : new IndexName(type); - public override bool Equals(object obj) => obj is string s ? this.EqualsString(s) : obj is IndexName i && EqualsMarker(i); + public override bool Equals(object obj) => obj is string s ? EqualsString(s) : obj is IndexName i && EqualsMarker(i); public override int GetHashCode() { unchecked { var result = TypeHashCode; - result = (result * 397) ^ (this.Name?.GetHashCode() ?? this.Type?.GetHashCode() ?? 0); - result = (result * 397) ^ (this.Cluster?.GetHashCode() ?? 0); + result = (result * 397) ^ (Name?.GetHashCode() ?? Type?.GetHashCode() ?? 0); + result = (result * 397) ^ (Cluster?.GetHashCode() ?? 0); return result; } } @@ -85,33 +101,27 @@ public override int GetHashCode() public override string ToString() { - if (!this.Name.IsNullOrEmpty()) - return PrefixClusterName(this.Name); - return this.Type != null ? PrefixClusterName(this.Type.Name) : string.Empty; + if (!Name.IsNullOrEmpty()) + return PrefixClusterName(Name); + + return Type != null ? PrefixClusterName(Type.Name) : string.Empty; } + private string PrefixClusterName(string name) => PrefixClusterName(this, name); + private static string PrefixClusterName(IndexName i, string name) => i.Cluster.IsNullOrEmpty() ? name : $"{i.Cluster}:{name}"; - private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == PrefixClusterName(this.Name); + private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == PrefixClusterName(Name); private bool EqualsMarker(IndexName other) { if (other == null) return false; - if (!this.Name.IsNullOrEmpty() && !other.Name.IsNullOrEmpty()) - return EqualsString(PrefixClusterName(other,other.Name)); - - if ((!this.Cluster.IsNullOrEmpty() || !other.Cluster.IsNullOrEmpty()) && this.Cluster != other.Cluster) return false; - - return this.Type != null && other?.Type != null && this.Type == other.Type; - } + if (!Name.IsNullOrEmpty() && !other.Name.IsNullOrEmpty()) + return EqualsString(PrefixClusterName(other, other.Name)); - public string GetString(IConnectionConfigurationValues settings) - { - if (!(settings is IConnectionSettingsValues nestSettings)) - throw new Exception("Tried to pass index name on querystring but it could not be resolved because no nest settings are available"); + if ((!Cluster.IsNullOrEmpty() || !other.Cluster.IsNullOrEmpty()) && Cluster != other.Cluster) return false; - return nestSettings.Inferrer.IndexName(this); + return Type != null && other?.Type != null && Type == other.Type; } - } } diff --git a/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameExtensions.cs b/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameExtensions.cs index c962b49bc36..97f0f7a4f12 100644 --- a/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameExtensions.cs +++ b/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameExtensions.cs @@ -6,11 +6,13 @@ public static string Resolve(this IndexName marker, IConnectionSettingsValues co { if (marker == null) return null; + connectionSettings.ThrowIfNull(nameof(connectionSettings)); if (marker.Type == null) return marker.Name; + return new IndexNameResolver(connectionSettings).Resolve(marker.Type); } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameJsonConverter.cs index f1ff0f64b9c..653d882b20f 100644 --- a/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameJsonConverter.cs @@ -23,9 +23,9 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.String) return null; + var typeName = reader.Value.ToString(); return (IndexName)typeName; } - } } diff --git a/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameResolver.cs b/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameResolver.cs index 4e02917f73a..0b25e09f064 100644 --- a/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameResolver.cs +++ b/src/Nest/CommonAbstractions/Infer/IndexName/IndexNameResolver.cs @@ -1,5 +1,4 @@ -using Elasticsearch.Net; -using System; +using System; namespace Nest { @@ -10,22 +9,24 @@ public class IndexNameResolver public IndexNameResolver(IConnectionSettingsValues connectionSettings) { connectionSettings.ThrowIfNull(nameof(connectionSettings)); - this._connectionSettings = connectionSettings; + _connectionSettings = connectionSettings; } - public string Resolve() where T : class => this.Resolve(typeof(T)); + + public string Resolve() where T : class => Resolve(typeof(T)); public string Resolve(IndexName i) { if (string.IsNullOrEmpty(i?.Name)) - return PrefixClusterName(i,this.Resolve(i?.Type)); + return PrefixClusterName(i, Resolve(i?.Type)); + ValidateIndexName(i.Name); return PrefixClusterName(i, i.Name); } public string Resolve(Type type) { - var indexName = this._connectionSettings.DefaultIndex; - var defaultIndices = this._connectionSettings.DefaultIndices; + var indexName = _connectionSettings.DefaultIndex; + var defaultIndices = _connectionSettings.DefaultIndices; if (defaultIndices != null && type != null) { if (defaultIndices.TryGetValue(type, out var value) && !string.IsNullOrEmpty(value)) @@ -34,6 +35,7 @@ public string Resolve(Type type) ValidateIndexName(indexName); return indexName; } + private static string PrefixClusterName(IndexName i, string name) => i.Cluster.IsNullOrEmpty() ? name : $"{i.Cluster}:{name}"; private static void ValidateIndexName(string indexName) diff --git a/src/Nest/CommonAbstractions/Infer/Indices/Indices.cs b/src/Nest/CommonAbstractions/Infer/Indices/Indices.cs index f893aaf4aab..73387397a31 100644 --- a/src/Nest/CommonAbstractions/Infer/Indices/Indices.cs +++ b/src/Nest/CommonAbstractions/Infer/Indices/Indices.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.Linq; using Elasticsearch.Net; -using Newtonsoft.Json; namespace Nest { @@ -11,76 +10,64 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class Indices : Union, IUrlParameter { - public class AllIndicesMarker { internal AllIndicesMarker() { } } + internal Indices(AllIndicesMarker all) : base(all) { } + + internal Indices(ManyIndices indices) : base(indices) { } + + internal Indices(IEnumerable indices) : base(new ManyIndices(indices)) { } + public static Indices All { get; } = new Indices(new AllIndicesMarker()); public static Indices AllIndices { get; } = new Indices(new AllIndicesMarker()); - public class ManyIndices - { - private readonly List _indices = new List(); - public IReadOnlyList Indices => _indices; - internal ManyIndices(IEnumerable indices) - { - indices.ThrowIfEmpty(nameof(indices)); - this._indices.AddRange(indices); - } - internal ManyIndices(IEnumerable indices) - { - indices.ThrowIfEmpty(nameof(indices)); - this._indices.AddRange(indices.Select(s=>(IndexName)s)); - } - public ManyIndices And() + private string DebugDisplay => Match( + all => "_all", + types => $"Count: {types.Indices.Count} [" + string.Join(",", types.Indices.Select((t, i) => $"({i + 1}: {t.DebugDisplay})")) + "]" + ); + + string IUrlParameter.GetString(IConnectionConfigurationValues settings) => Match( + all => "_all", + many => { - this._indices.Add(typeof(T)); - return this; - } - } + if (!(settings is IConnectionSettingsValues nestSettings)) + throw new Exception( + "Tried to pass index names on querysting but it could not be resolved because no nest settings are available"); - internal Indices(Indices.AllIndicesMarker all) : base(all) { } - internal Indices(Indices.ManyIndices indices) : base(indices) { } - internal Indices(IEnumerable indices) : base(new ManyIndices(indices)) { } + var infer = nestSettings.Inferrer; + var indices = many.Indices.Select(i => infer.IndexName(i)).Distinct(); + return string.Join(",", indices); + } + ); public static IndexName Index(IndexName index) => index; + public static IndexName Index() => typeof(T); + public static ManyIndices Index(IEnumerable indices) => new ManyIndices(indices); + public static ManyIndices Index(params IndexName[] indices) => new ManyIndices(indices); public static ManyIndices Index(IEnumerable indices) => new ManyIndices(indices); + public static ManyIndices Index(params string[] indices) => new ManyIndices(indices); public static Indices Parse(string indicesString) { if (indicesString.IsNullOrEmptyCommaSeparatedList(out var indices)) return null; + return indices.Contains("_all") ? All : Index(indices.Select(i => (IndexName)i)); } public static implicit operator Indices(string indicesString) => Parse(indicesString); + public static implicit operator Indices(ManyIndices many) => many == null ? null : new Indices(many); + public static implicit operator Indices(string[] many) => many.IsEmpty() ? null : new ManyIndices(many); - public static implicit operator Indices(IndexName[] many) => many.IsEmpty()? null : new ManyIndices(many); - public static implicit operator Indices(IndexName index) => index == null ? null : new ManyIndices(new[] { index }); - public static implicit operator Indices(Type type) => type == null ? null : new ManyIndices(new IndexName[] { type }); - private string DebugDisplay => this.Match( - all => "_all", - types => $"Count: {types.Indices.Count} [" + string.Join(",", types.Indices.Select((t, i) => $"({i+1}: {t.DebugDisplay})")) + "]" - ); + public static implicit operator Indices(IndexName[] many) => many.IsEmpty() ? null : new ManyIndices(many); - string IUrlParameter.GetString(IConnectionConfigurationValues settings) - { - return this.Match( - all => "_all", - many => - { - if (!(settings is IConnectionSettingsValues nestSettings)) - throw new Exception("Tried to pass index names on querysting but it could not be resolved because no nest settings are available"); - - var infer = nestSettings.Inferrer; - var indices = many.Indices.Select(i => infer.IndexName(i)).Distinct(); - return string.Join(",", indices); - } - ); - } + public static implicit operator Indices(IndexName index) => index == null ? null : new ManyIndices(new[] { index }); + + public static implicit operator Indices(Type type) => type == null ? null : new ManyIndices(new IndexName[] { type }); public static bool operator ==(Indices left, Indices right) => Equals(left, right); @@ -89,7 +76,8 @@ string IUrlParameter.GetString(IConnectionConfigurationValues settings) public override bool Equals(object obj) { if (!(obj is Indices other)) return false; - return this.Match( + + return Match( all => other.Match(a => true, m => false), many => other.Match( a => false, @@ -102,15 +90,43 @@ private static bool EqualsAllIndices(IReadOnlyList thisIndices, IRead { if (thisIndices == null && otherIndices == null) return true; if (thisIndices == null || otherIndices == null) return false; + return thisIndices.Count == otherIndices.Count && !thisIndices.Except(otherIndices).Any(); } - public override int GetHashCode() + public override int GetHashCode() => Match( + all => "_all".GetHashCode(), + many => string.Concat(many.Indices.OrderBy(i => i.ToString())).GetHashCode() + ); + + public class AllIndicesMarker { - return this.Match( - all => "_all".GetHashCode(), - many => string.Concat(many.Indices.OrderBy(i => i.ToString())).GetHashCode() - ); + internal AllIndicesMarker() { } + } + + public class ManyIndices + { + private readonly List _indices = new List(); + + internal ManyIndices(IEnumerable indices) + { + indices.ThrowIfEmpty(nameof(indices)); + _indices.AddRange(indices); + } + + internal ManyIndices(IEnumerable indices) + { + indices.ThrowIfEmpty(nameof(indices)); + _indices.AddRange(indices.Select(s => (IndexName)s)); + } + + public IReadOnlyList Indices => _indices; + + public ManyIndices And() + { + _indices.Add(typeof(T)); + return this; + } } } } diff --git a/src/Nest/CommonAbstractions/Infer/Indices/IndicesExtensions.cs b/src/Nest/CommonAbstractions/Infer/Indices/IndicesExtensions.cs index 6c042edd153..d8b1a6d9154 100644 --- a/src/Nest/CommonAbstractions/Infer/Indices/IndicesExtensions.cs +++ b/src/Nest/CommonAbstractions/Infer/Indices/IndicesExtensions.cs @@ -5,6 +5,7 @@ public static class IndicesExtensions public static string Resolve(this Indices marker, IConnectionSettingsValues connectionSettings) { if (marker == null) return null; + connectionSettings.ThrowIfNull(nameof(connectionSettings)); return connectionSettings.Inferrer.Resolve(marker); } diff --git a/src/Nest/CommonAbstractions/Infer/Indices/IndicesJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/Indices/IndicesJsonConverter.cs index 0d78167febb..1199c1d4036 100644 --- a/src/Nest/CommonAbstractions/Infer/Indices/IndicesJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/Indices/IndicesJsonConverter.cs @@ -38,6 +38,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.StartArray) return null; + var indices = new List(); while (reader.TokenType != JsonToken.EndArray) { @@ -47,6 +48,5 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } return new Indices(indices); } - } } diff --git a/src/Nest/CommonAbstractions/Infer/Indices/IndicesMultiSyntaxJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/Indices/IndicesMultiSyntaxJsonConverter.cs index 5ed9167d160..3df5e27c75d 100644 --- a/src/Nest/CommonAbstractions/Infer/Indices/IndicesMultiSyntaxJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/Indices/IndicesMultiSyntaxJsonConverter.cs @@ -4,7 +4,6 @@ namespace Nest { - internal class IndicesMultiSyntaxJsonConverter : JsonConverter { public override bool CanConvert(Type objectType) => typeof(Indices) == objectType; @@ -18,7 +17,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s return; } marker.Match( - all=> writer.WriteValue("_all"), + all => writer.WriteValue("_all"), many => writer.WriteValue(((IUrlParameter)marker).GetString(serializer.GetConnectionSettings())) ); } @@ -27,11 +26,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { if (reader.TokenType == JsonToken.String) { - string indices = reader.Value.ToString(); + var indices = reader.Value.ToString(); return (Indices)indices; } return null; } - } } diff --git a/src/Nest/CommonAbstractions/Infer/Inferrer.cs b/src/Nest/CommonAbstractions/Infer/Inferrer.cs index 8aa5878518c..a7cbe8cc99d 100644 --- a/src/Nest/CommonAbstractions/Infer/Inferrer.cs +++ b/src/Nest/CommonAbstractions/Infer/Inferrer.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Globalization; -using System.Linq; using Elasticsearch.Net; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; @@ -12,57 +10,65 @@ namespace Nest public class Inferrer { private readonly IConnectionSettingsValues _connectionSettings; - private IdResolver IdResolver { get; } - private IndexNameResolver IndexNameResolver { get; } - private TypeNameResolver TypeNameResolver { get; } - private RelationNameResolver RelationNameResolver { get; } - private FieldResolver FieldResolver { get; } - private RoutingResolver RoutingResolver { get; } - - internal ConcurrentDictionary Contracts { get; } - internal ConcurrentDictionary>>> CreateMultiHitDelegates { get; } - internal ConcurrentDictionary>> CreateSearchResponseDelegates { get; } public Inferrer(IConnectionSettingsValues connectionSettings) { connectionSettings.ThrowIfNull(nameof(connectionSettings)); - this._connectionSettings = connectionSettings; - this.IdResolver = new IdResolver(connectionSettings); - this.IndexNameResolver = new IndexNameResolver(connectionSettings); - this.TypeNameResolver = new TypeNameResolver(connectionSettings); - this.RelationNameResolver = new RelationNameResolver(connectionSettings); - this.FieldResolver = new FieldResolver(connectionSettings); - this.RoutingResolver = new RoutingResolver(connectionSettings, this.IdResolver); - - this.Contracts = new ConcurrentDictionary(); - this.CreateMultiHitDelegates = new ConcurrentDictionary>>>(); - this.CreateSearchResponseDelegates = new ConcurrentDictionary>>(); + _connectionSettings = connectionSettings; + IdResolver = new IdResolver(connectionSettings); + IndexNameResolver = new IndexNameResolver(connectionSettings); + TypeNameResolver = new TypeNameResolver(connectionSettings); + RelationNameResolver = new RelationNameResolver(connectionSettings); + FieldResolver = new FieldResolver(connectionSettings); + RoutingResolver = new RoutingResolver(connectionSettings, IdResolver); + + Contracts = new ConcurrentDictionary(); + CreateMultiHitDelegates = + new ConcurrentDictionary>>>(); + CreateSearchResponseDelegates = + new ConcurrentDictionary> + >(); } - public string Resolve(IUrlParameter urlParameter) => urlParameter.GetString(this._connectionSettings); + internal ConcurrentDictionary Contracts { get; } + + internal ConcurrentDictionary>>> + CreateMultiHitDelegates { get; } + + internal ConcurrentDictionary>> + CreateSearchResponseDelegates { get; } + + private FieldResolver FieldResolver { get; } + private IdResolver IdResolver { get; } + private IndexNameResolver IndexNameResolver { get; } + private RelationNameResolver RelationNameResolver { get; } + private RoutingResolver RoutingResolver { get; } + private TypeNameResolver TypeNameResolver { get; } + + public string Resolve(IUrlParameter urlParameter) => urlParameter.GetString(_connectionSettings); + + public string Field(Field field) => FieldResolver.Resolve(field); - public string Field(Field field) => this.FieldResolver.Resolve(field); + public string PropertyName(PropertyName property) => FieldResolver.Resolve(property); - public string PropertyName(PropertyName property) => this.FieldResolver.Resolve(property); + public string IndexName() where T : class => IndexNameResolver.Resolve(); - public string IndexName() where T : class => this.IndexNameResolver.Resolve(); + public string IndexName(IndexName index) => IndexNameResolver.Resolve(index); - public string IndexName(IndexName index) => this.IndexNameResolver.Resolve(index); + public string Id(T instance) where T : class => IdResolver.Resolve(instance); - public string Id(T instance) where T : class => this.IdResolver.Resolve(instance); + public string Id(Type type, object instance) => IdResolver.Resolve(type, instance); - public string Id(Type type, object instance) => this.IdResolver.Resolve(type, instance); + public string TypeName() where T : class => TypeNameResolver.Resolve(); - public string TypeName() where T : class => this.TypeNameResolver.Resolve(); + public string TypeName(TypeName type) => TypeNameResolver.Resolve(type); - public string TypeName(TypeName type) => this.TypeNameResolver.Resolve(type); + public string RelationName() where T : class => RelationNameResolver.Resolve(); - public string RelationName() where T : class => this.RelationNameResolver.Resolve(); + public string RelationName(RelationName type) => RelationNameResolver.Resolve(type); - public string RelationName(RelationName type) => this.RelationNameResolver.Resolve(type); + public string Routing(T document) => RoutingResolver.Resolve(document); - public string Routing(T document) => this.RoutingResolver.Resolve(document); - - public string Routing(Type type, object instance) => this.RoutingResolver.Resolve(type, instance); + public string Routing(Type type, object instance) => RoutingResolver.Resolve(type, instance); } } diff --git a/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/Routing.cs b/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/Routing.cs index b3104b698e1..e5e3eaa35d5 100644 --- a/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/Routing.cs +++ b/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/Routing.cs @@ -11,14 +11,7 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class Routing : IEquatable, IUrlParameter { - internal string StringValue { get; } - internal long? LongValue { get; } - internal string StringOrLongValue => this.StringValue ?? this.LongValue?.ToString(CultureInfo.InvariantCulture); - - internal object Document { get; } - internal Func DocumentGetter { get; } - - internal int Tag { get; } + private static readonly char[] Separator = { ',' }; internal Routing(Func documentGetter) { @@ -44,15 +37,38 @@ public Routing(object document) Document = document; } - public static implicit operator Routing(string routing) => routing.IsNullOrEmptyCommaSeparatedList(out _) ? null : new Routing(routing); - public static implicit operator Routing(string[] routing) => routing.IsEmpty() ? null : new Routing(string.Join(",", routing)); - public static implicit operator Routing(long routing) => new Routing(routing); - public static implicit operator Routing(Guid routing) => new Routing(routing.ToString("D")); + internal object Document { get; } + internal Func DocumentGetter { get; } + internal long? LongValue { get; } + internal string StringOrLongValue => StringValue ?? LongValue?.ToString(CultureInfo.InvariantCulture); + internal string StringValue { get; } - /// Use the inferred routing from - public static Routing From(T document) where T : class => new Routing(document); + internal int Tag { get; } + + private string DebugDisplay => StringOrLongValue ?? "Routing from instance typeof: " + Document?.GetType().Name; + + private static int TypeHashCode { get; } = typeof(Routing).GetHashCode(); - private string DebugDisplay => this.StringOrLongValue ?? "Routing from instance typeof: " + Document?.GetType().Name; + public bool Equals(Routing other) + { + if (Tag == other.Tag) + { + switch (Tag) + { + case 0: + var t = DocumentGetter(); + var o = other.DocumentGetter(); + return t?.Equals(o) ?? false; + case 4: return Document?.Equals(other.Document) ?? false; + default: + return StringEquals(StringOrLongValue, other.StringOrLongValue); + } + } + else if (Tag + other.Tag == 3) + return StringEquals(StringOrLongValue, other.StringOrLongValue); + else + return false; + } string IUrlParameter.GetString(IConnectionConfigurationValues settings) { @@ -60,59 +76,48 @@ string IUrlParameter.GetString(IConnectionConfigurationValues settings) return GetString(nestSettings); } + public static implicit operator Routing(string routing) => routing.IsNullOrEmptyCommaSeparatedList(out _) ? null : new Routing(routing); + + public static implicit operator Routing(string[] routing) => routing.IsEmpty() ? null : new Routing(string.Join(",", routing)); + + public static implicit operator Routing(long routing) => new Routing(routing); + + public static implicit operator Routing(Guid routing) => new Routing(routing.ToString("D")); + + /// Use the inferred routing from + public static Routing From(T document) where T : class => new Routing(document); + private string GetString(IConnectionSettingsValues nestSettings) { string value = null; - if (this.DocumentGetter != null) + if (DocumentGetter != null) { - var doc = this.DocumentGetter(); + var doc = DocumentGetter(); value = nestSettings.Inferrer.Routing(doc); } - else if (this.Document != null) - value = nestSettings.Inferrer.Routing(this.Document); + else if (Document != null) + value = nestSettings.Inferrer.Routing(Document); - return value ?? this.StringOrLongValue; + return value ?? StringOrLongValue; } public static bool operator ==(Routing left, Routing right) => Equals(left, right); public static bool operator !=(Routing left, Routing right) => !Equals(left, right); - public bool Equals(Routing other) - { - if (this.Tag == other.Tag) - { - switch (this.Tag) - { - case 0: - var t = this.DocumentGetter(); - var o = other.DocumentGetter(); - return t?.Equals(o) ?? false; - case 4: return this.Document?.Equals(other.Document) ?? false; - default: - return StringEquals(this.StringOrLongValue, other.StringOrLongValue); - } - } - else if (this.Tag + other.Tag == 3) - return StringEquals(this.StringOrLongValue, other.StringOrLongValue); - else - return false; - } - - private static readonly char[] Separator = {','}; - private static bool StringEquals(string left, string right) { if (left == null && right == null) return true; else if (left == null || right == null) return false; + if (!left.Contains(",") || !right.Contains(",")) return left == right; - var l1 = left.Split(Separator, StringSplitOptions.RemoveEmptyEntries).Select(v=>v.Trim()).ToList(); - var l2 = right.Split(Separator, StringSplitOptions.RemoveEmptyEntries).Select(v=>v.Trim()).ToList(); + var l1 = left.Split(Separator, StringSplitOptions.RemoveEmptyEntries).Select(v => v.Trim()).ToList(); + var l2 = right.Split(Separator, StringSplitOptions.RemoveEmptyEntries).Select(v => v.Trim()).ToList(); if (l1.Count != l2.Count) return false; - return l1.Count == l2.Count && !l1.Except(l2).Any(); + return l1.Count == l2.Count && !l1.Except(l2).Any(); } public override bool Equals(object obj) @@ -129,16 +134,15 @@ public override bool Equals(object obj) return Equals(new Routing(obj)); } - private static int TypeHashCode { get; } = typeof(Routing).GetHashCode(); public override int GetHashCode() { unchecked { var result = TypeHashCode; - result = (result * 397) ^ (this.StringValue?.GetHashCode() ?? 0); - result = (result * 397) ^ (this.LongValue?.GetHashCode() ?? 0); - result = (result * 397) ^ (this.DocumentGetter?.GetHashCode() ?? 0); - result = (result * 397) ^ (this.Document?.GetHashCode() ?? 0); + result = (result * 397) ^ (StringValue?.GetHashCode() ?? 0); + result = (result * 397) ^ (LongValue?.GetHashCode() ?? 0); + result = (result * 397) ^ (DocumentGetter?.GetHashCode() ?? 0); + result = (result * 397) ^ (Document?.GetHashCode() ?? 0); return result; } } diff --git a/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/RoutingResolver.cs b/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/RoutingResolver.cs index 1008f2816b3..84cdc3b9f57 100644 --- a/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/RoutingResolver.cs +++ b/src/Nest/CommonAbstractions/Infer/JoinFieldRouting/RoutingResolver.cs @@ -7,21 +7,26 @@ namespace Nest { public class RoutingResolver { - private static readonly ConcurrentDictionary> PropertyGetDelegates = new ConcurrentDictionary>(); - private readonly ConcurrentDictionary> LocalRouteDelegates = new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> PropertyGetDelegates = + new ConcurrentDictionary>(); + private static readonly MethodInfo MakeDelegateMethodInfo = typeof(RoutingResolver).GetMethod(nameof(MakeDelegate), BindingFlags.Static | BindingFlags.NonPublic); + private readonly IConnectionSettingsValues _connectionSettings; private readonly IdResolver _idResolver; + private readonly ConcurrentDictionary> + LocalRouteDelegates = new ConcurrentDictionary>(); + public RoutingResolver(IConnectionSettingsValues connectionSettings, IdResolver idResolver) { _connectionSettings = connectionSettings; _idResolver = idResolver; } - PropertyInfo GetPropertyCaseInsensitive(Type type, string fieldName) => + private PropertyInfo GetPropertyCaseInsensitive(Type type, string fieldName) => type.GetProperty(fieldName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); internal static Func MakeDelegate(MethodInfo @get) @@ -35,6 +40,7 @@ internal static Func MakeDelegate(MethodInfo @get) public string Resolve(Type type, object @object) { if (TryConnectionSettingsRoute(type, @object, out var route)) return route; + var joinField = GetJoinFieldFromObject(type, @object); return joinField?.Match(p => _idResolver.Resolve(@object), c => ResolveId(c.Parent, _connectionSettings)); } @@ -42,7 +48,7 @@ public string Resolve(Type type, object @object) private bool TryConnectionSettingsRoute(Type type, object @object, out string route) { route = null; - if (!this._connectionSettings.RouteProperties.TryGetValue(type, out var propertyName)) + if (!_connectionSettings.RouteProperties.TryGetValue(type, out var propertyName)) return false; if (LocalRouteDelegates.TryGetValue(type, out var cachedLookup)) @@ -92,7 +98,7 @@ private static Func CreateGetterFunc(Type type, PropertyInfo joi { var getMethod = joinProperty.GetGetMethod(); var generic = MakeDelegateMethodInfo.MakeGenericMethod(type, getMethod.ReturnType); - var func = (Func) generic.Invoke(null, new object[] {getMethod}); + var func = (Func)generic.Invoke(null, new object[] { getMethod }); return func; } @@ -101,8 +107,8 @@ private static PropertyInfo GetJoinFieldProperty(Type type) var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public); try { - var joinField = properties.SingleOrDefault(p => p.PropertyType == typeof(JoinField)); - return joinField; + var joinField = properties.SingleOrDefault(p => p.PropertyType == typeof(JoinField)); + return joinField; } catch (InvalidOperationException e) { diff --git a/src/Nest/CommonAbstractions/Infer/Metrics/IndexMetrics.cs b/src/Nest/CommonAbstractions/Infer/Metrics/IndexMetrics.cs index 240b15e6ece..614f5b1b00b 100644 --- a/src/Nest/CommonAbstractions/Infer/Metrics/IndexMetrics.cs +++ b/src/Nest/CommonAbstractions/Infer/Metrics/IndexMetrics.cs @@ -6,19 +6,22 @@ namespace Nest public class IndexMetrics : IEquatable, IUrlParameter { private readonly NodesStatsIndexMetric _enumValue; + + internal IndexMetrics(NodesStatsIndexMetric metric) => _enumValue = metric; + internal Enum Value => _enumValue; - public string GetString(IConnectionConfigurationValues settings) => this._enumValue.GetStringValue(); - internal IndexMetrics(NodesStatsIndexMetric metric) { _enumValue = metric; } + public bool Equals(IndexMetrics other) => Value.Equals(other.Value); + + public string GetString(IConnectionConfigurationValues settings) => _enumValue.GetStringValue(); public static implicit operator IndexMetrics(NodesStatsIndexMetric metric) => new IndexMetrics(metric); - public bool Equals(Enum other) => this.Value.Equals(other); - public bool Equals(IndexMetrics other) => this.Value.Equals(other.Value); + public bool Equals(Enum other) => Value.Equals(other); public override bool Equals(object obj) => obj is Enum e ? Equals(e) : obj is IndexMetrics m && Equals(m.Value); - public override int GetHashCode() => (_enumValue.GetHashCode()); + public override int GetHashCode() => _enumValue.GetHashCode(); public static bool operator ==(IndexMetrics left, IndexMetrics right) => Equals(left, right); diff --git a/src/Nest/CommonAbstractions/Infer/Metrics/Metrics.cs b/src/Nest/CommonAbstractions/Infer/Metrics/Metrics.cs index 458f720e23f..4e72fd8828e 100644 --- a/src/Nest/CommonAbstractions/Infer/Metrics/Metrics.cs +++ b/src/Nest/CommonAbstractions/Infer/Metrics/Metrics.cs @@ -5,30 +5,41 @@ namespace Nest { public class Metrics : IEquatable, IUrlParameter { - private readonly Enum _enumValue; - internal Enum Value => _enumValue; + internal Metrics(IndicesStatsMetric metric) => Value = metric; - public string GetString(IConnectionConfigurationValues settings) => this._enumValue.GetStringValue(); - internal Metrics(IndicesStatsMetric metric) { _enumValue = metric; } - internal Metrics(NodesStatsMetric metric){ _enumValue = metric; } - internal Metrics(NodesInfoMetric metric){ _enumValue = metric; } - internal Metrics(ClusterStateMetric metric){ _enumValue = metric; } - internal Metrics(WatcherStatsMetric metric){ _enumValue = metric; } - internal Metrics(NodesUsageMetric metric){ _enumValue = metric; } + internal Metrics(NodesStatsMetric metric) => Value = metric; + + internal Metrics(NodesInfoMetric metric) => Value = metric; + + internal Metrics(ClusterStateMetric metric) => Value = metric; + + internal Metrics(WatcherStatsMetric metric) => Value = metric; + + internal Metrics(NodesUsageMetric metric) => Value = metric; + + internal Enum Value { get; } + + public bool Equals(Metrics other) => Value.Equals(other.Value); + + public string GetString(IConnectionConfigurationValues settings) => Value.GetStringValue(); public static implicit operator Metrics(IndicesStatsMetric metric) => new Metrics(metric); + public static implicit operator Metrics(NodesStatsMetric metric) => new Metrics(metric); + public static implicit operator Metrics(NodesInfoMetric metric) => new Metrics(metric); + public static implicit operator Metrics(ClusterStateMetric metric) => new Metrics(metric); + public static implicit operator Metrics(WatcherStatsMetric metric) => new Metrics(metric); + public static implicit operator Metrics(NodesUsageMetric metric) => new Metrics(metric); - public bool Equals(Enum other) => this.Value.Equals(other); - public bool Equals(Metrics other) => this.Value.Equals(other.Value); + public bool Equals(Enum other) => Value.Equals(other); public override bool Equals(object obj) => obj is Enum e ? Equals(e) : obj is Metrics m && Equals(m.Value); - public override int GetHashCode() => (_enumValue != null ? _enumValue.GetHashCode() : 0); + public override int GetHashCode() => Value != null ? Value.GetHashCode() : 0; public static bool operator ==(Metrics left, Metrics right) => Equals(left, right); diff --git a/src/Nest/CommonAbstractions/Infer/Name/Name.cs b/src/Nest/CommonAbstractions/Infer/Name/Name.cs index 5d9bd54915d..40c95a62171 100644 --- a/src/Nest/CommonAbstractions/Infer/Name/Name.cs +++ b/src/Nest/CommonAbstractions/Infer/Name/Name.cs @@ -7,13 +7,17 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class Name : IEquatable, IUrlParameter { - private readonly string _name; - internal string Value => _name; - private string DebugDisplay => _name; + public Name(string name) => Value = name?.Trim(); - public Name(string name) => this._name = name?.Trim(); + internal string Value { get; } - string IUrlParameter.GetString(IConnectionConfigurationValues settings) => _name; + private string DebugDisplay => Value; + + private static int TypeHashCode { get; } = typeof(Name).GetHashCode(); + + public bool Equals(Name other) => EqualsString(other?.Value); + + string IUrlParameter.GetString(IConnectionConfigurationValues settings) => Value; public static implicit operator Name(string name) => name.IsNullOrEmpty() ? null : new Name(name); @@ -21,20 +25,17 @@ public class Name : IEquatable, IUrlParameter public static bool operator !=(Name left, Name right) => !Equals(left, right); - public bool Equals(Name other) => EqualsString(other?.Value); - public override bool Equals(object obj) => - obj is string s ? this.EqualsString(s) : (obj is Name i) && this.EqualsString(i.Value); + obj is string s ? EqualsString(s) : obj is Name i && EqualsString(i.Value); - private bool EqualsString(string other) => !other.IsNullOrEmpty() && other.Trim() == this.Value; + private bool EqualsString(string other) => !other.IsNullOrEmpty() && other.Trim() == Value; - private static int TypeHashCode { get; } = typeof(Name).GetHashCode(); public override int GetHashCode() { unchecked { var result = TypeHashCode; - result = (result * 397) ^ (this.Value?.GetHashCode() ?? 0); + result = (result * 397) ^ (Value?.GetHashCode() ?? 0); return result; } } diff --git a/src/Nest/CommonAbstractions/Infer/Name/Names.cs b/src/Nest/CommonAbstractions/Infer/Name/Names.cs index b8b57032a8f..293d74d0f32 100644 --- a/src/Nest/CommonAbstractions/Infer/Name/Names.cs +++ b/src/Nest/CommonAbstractions/Infer/Name/Names.cs @@ -9,24 +9,25 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class Names : IEquatable, IUrlParameter { - private readonly IList _names; - internal IList Value => _names; - - public Names(IEnumerable names) : this(names?.Select(n=>(Name)n).ToList()) { } + public Names(IEnumerable names) : this(names?.Select(n => (Name)n).ToList()) { } public Names(IEnumerable names) { - this._names = names?.ToList(); - if (!this._names.HasAny()) + Value = names?.ToList(); + if (!Value.HasAny()) throw new ArgumentException($"can not create {nameof(Names)} on an empty enumerable of ", nameof(names)); } - public static Names Parse(string names) => names.IsNullOrEmptyCommaSeparatedList(out var list) ? null : new Names(list); + internal IList Value { get; } + + private string DebugDisplay => ((IUrlParameter)this).GetString(null); + + public bool Equals(Names other) => EqualsAllIds(Value, other.Value); string IUrlParameter.GetString(IConnectionConfigurationValues settings) => - string.Join(",", this._names.Cast().Select(n => n.GetString(settings))); + string.Join(",", Value.Cast().Select(n => n.GetString(settings))); - private string DebugDisplay => ((IUrlParameter)this).GetString(null); + public static Names Parse(string names) => names.IsNullOrEmptyCommaSeparatedList(out var list) ? null : new Names(list); public static implicit operator Names(Name name) => name == null ? null : new Names(new[] { name }); @@ -38,18 +39,17 @@ string IUrlParameter.GetString(IConnectionConfigurationValues settings) => public static bool operator !=(Names left, Names right) => !Equals(left, right); - public bool Equals(Names other) => EqualsAllIds(this.Value, other.Value); - private static bool EqualsAllIds(ICollection thisIds, ICollection otherIds) { if (thisIds == null && otherIds == null) return true; if (thisIds == null || otherIds == null) return false; if (thisIds.Count != otherIds.Count) return false; + return thisIds.Count == otherIds.Count && !thisIds.Except(otherIds).Any(); } - public override bool Equals(object obj) => obj is string s ? this.Equals(Parse(s)) : (obj is Names i) && this.Equals(i); + public override bool Equals(object obj) => obj is string s ? Equals(Parse(s)) : obj is Names i && Equals(i); - public override int GetHashCode() => this._names.GetHashCode(); + public override int GetHashCode() => Value.GetHashCode(); } } diff --git a/src/Nest/CommonAbstractions/Infer/NodeId/NodeIds.cs b/src/Nest/CommonAbstractions/Infer/NodeId/NodeIds.cs index 62649c870a7..86e0e217ebb 100644 --- a/src/Nest/CommonAbstractions/Infer/NodeId/NodeIds.cs +++ b/src/Nest/CommonAbstractions/Infer/NodeId/NodeIds.cs @@ -9,41 +9,42 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class NodeIds : IEquatable, IUrlParameter { - private readonly IList _nodeIds; - internal IList Value => _nodeIds; - public NodeIds(IEnumerable nodeIds) { - this._nodeIds = nodeIds?.ToList(); - if (!this._nodeIds.HasAny()) - throw new ArgumentException($"can not create {nameof(NodeIds )} on an empty enumerable of ", nameof(nodeIds)); + Value = nodeIds?.ToList(); + if (!Value.HasAny()) + throw new ArgumentException($"can not create {nameof(NodeIds)} on an empty enumerable of ", nameof(nodeIds)); } + internal IList Value { get; } + private string DebugDisplay => ((IUrlParameter)this).GetString(null); - string IUrlParameter.GetString(IConnectionConfigurationValues settings) => string.Join(",", this._nodeIds); + public bool Equals(NodeIds other) => EqualsAllIds(Value, other.Value); + + string IUrlParameter.GetString(IConnectionConfigurationValues settings) => string.Join(",", Value); public static NodeIds Parse(string nodeIds) => nodeIds.IsNullOrEmptyCommaSeparatedList(out var nodes) ? null : new NodeIds(nodes); public static implicit operator NodeIds(string nodes) => Parse(nodes); + public static implicit operator NodeIds(string[] nodes) => nodes.IsEmpty() ? null : new NodeIds(nodes); public static bool operator ==(NodeIds left, NodeIds right) => Equals(left, right); public static bool operator !=(NodeIds left, NodeIds right) => !Equals(left, right); - public bool Equals(NodeIds other) => EqualsAllIds(this.Value, other.Value); - private static bool EqualsAllIds(ICollection thisIds, ICollection otherIds) { if (thisIds == null && otherIds == null) return true; if (thisIds == null || otherIds == null) return false; if (thisIds.Count != otherIds.Count) return false; + return thisIds.Count == otherIds.Count && !thisIds.Except(otherIds).Any(); } - public override bool Equals(object obj) => obj is string s ? this.Equals(Parse(s)) : (obj is NodeIds i) && this.Equals(i); + public override bool Equals(object obj) => obj is string s ? Equals(Parse(s)) : obj is NodeIds i && Equals(i); - public override int GetHashCode() => this._nodeIds.GetHashCode(); + public override int GetHashCode() => Value.GetHashCode(); } } diff --git a/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyName.cs b/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyName.cs index 1f4a7ef6ea3..d902d6a28bb 100644 --- a/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyName.cs +++ b/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyName.cs @@ -10,21 +10,9 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class PropertyName : IEquatable, IUrlParameter { - private static int TypeHashCode { get; } = typeof(PropertyName).GetHashCode(); - - public string Name { get; } - public Expression Expression { get; } - public PropertyInfo Property { get; } - public bool CacheableExpression { get; } - private readonly object _comparisonValue; private readonly Type _type; - internal string DebugDisplay => - $"{Expression?.ToString() ?? PropertyDebug ?? Name}{(_type == null ? "" : " typeof: " + _type.Name)}"; - - private string PropertyDebug => Property == null ? null : $"PropertyInfo: {Property.Name}"; - public PropertyName(string name) { Name = name; @@ -46,6 +34,29 @@ public PropertyName(PropertyInfo property) _type = property.DeclaringType; } + public bool CacheableExpression { get; } + public Expression Expression { get; } + + public string Name { get; } + public PropertyInfo Property { get; } + + internal string DebugDisplay => + $"{Expression?.ToString() ?? PropertyDebug ?? Name}{(_type == null ? "" : " typeof: " + _type.Name)}"; + + private string PropertyDebug => Property == null ? null : $"PropertyInfo: {Property.Name}"; + private static int TypeHashCode { get; } = typeof(PropertyName).GetHashCode(); + + public bool Equals(PropertyName other) => EqualsMarker(other); + + string IUrlParameter.GetString(IConnectionConfigurationValues settings) + { + if (!(settings is IConnectionSettingsValues nestSettings)) + throw new ArgumentNullException(nameof(settings), + $"Can not resolve {nameof(PropertyName)} if no {nameof(IConnectionSettingsValues)} is provided"); + + return nestSettings.Inferrer.PropertyName(this); + } + public static implicit operator PropertyName(string name) => name.IsNullOrEmpty() ? null : new PropertyName(name); public static implicit operator PropertyName(Expression expression) => expression == null ? null : new PropertyName(expression); @@ -63,30 +74,17 @@ public override int GetHashCode() } } - public bool Equals(PropertyName other) => EqualsMarker(other); - public override bool Equals(object obj) => - obj is string s ? this.EqualsString(s) : (obj is PropertyName r) && this.EqualsMarker(r); + obj is string s ? EqualsString(s) : obj is PropertyName r && EqualsMarker(r); - private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == this.Name; + private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == Name; - public bool EqualsMarker(PropertyName other) - { - return _type != null - ? other != null && _type == other._type && _comparisonValue.Equals(other._comparisonValue) - : other != null && _comparisonValue.Equals(other._comparisonValue); - } + public bool EqualsMarker(PropertyName other) => _type != null + ? other != null && _type == other._type && _comparisonValue.Equals(other._comparisonValue) + : other != null && _comparisonValue.Equals(other._comparisonValue); public static bool operator ==(PropertyName left, PropertyName right) => Equals(left, right); public static bool operator !=(PropertyName left, PropertyName right) => !Equals(left, right); - - string IUrlParameter.GetString(IConnectionConfigurationValues settings) - { - if (!(settings is IConnectionSettingsValues nestSettings)) - throw new ArgumentNullException(nameof(settings), $"Can not resolve {nameof(PropertyName)} if no {nameof(IConnectionSettingsValues)} is provided"); - - return nestSettings.Inferrer.PropertyName(this); - } } } diff --git a/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameExtensions.cs b/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameExtensions.cs index 7965692fe70..bb89ca4648a 100644 --- a/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameExtensions.cs +++ b/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameExtensions.cs @@ -2,9 +2,7 @@ { internal static class PropertyNameExtensions { - internal static bool IsConditionless(this PropertyName property) - { - return property == null || (property.Name.IsNullOrEmpty() && property.Expression == null && property.Property == null); - } + internal static bool IsConditionless(this PropertyName property) => + property == null || property.Name.IsNullOrEmpty() && property.Expression == null && property.Property == null; } } diff --git a/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameJsonConverter.cs index 96d954582e7..061979dd249 100644 --- a/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/PropertyName/PropertyNameJsonConverter.cs @@ -22,12 +22,13 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s var infer = serializer.GetConnectionSettings().Inferrer; writer.WriteValue(infer.PropertyName(property)); } + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.String) return null; + var property = reader.Value.ToString(); return (PropertyName)property; } } } - diff --git a/src/Nest/CommonAbstractions/Infer/RelationName/RelationName.cs b/src/Nest/CommonAbstractions/Infer/RelationName/RelationName.cs index 1ad349e87fe..dcd603130a8 100644 --- a/src/Nest/CommonAbstractions/Infer/RelationName/RelationName.cs +++ b/src/Nest/CommonAbstractions/Infer/RelationName/RelationName.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using System.Linq; using Elasticsearch.Net; namespace Nest @@ -9,14 +8,28 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class RelationName : IEquatable, IUrlParameter { + private RelationName(string type) => Name = type; + + private RelationName(Type type) => Type = type; + public string Name { get; } public Type Type { get; } - private RelationName(string type) => this.Name = type; - private RelationName(Type type) => this.Type = type; - internal string DebugDisplay => Type == null ? Name : $"{nameof(RelationName)} for typeof: {Type?.Name}"; + private static int TypeHashCode { get; } = typeof(RelationName).GetHashCode(); + + public bool Equals(RelationName other) => EqualsMarker(other); + + string IUrlParameter.GetString(IConnectionConfigurationValues settings) + { + if (!(settings is IConnectionSettingsValues nestSettings)) + throw new ArgumentNullException(nameof(settings), + $"Can not resolve {nameof(RelationName)} if no {nameof(IConnectionSettingsValues)} is provided"); + + return nestSettings.Inferrer.RelationName(this); + } + public static RelationName From() => typeof(T); public static RelationName Create(Type type) => GetRelationNameForType(type); @@ -29,13 +42,12 @@ public class RelationName : IEquatable, IUrlParameter public static implicit operator RelationName(Type type) => type == null ? null : new RelationName(type); - private static int TypeHashCode { get; } = typeof(RelationName).GetHashCode(); public override int GetHashCode() { unchecked { var result = TypeHashCode; - result = (result * 397) ^ (this.Name?.GetHashCode() ?? this.Type?.GetHashCode() ?? 0); + result = (result * 397) ^ (Name?.GetHashCode() ?? Type?.GetHashCode() ?? 0); return result; } } @@ -44,35 +56,27 @@ public override int GetHashCode() public static bool operator !=(RelationName left, RelationName right) => !Equals(left, right); - public bool Equals(RelationName other) => EqualsMarker(other); - public override bool Equals(object obj) => - obj is string s ? this.EqualsString(s) : (obj is RelationName r) && this.EqualsMarker(r); + obj is string s ? EqualsString(s) : obj is RelationName r && EqualsMarker(r); public bool EqualsMarker(RelationName other) { - if (!this.Name.IsNullOrEmpty() && other != null && !other.Name.IsNullOrEmpty()) + if (!Name.IsNullOrEmpty() && other != null && !other.Name.IsNullOrEmpty()) return EqualsString(other.Name); - if (this.Type != null && other?.Type != null) - return this.Type == other.Type; + if (Type != null && other?.Type != null) + return Type == other.Type; + return false; } + //already private in master, breaking change to change in 6.x - public bool EqualsString(string other) => !other.IsNullOrEmpty() && other == this.Name; + public bool EqualsString(string other) => !other.IsNullOrEmpty() && other == Name; public override string ToString() { - if (!this.Name.IsNullOrEmpty()) return this.Name; - return this.Type != null ? this.Type.Name : string.Empty; - } + if (!Name.IsNullOrEmpty()) return Name; - string IUrlParameter.GetString(IConnectionConfigurationValues settings) - { - if (!(settings is IConnectionSettingsValues nestSettings)) - throw new ArgumentNullException(nameof(settings), $"Can not resolve {nameof(RelationName)} if no {nameof(IConnectionSettingsValues)} is provided"); - - return nestSettings.Inferrer.RelationName(this); + return Type != null ? Type.Name : string.Empty; } - } } diff --git a/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameExtensions.cs b/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameExtensions.cs index d44ab306484..c5e5b9ed373 100644 --- a/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameExtensions.cs +++ b/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameExtensions.cs @@ -2,9 +2,6 @@ { internal static class RelationNameExtensions { - internal static bool IsConditionless(this RelationName marker) - { - return marker == null || marker.Name.IsNullOrEmpty() && marker.Type == null; - } + internal static bool IsConditionless(this RelationName marker) => marker == null || marker.Name.IsNullOrEmpty() && marker.Type == null; } } diff --git a/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameJsonConverter.cs index eda005474b8..5e77f2a8562 100644 --- a/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameJsonConverter.cs @@ -5,10 +5,7 @@ namespace Nest { internal class RelationNameJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) - { - return typeof(RelationName) == objectType; - } + public override bool CanConvert(Type objectType) => typeof(RelationName) == objectType; public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { @@ -28,8 +25,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { if (reader.TokenType == JsonToken.String) { - string typeName = reader.Value.ToString(); - return (RelationName) typeName; + var typeName = reader.Value.ToString(); + return (RelationName)typeName; } return null; } diff --git a/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameResolver.cs b/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameResolver.cs index a931f0d1330..a9c28e45667 100644 --- a/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameResolver.cs +++ b/src/Nest/CommonAbstractions/Infer/RelationName/RelationNameResolver.cs @@ -11,16 +11,17 @@ public class RelationNameResolver public RelationNameResolver(IConnectionSettingsValues connectionSettings) { connectionSettings.ThrowIfNull(nameof(connectionSettings)); - this._connectionSettings = connectionSettings; + _connectionSettings = connectionSettings; } - public string Resolve() where T : class => this.Resolve(typeof(T)); + public string Resolve() where T : class => Resolve(typeof(T)); - public string Resolve(RelationName t) => t?.Name ?? this.ResolveType(t?.Type); + public string Resolve(RelationName t) => t?.Name ?? ResolveType(t?.Type); private string ResolveType(Type type) { if (type == null) return null; + string typeName; if (RelationNames.TryGetValue(type, out typeName)) @@ -41,6 +42,5 @@ private string ResolveType(Type type) RelationNames.TryAdd(type, typeName); return typeName; } - } } diff --git a/src/Nest/CommonAbstractions/Infer/TaskId/TaskId.cs b/src/Nest/CommonAbstractions/Infer/TaskId/TaskId.cs index 80f52d4f409..2d4bd1e9b20 100644 --- a/src/Nest/CommonAbstractions/Infer/TaskId/TaskId.cs +++ b/src/Nest/CommonAbstractions/Infer/TaskId/TaskId.cs @@ -8,12 +8,6 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class TaskId : IUrlParameter, IEquatable { - public string NodeId { get; } - public long TaskNumber { get; } - public string FullyQualifiedId { get; } - - private string DebugDisplay => FullyQualifiedId; - /// /// A task id exists in the form [node_id]:[task_id] /// @@ -27,37 +21,43 @@ public TaskId(string taskId) if (tokens.Length != 2) throw new ArgumentException($"TaskId:{taskId} not in expected format of :", nameof(taskId)); - this.NodeId = tokens[0]; - this.FullyQualifiedId = taskId; + NodeId = tokens[0]; + FullyQualifiedId = taskId; if (!long.TryParse(tokens[1].Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out var t) || t < -1 || t == 0) throw new ArgumentException($"TaskId task component:{tokens[1]} could not be parsed to long or is out of range", nameof(taskId)); - this.TaskNumber = t; + TaskNumber = t; } - public override string ToString() => FullyQualifiedId; + public string FullyQualifiedId { get; } + public string NodeId { get; } + public long TaskNumber { get; } + + private string DebugDisplay => FullyQualifiedId; + + public bool Equals(TaskId other) => EqualsString(other?.FullyQualifiedId); public string GetString(IConnectionConfigurationValues settings) => FullyQualifiedId; + public override string ToString() => FullyQualifiedId; + public static implicit operator TaskId(string taskId) => taskId.IsNullOrEmpty() ? null : new TaskId(taskId); public static bool operator ==(TaskId left, TaskId right) => Equals(left, right); public static bool operator !=(TaskId left, TaskId right) => !Equals(left, right); - public bool Equals(TaskId other) => EqualsString(other?.FullyQualifiedId); - public override bool Equals(object obj) => - obj != null && obj is string s ? this.EqualsString(s) : (obj is TaskId i) && this.EqualsString(i.FullyQualifiedId); + obj != null && obj is string s ? EqualsString(s) : obj is TaskId i && EqualsString(i.FullyQualifiedId); - private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == this.FullyQualifiedId; + private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == FullyQualifiedId; public override int GetHashCode() { unchecked { - return (NodeId.GetHashCode()*397) ^ TaskNumber.GetHashCode(); + return (NodeId.GetHashCode() * 397) ^ TaskNumber.GetHashCode(); } } } diff --git a/src/Nest/CommonAbstractions/Infer/TypeName/TypeName.cs b/src/Nest/CommonAbstractions/Infer/TypeName/TypeName.cs index 9fec2f045d8..35c92591800 100644 --- a/src/Nest/CommonAbstractions/Infer/TypeName/TypeName.cs +++ b/src/Nest/CommonAbstractions/Infer/TypeName/TypeName.cs @@ -9,16 +9,26 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class TypeName : IEquatable, IUrlParameter { - private static int TypeHashCode { get; } = typeof(TypeName).GetHashCode(); + private TypeName(string type) => Name = type; + + private TypeName(Type type) => Type = type; public string Name { get; } public Type Type { get; } - private TypeName(string type) => this.Name = type; + internal string DebugDisplay => Type == null ? Name : $"{nameof(TypeName)} for typeof: {Type?.Name}"; + private static int TypeHashCode { get; } = typeof(TypeName).GetHashCode(); - private TypeName(Type type) => this.Type = type; + public bool Equals(TypeName other) => EqualsMarker(other); - internal string DebugDisplay => Type == null ? Name : $"{nameof(TypeName)} for typeof: {Type?.Name}"; + string IUrlParameter.GetString(IConnectionConfigurationValues settings) + { + if (!(settings is IConnectionSettingsValues nestSettings)) + throw new ArgumentNullException(nameof(settings), + $"Can not resolve {nameof(TypeName)} if no {nameof(IConnectionSettingsValues)} is provided"); + + return nestSettings.Inferrer.TypeName(this); + } public static TypeName Create(Type type) => GetTypeNameForType(type); @@ -35,57 +45,50 @@ public override int GetHashCode() unchecked { var result = TypeHashCode; - result = (result * 397) ^ (this.Name?.GetHashCode() ?? this.Type?.GetHashCode() ?? 0); + result = (result * 397) ^ (Name?.GetHashCode() ?? Type?.GetHashCode() ?? 0); return result; } } + public static bool operator ==(TypeName left, TypeName right) => Equals(left, right); public static bool operator !=(TypeName left, TypeName right) => !Equals(left, right); - public bool Equals(TypeName other) => EqualsMarker(other); - public override bool Equals(object obj) { var s = obj as string; - if (!s.IsNullOrEmpty()) return this.EqualsString(s); + if (!s.IsNullOrEmpty()) return EqualsString(s); + var pp = obj as TypeName; - return this.EqualsMarker(pp); + return EqualsMarker(pp); } public override string ToString() { - if (!this.Name.IsNullOrEmpty()) - return this.Name; - return this.Type != null ? this.Type.Name : string.Empty; + if (!Name.IsNullOrEmpty()) + return Name; + + return Type != null ? Type.Name : string.Empty; } private bool EqualsMarker(TypeName other) { - if (!this.Name.IsNullOrEmpty() && other != null && !other.Name.IsNullOrEmpty()) + if (!Name.IsNullOrEmpty() && other != null && !other.Name.IsNullOrEmpty()) return EqualsString(other.Name); - if (this.Type != null && other?.Type != null) - return this.Type == other.Type; - return false; - } + if (Type != null && other?.Type != null) + return Type == other.Type; - private bool EqualsString(string other) - { - return !other.IsNullOrEmpty() && other == this.Name; + return false; } - string IUrlParameter.GetString(IConnectionConfigurationValues settings) - { - if (!(settings is IConnectionSettingsValues nestSettings)) - throw new ArgumentNullException(nameof(settings), $"Can not resolve {nameof(TypeName)} if no {nameof(IConnectionSettingsValues)} is provided"); - - return nestSettings.Inferrer.TypeName(this); - } + private bool EqualsString(string other) => !other.IsNullOrEmpty() && other == Name; public static TypeName From() => typeof(T); - public Types And() => new Types(new TypeName[] { this, typeof(T)}); + public Types And() => new Types(new TypeName[] { this, typeof(T) }); + public Types And(TypeName type) => new Types(new TypeName[] { this, type }); + public Types And(TypeName[] types) => new Types(new TypeName[] { this }.Concat(types)); } } diff --git a/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameExtensions.cs b/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameExtensions.cs index b61707ba4e8..8a04c7dbf8c 100644 --- a/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameExtensions.cs +++ b/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameExtensions.cs @@ -2,9 +2,6 @@ { internal static class TypeNameExtensions { - internal static bool IsConditionless(this TypeName marker) - { - return marker == null || marker.Name.IsNullOrEmpty() && marker.Type == null; - } + internal static bool IsConditionless(this TypeName marker) => marker == null || marker.Name.IsNullOrEmpty() && marker.Type == null; } } diff --git a/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameJsonConverter.cs index 7f14d21bc9d..8992a89cb17 100644 --- a/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameJsonConverter.cs @@ -5,10 +5,7 @@ namespace Nest { internal class TypeNameJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) - { - return typeof(TypeName) == objectType; - } + public override bool CanConvert(Type objectType) => typeof(TypeName) == objectType; public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { @@ -28,11 +25,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { if (reader.TokenType == JsonToken.String) { - string typeName = reader.Value.ToString(); - return (TypeName) typeName; + var typeName = reader.Value.ToString(); + return (TypeName)typeName; } return null; } - } } diff --git a/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameResolver.cs b/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameResolver.cs index 6cd13ed68fa..1e0b25a6175 100644 --- a/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameResolver.cs +++ b/src/Nest/CommonAbstractions/Infer/TypeName/TypeNameResolver.cs @@ -13,12 +13,12 @@ public class TypeNameResolver public TypeNameResolver(IConnectionSettingsValues connectionSettings) { connectionSettings.ThrowIfNull(nameof(connectionSettings)); - this._connectionSettings = connectionSettings; + _connectionSettings = connectionSettings; } - public string Resolve() where T : class => this.Resolve(typeof(T)); + public string Resolve() where T : class => Resolve(typeof(T)); - public string Resolve(TypeName t) => t?.Name ?? this.ResolveType(t?.Type); + public string Resolve(TypeName t) => t?.Name ?? ResolveType(t?.Type); private string ResolveType(Type type) { @@ -41,7 +41,7 @@ private string ResolveType(Type type) if (dataContract?.Name != null) typeName = dataContract.Name; else { - var inferredType =_connectionSettings.DefaultTypeNameInferrer(type); + var inferredType = _connectionSettings.DefaultTypeNameInferrer(type); typeName = !inferredType.IsNullOrEmpty() ? inferredType : _connectionSettings.DefaultTypeName; } } diff --git a/src/Nest/CommonAbstractions/Infer/Types/Types.cs b/src/Nest/CommonAbstractions/Infer/Types/Types.cs index b2e4a4ecd25..2d562d60a65 100644 --- a/src/Nest/CommonAbstractions/Infer/Types/Types.cs +++ b/src/Nest/CommonAbstractions/Infer/Types/Types.cs @@ -10,86 +10,78 @@ namespace Nest [DebuggerDisplay("{DebugDisplay,nq}")] public class Types : Union, IUrlParameter, IEquatable { - public class AllTypesMarker { internal AllTypesMarker() { } } + internal Types(AllTypesMarker all) : base(all) { } + + internal Types(ManyTypes types) : base(types) { } + + internal Types(IEnumerable types) : base(new ManyTypes(types)) { } + public static AllTypesMarker All { get; } = new AllTypesMarker(); public static AllTypesMarker AllTypes { get; } = new AllTypesMarker(); - public class ManyTypes + + private string DebugDisplay => Match( + all => "_all", + types => $"Count: {types.Types.Count} [" + string.Join(",", types.Types.Select((t, i) => $"({i + 1}: {t.DebugDisplay})")) + "]" + ); + + public bool Equals(Types other) { - private readonly List _types = new List(); - public IReadOnlyList Types => _types; - internal ManyTypes(IEnumerable types) - { - types.ThrowIfEmpty(nameof(types)); - this._types.AddRange(types); - } + if (other == null) return false; - internal ManyTypes(IEnumerable types) - { - types.ThrowIfEmpty(nameof(types)); - this._types.AddRange(types.Select(s=>(TypeName)s)); - } + return Match( + all => other.Match(a => true, m => false), + many => other.Match( + a => false, + m => EqualsAllTypes(m.Types, many.Types) + ) + ); + } - public ManyTypes And() + string IUrlParameter.GetString(IConnectionConfigurationValues settings) => Match( + all => null, + many => { - this._types.Add(typeof(T)); - return this; - } - } + if (!(settings is IConnectionSettingsValues nestSettings)) + throw new ArgumentNullException(nameof(settings), $"Can not resolve Types if no {nameof(IConnectionSettingsValues)} is provided"); - internal Types(AllTypesMarker all) : base(all) { } - internal Types(ManyTypes types) : base(types) { } - internal Types(IEnumerable types) : base(new ManyTypes(types)) { } + var types = many.Types.Select(t => nestSettings.Inferrer.TypeName(t)).Distinct(); + return string.Join(",", types); + } + ); public static TypeName Type(TypeName type) => type; + public static TypeName Type() => typeof(T); + public static ManyTypes Type(IEnumerable types) => new ManyTypes(types); + public static ManyTypes Type(params TypeName[] types) => new ManyTypes(types); + public static ManyTypes Type(IEnumerable indices) => new ManyTypes(indices); + public static ManyTypes Type(params string[] indices) => new ManyTypes(indices); - public static Types Parse(string typesString) => typesString.IsNullOrEmptyCommaSeparatedList(out var types) ? null : Type(types.Select(i => (TypeName)i)); + public static Types Parse(string typesString) => + typesString.IsNullOrEmptyCommaSeparatedList(out var types) ? null : Type(types.Select(i => (TypeName)i)); public static implicit operator Types(string typesString) => Parse(typesString); + public static implicit operator Types(AllTypesMarker all) => all == null ? null : new Types(all); + public static implicit operator Types(ManyTypes many) => many == null ? null : new Types(many); + public static implicit operator Types(TypeName type) => type == null ? null : new ManyTypes(new[] { type }); - public static implicit operator Types(TypeName[] type) => type.IsEmpty() ? null : new ManyTypes(type); - public static implicit operator Types(string[] many) => many.IsEmpty() ? null : new ManyTypes(many); - public static implicit operator Types(Type type) => type == null ? null : new ManyTypes(new TypeName[] { type }); - private string DebugDisplay => this.Match( - all => "_all", - types => $"Count: {types.Types.Count} [" + string.Join(",", types.Types.Select((t, i) => $"({i+1}: {t.DebugDisplay})")) + "]" - ); + public static implicit operator Types(TypeName[] type) => type.IsEmpty() ? null : new ManyTypes(type); - string IUrlParameter.GetString(IConnectionConfigurationValues settings) => this.Match( - all => null, - many => - { - if (!(settings is IConnectionSettingsValues nestSettings)) - throw new ArgumentNullException(nameof(settings), $"Can not resolve Types if no {nameof(IConnectionSettingsValues)} is provided"); + public static implicit operator Types(string[] many) => many.IsEmpty() ? null : new ManyTypes(many); - var types = many.Types.Select(t => nestSettings.Inferrer.TypeName(t)).Distinct(); - return string.Join(",", types); - } - ); + public static implicit operator Types(Type type) => type == null ? null : new ManyTypes(new TypeName[] { type }); public static bool operator ==(Types left, Types right) => Equals(left, right); public static bool operator !=(Types left, Types right) => !Equals(left, right); - public bool Equals(Types other) - { - if (other == null) return false; - return this.Match( - all => other.Match(a => true, m => false), - many => other.Match( - a => false, - m => EqualsAllTypes(m.Types, many.Types) - ) - ); - } - public override bool Equals(object obj) { Types other = null; @@ -104,15 +96,43 @@ private static bool EqualsAllTypes(IReadOnlyList thisTypes, IReadOnlyL if (thisTypes == null && otherTypes == null) return true; if (thisTypes == null || otherTypes == null) return false; if (thisTypes.Count != otherTypes.Count) return false; + return thisTypes.Count == otherTypes.Count && !thisTypes.Except(otherTypes).Any(); } - public override int GetHashCode() + public override int GetHashCode() => Match( + all => "_all".GetHashCode(), + many => string.Concat(many.Types).GetHashCode() + ); + + public class AllTypesMarker { - return this.Match( - all => "_all".GetHashCode(), - many => string.Concat(many.Types).GetHashCode() - ); + internal AllTypesMarker() { } + } + + public class ManyTypes + { + private readonly List _types = new List(); + + internal ManyTypes(IEnumerable types) + { + types.ThrowIfEmpty(nameof(types)); + _types.AddRange(types); + } + + internal ManyTypes(IEnumerable types) + { + types.ThrowIfEmpty(nameof(types)); + _types.AddRange(types.Select(s => (TypeName)s)); + } + + public IReadOnlyList Types => _types; + + public ManyTypes And() + { + _types.Add(typeof(T)); + return this; + } } } } diff --git a/src/Nest/CommonAbstractions/Infer/Types/TypesJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/Types/TypesJsonConverter.cs index fa8cd203d1b..bf540d07b00 100644 --- a/src/Nest/CommonAbstractions/Infer/Types/TypesJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/Types/TypesJsonConverter.cs @@ -19,12 +19,12 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s return; } marker.Match( - all=> writer.WriteNull(), + all => writer.WriteNull(), many => { var settings = serializer.GetConnectionSettings(); writer.WriteStartArray(); - foreach(var m in many.Types.Cast()) + foreach (var m in many.Types.Cast()) writer.WriteValue(m.GetString(settings)); writer.WriteEndArray(); } @@ -33,8 +33,8 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if (reader.TokenType != JsonToken.StartArray) return null; + var types = new List(); while (reader.TokenType != JsonToken.EndArray) { @@ -44,6 +44,5 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } return new Types(types); } - } } diff --git a/src/Nest/CommonAbstractions/Infer/Types/TypesMultiSyntaxJsonConverter.cs b/src/Nest/CommonAbstractions/Infer/Types/TypesMultiSyntaxJsonConverter.cs index 9667af1330d..b4266e48aad 100644 --- a/src/Nest/CommonAbstractions/Infer/Types/TypesMultiSyntaxJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Infer/Types/TypesMultiSyntaxJsonConverter.cs @@ -17,7 +17,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s return; } marker.Match( - all=> writer.WriteNull(), + all => writer.WriteNull(), many => writer.WriteValue(((IUrlParameter)marker).GetString(serializer.GetConnectionSettings())) ); } @@ -26,11 +26,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { if (reader.TokenType == JsonToken.String) { - string types = reader.Value.ToString(); + var types = reader.Value.ToString(); return (Types)types; } return null; } - } } diff --git a/src/Nest/CommonAbstractions/LazyDocument/LazyDocument.cs b/src/Nest/CommonAbstractions/LazyDocument/LazyDocument.cs index 90809e23d1d..59e503061a3 100644 --- a/src/Nest/CommonAbstractions/LazyDocument/LazyDocument.cs +++ b/src/Nest/CommonAbstractions/LazyDocument/LazyDocument.cs @@ -1,8 +1,5 @@ using System; -using System.IO; -using System.Text; using Elasticsearch.Net; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Nest @@ -14,15 +11,15 @@ namespace Nest public interface ILazyDocument { /// - /// Creates an instance of from this - /// instance + /// Creates an instance of from this + /// instance /// /// The type T As(); /// - /// Creates an instance of from this - /// instance + /// Creates an instance of from this + /// instance /// /// The type object As(Type objectType); @@ -31,8 +28,6 @@ public interface ILazyDocument /// public class LazyDocument : ILazyDocument { - internal JToken Token { get; } - private readonly IElasticsearchSerializer _serializer; internal LazyDocument(JToken token, IElasticsearchSerializer serializer) @@ -41,6 +36,8 @@ internal LazyDocument(JToken token, IElasticsearchSerializer serializer) _serializer = serializer; } + internal JToken Token { get; } + /// public T As() { diff --git a/src/Nest/CommonAbstractions/LazyDocument/LazyDocumentJsonConverter.cs b/src/Nest/CommonAbstractions/LazyDocument/LazyDocumentJsonConverter.cs index 79c30fe2d71..d8d19d6e1c4 100644 --- a/src/Nest/CommonAbstractions/LazyDocument/LazyDocumentJsonConverter.cs +++ b/src/Nest/CommonAbstractions/LazyDocument/LazyDocumentJsonConverter.cs @@ -1,6 +1,5 @@ using System; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace Nest { @@ -27,5 +26,4 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist public override bool CanConvert(Type objectType) => true; } - } diff --git a/src/Nest/CommonAbstractions/LowLevelDispatch/IHighLevelToLowLevelDispatcher.cs b/src/Nest/CommonAbstractions/LowLevelDispatch/IHighLevelToLowLevelDispatcher.cs index d7a851df5c0..2aee3a85a75 100644 --- a/src/Nest/CommonAbstractions/LowLevelDispatch/IHighLevelToLowLevelDispatcher.cs +++ b/src/Nest/CommonAbstractions/LowLevelDispatch/IHighLevelToLowLevelDispatcher.cs @@ -1,8 +1,8 @@ using System; using System.IO; +using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; -using System.Threading; namespace Nest { @@ -20,7 +20,7 @@ TResponse Dispatch( TRequest descriptor, Func responseGenerator, Func, TResponse> dispatch - ) + ) where TQueryString : RequestParameters, new() where TRequest : IRequest where TResponse : ResponseBase; @@ -29,7 +29,7 @@ Task DispatchAsync, CancellationToken, Task> dispatch - ) + ) where TQueryString : RequestParameters, new() where TRequest : IRequest where TResponse : ResponseBase, TResponseInterface diff --git a/src/Nest/CommonAbstractions/LowLevelDispatch/LowLevelDispatch.cs b/src/Nest/CommonAbstractions/LowLevelDispatch/LowLevelDispatch.cs index 785f33c37bf..9b8044799a0 100644 --- a/src/Nest/CommonAbstractions/LowLevelDispatch/LowLevelDispatch.cs +++ b/src/Nest/CommonAbstractions/LowLevelDispatch/LowLevelDispatch.cs @@ -8,12 +8,10 @@ namespace Nest { internal partial class LowLevelDispatch { + private static readonly Regex ReplaceParams = new Regex(@"\{(.+?)\}"); protected IElasticLowLevelClient _lowLevel; - public LowLevelDispatch(IElasticLowLevelClient rawElasticClient) - { - this._lowLevel = rawElasticClient; - } + public LowLevelDispatch(IElasticLowLevelClient rawElasticClient) => _lowLevel = rawElasticClient; internal bool AllSetNoFallback(params string[] pathVariables) => pathVariables.All(p => !p.IsNullOrEmpty()); @@ -26,7 +24,7 @@ internal static Exception InvalidDispatch(string apiCall, IRequest provided, Htt var sb = new StringBuilder(); sb.AppendLine($"Dispatching {apiCall}() from NEST into to Elasticsearch.NET failed"); sb.AppendLine($"Received a request marked as {provided.HttpMethod.GetStringValue()}"); - sb.AppendLine($"This endpoint accepts {string.Join(",", methods.Select(p=>p.GetStringValue()))}"); + sb.AppendLine($"This endpoint accepts {string.Join(",", methods.Select(p => p.GetStringValue()))}"); sb.AppendLine($"The request might not have enough information provided to make any of these endpoints:"); foreach (var endpoint in endpoints) sb.AppendLine($" - {PrettyPrintEndpoint(provided, endpoint)}"); @@ -34,37 +32,34 @@ internal static Exception InvalidDispatch(string apiCall, IRequest provided, Htt return new ArgumentException(sb.ToString()); } - private static readonly Regex ReplaceParams = new Regex(@"\{(.+?)\}"); - internal static string PrettyPrintEndpoint(IRequest request, string endpoint) { var pretty = ReplaceParams.Replace(endpoint, (m) => { var key = m.Groups[1].Value.ToLowerInvariant(); - switch(key) + switch (key) { - case "index" : return PrettyParam(key, request.RouteValues.Index); - case "name" : return PrettyParam(key, request.RouteValues.Name); - case "feature" : return PrettyParam(key, request.RouteValues.Feature); - case "field" : return PrettyParam(key, request.RouteValues.Field); - case "fields" : return PrettyParam(key, request.RouteValues.Fields); - case "id" : return PrettyParam(key, request.RouteValues.Id); - case "index_metric" : return PrettyParam(key, request.RouteValues.IndexMetric); - case "lang" : return PrettyParam(key, request.RouteValues.Lang); - case "metric" : return PrettyParam(key, request.RouteValues.Metric); - case "nodes" : return PrettyParam(key, request.RouteValues.NodeId); - case "node_id" : return PrettyParam(key, request.RouteValues.NodeId); - case "repository" : return PrettyParam(key, request.RouteValues.Repository); - case "scroll_id" : return PrettyParam(key, request.RouteValues.ScrollId); - case "snapshot" : return PrettyParam(key, request.RouteValues.Snapshot); - case "type" : return PrettyParam(key, request.RouteValues.Type); - default: return PrettyParam(key, ""); + case "index": return PrettyParam(key, request.RouteValues.Index); + case "name": return PrettyParam(key, request.RouteValues.Name); + case "feature": return PrettyParam(key, request.RouteValues.Feature); + case "field": return PrettyParam(key, request.RouteValues.Field); + case "fields": return PrettyParam(key, request.RouteValues.Fields); + case "id": return PrettyParam(key, request.RouteValues.Id); + case "index_metric": return PrettyParam(key, request.RouteValues.IndexMetric); + case "lang": return PrettyParam(key, request.RouteValues.Lang); + case "metric": return PrettyParam(key, request.RouteValues.Metric); + case "nodes": return PrettyParam(key, request.RouteValues.NodeId); + case "node_id": return PrettyParam(key, request.RouteValues.NodeId); + case "repository": return PrettyParam(key, request.RouteValues.Repository); + case "scroll_id": return PrettyParam(key, request.RouteValues.ScrollId); + case "snapshot": return PrettyParam(key, request.RouteValues.Snapshot); + case "type": return PrettyParam(key, request.RouteValues.Type); + default: return PrettyParam(key, ""); } }); return pretty; } private static string PrettyParam(string key, string value) => $"{{{key}={(value.IsNullOrEmpty() ? "" : value)}}}"; - } } diff --git a/src/Nest/CommonAbstractions/RawJson/RawJson.cs b/src/Nest/CommonAbstractions/RawJson/RawJson.cs index c968670982c..3cd5c2503de 100644 --- a/src/Nest/CommonAbstractions/RawJson/RawJson.cs +++ b/src/Nest/CommonAbstractions/RawJson/RawJson.cs @@ -5,11 +5,8 @@ /// internal class RawJson { - public string Data { get; set; } + public RawJson(string rawJsonData) => Data = rawJsonData; - public RawJson(string rawJsonData) - { - Data = rawJsonData; - } + public string Data { get; set; } } } diff --git a/src/Nest/CommonAbstractions/Reactive/BlockingSubscribeExtensions.cs b/src/Nest/CommonAbstractions/Reactive/BlockingSubscribeExtensions.cs index 764e363a3ff..72acf9a3647 100644 --- a/src/Nest/CommonAbstractions/Reactive/BlockingSubscribeExtensions.cs +++ b/src/Nest/CommonAbstractions/Reactive/BlockingSubscribeExtensions.cs @@ -10,7 +10,9 @@ public static BulkAllObserver Wait(this BulkAllObservable observable, Time WaitOnObservable, IBulkAllResponse, BulkAllObserver>( observable, maximumRunTime, (e, c) => new BulkAllObserver(onNext, e, c)); - public static ScrollAllObserver Wait(this IObservable> observable, TimeSpan maximumRunTime, Action> onNext) + public static ScrollAllObserver Wait(this IObservable> observable, TimeSpan maximumRunTime, + Action> onNext + ) where T : class => WaitOnObservable>, IScrollAllResponse, ScrollAllObserver>( observable, maximumRunTime, (e, c) => new ScrollAllObserver(onNext, e, c)); @@ -42,7 +44,8 @@ Func, Action, TObserver> factory observable.Subscribe(observer); handle.WaitOne(maximumRunTime); if (ex != null) throw ex; + return observer; } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Reactive/CoordinatedRequestObserverBase.cs b/src/Nest/CommonAbstractions/Reactive/CoordinatedRequestObserverBase.cs index 3ce0c8e00b3..72d303dde4e 100644 --- a/src/Nest/CommonAbstractions/Reactive/CoordinatedRequestObserverBase.cs +++ b/src/Nest/CommonAbstractions/Reactive/CoordinatedRequestObserverBase.cs @@ -4,9 +4,9 @@ namespace Nest { internal static class CoordinatedRequestDefaults { - public static int BulkAllMaxDegreeOfParallelismDefault = 4; - public static TimeSpan BulkAllBackOffTimeDefault = TimeSpan.FromMinutes(1); public static int BulkAllBackOffRetriesDefault = 0; + public static TimeSpan BulkAllBackOffTimeDefault = TimeSpan.FromMinutes(1); + public static int BulkAllMaxDegreeOfParallelismDefault = 4; public static int BulkAllSizeDefault = 1000; public static int ReindexBackPressureFactor = 4; public static int ReindexScrollSize = 500; @@ -14,30 +14,21 @@ internal static class CoordinatedRequestDefaults public abstract class CoordinatedRequestObserverBase : IObserver { - private readonly Action _onNext; - private readonly Action _onError; private readonly Action _completed; + private readonly Action _onError; + private readonly Action _onNext; - protected CoordinatedRequestObserverBase(Action onNext = null, Action onError = null, System.Action completed = null) + protected CoordinatedRequestObserverBase(Action onNext = null, Action onError = null, Action completed = null) { _onNext = onNext; _onError = onError; _completed = completed; } - public void OnNext(T value) - { - this._onNext?.Invoke(value); - } + public void OnCompleted() => _completed?.Invoke(); - public void OnError(Exception error) - { - this._onError?.Invoke(error); - } + public void OnError(Exception error) => _onError?.Invoke(error); - public void OnCompleted() - { - this._completed?.Invoke(); - } + public void OnNext(T value) => _onNext?.Invoke(value); } } diff --git a/src/Nest/CommonAbstractions/Reactive/GetEnumerator.cs b/src/Nest/CommonAbstractions/Reactive/GetEnumerator.cs index d7a08f6e77d..a6b48c1e046 100644 --- a/src/Nest/CommonAbstractions/Reactive/GetEnumerator.cs +++ b/src/Nest/CommonAbstractions/Reactive/GetEnumerator.cs @@ -8,12 +8,11 @@ namespace Nest { internal class GetEnumerator : IEnumerator, IObserver { + private readonly SemaphoreSlim _gate; private readonly ConcurrentQueue _queue; private TSource _current; - private Exception _error; private bool _disposed; - - private readonly SemaphoreSlim _gate; + private Exception _error; private IDisposable _subscription; public GetEnumerator() @@ -22,33 +21,15 @@ public GetEnumerator() _gate = new SemaphoreSlim(0); } - private IEnumerator Run(IObservable source) - { - // - // [OK] Use of unsafe Subscribe: non-pretentious exact mirror with the dual GetEnumerator method. - // - _subscription = source.Subscribe/*Unsafe*/(this); - return this; - } - public IEnumerable ToEnumerable(IObservable source) => - new AnonymousEnumerable(() => this.Run(source)); + public TSource Current => _current; - public virtual void OnNext(TSource value) - { - _queue.Enqueue(value); - _gate.Release(); - } + object IEnumerator.Current => _current; - public void OnError(Exception error) + public void Dispose() { - _error = error; _subscription.Dispose(); - _gate.Release(); - } - public void OnCompleted() - { - _subscription.Dispose(); + _disposed = true; _gate.Release(); } @@ -68,41 +49,48 @@ public bool MoveNext() return false; } - public TSource Current => _current; + public void Reset() => throw new NotSupportedException(); - object IEnumerator.Current => _current; + public void OnCompleted() + { + _subscription.Dispose(); + _gate.Release(); + } - public void Dispose() + public void OnError(Exception error) { + _error = error; _subscription.Dispose(); + _gate.Release(); + } - _disposed = true; + public virtual void OnNext(TSource value) + { + _queue.Enqueue(value); _gate.Release(); } - public void Reset() + private IEnumerator Run(IObservable source) { - throw new NotSupportedException(); + // + // [OK] Use of unsafe Subscribe: non-pretentious exact mirror with the dual GetEnumerator method. + // + _subscription = source.Subscribe /*Unsafe*/(this); + return this; } + public IEnumerable ToEnumerable(IObservable source) => + new AnonymousEnumerable(() => Run(source)); + internal sealed class AnonymousEnumerable : IEnumerable { private readonly Func> _getEnumerator; - public AnonymousEnumerable(Func> getEnumerator) - { - this._getEnumerator = getEnumerator; - } + public AnonymousEnumerable(Func> getEnumerator) => _getEnumerator = getEnumerator; - public IEnumerator GetEnumerator() - { - return _getEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } + public IEnumerator GetEnumerator() => _getEnumerator(); } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Reactive/PartitionHelper.cs b/src/Nest/CommonAbstractions/Reactive/PartitionHelper.cs index 6e3b2c6a5ae..1c9d4299fdd 100644 --- a/src/Nest/CommonAbstractions/Reactive/PartitionHelper.cs +++ b/src/Nest/CommonAbstractions/Reactive/PartitionHelper.cs @@ -16,7 +16,8 @@ internal PartitionHelper(IEnumerable i, int ps) _partitionSize = ps; } - IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + public IEnumerator> GetEnumerator() { using (var enumerator = _items.GetEnumerator()) @@ -32,9 +33,10 @@ private IEnumerable GetNextBatch(IEnumerator enumerator) for (var i = 0; i < _partitionSize; ++i) { yield return enumerator.Current; + _hasMoreItems = enumerator.MoveNext(); if (!_hasMoreItems) yield break; } } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Reactive/ProducerConsumerBackPressure.cs b/src/Nest/CommonAbstractions/Reactive/ProducerConsumerBackPressure.cs index 141835016fb..ddfcd375795 100644 --- a/src/Nest/CommonAbstractions/Reactive/ProducerConsumerBackPressure.cs +++ b/src/Nest/CommonAbstractions/Reactive/ProducerConsumerBackPressure.cs @@ -10,32 +10,35 @@ namespace Nest /// public class ProducerConsumerBackPressure { - private readonly SemaphoreSlim _consumerLimiter; private readonly int _backPressureFactor; + private readonly SemaphoreSlim _consumerLimiter; private readonly int _slots; /// /// Simple back pressure implementation that makes sure the minimum max concurrency between producer and consumer /// is not amplified by the greedier of the two by more then the backPressureFactor /// - /// The maximum amplification back pressure of the greedier part of the producer consumer pipeline, if null defaults to 4 + /// + /// The maximum amplification back pressure of the greedier part of the producer consumer pipeline, if null + /// defaults to 4 + /// /// The minimum maximum concurrency which would be the bottleneck of the producer consumer pipeline internal ProducerConsumerBackPressure(int? backPressureFactor, int maxConcurrency) { - this._backPressureFactor = backPressureFactor.GetValueOrDefault(4); - this._slots = maxConcurrency * this._backPressureFactor; - this._consumerLimiter = new SemaphoreSlim(_slots, _slots); + _backPressureFactor = backPressureFactor.GetValueOrDefault(4); + _slots = maxConcurrency * _backPressureFactor; + _consumerLimiter = new SemaphoreSlim(_slots, _slots); } public Task WaitAsync(CancellationToken token = default(CancellationToken)) => - this._consumerLimiter.WaitAsync(token); + _consumerLimiter.WaitAsync(token); public void Release() { - var minimumRelease = _slots - this._consumerLimiter.CurrentCount; - var release = Math.Min(minimumRelease, this._backPressureFactor); + var minimumRelease = _slots - _consumerLimiter.CurrentCount; + var release = Math.Min(minimumRelease, _backPressureFactor); if (release > 0) - this._consumerLimiter.Release(release); + _consumerLimiter.Release(release); } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Request/RequestBase.cs b/src/Nest/CommonAbstractions/Request/RequestBase.cs index 182f8d21c2d..34610417896 100644 --- a/src/Nest/CommonAbstractions/Request/RequestBase.cs +++ b/src/Nest/CommonAbstractions/Request/RequestBase.cs @@ -33,42 +33,40 @@ public interface IProxyRequest : IRequest public abstract class RequestBase : IRequest where TParameters : IRequestParameters, new() { - [JsonIgnore] - protected IRequest RequestState => this; + protected RequestBase() => Initialize(); - protected RequestBase() - { - Initialize(); - } protected RequestBase(Func pathSelector) { pathSelector(RequestState.RouteValues); Initialize(); } - protected virtual void Initialize() { } - protected virtual HttpMethod HttpMethod => RequestState.RequestParameters.DefaultHttpMethod; [JsonIgnore] - HttpMethod IRequest.HttpMethod => this.HttpMethod; + protected IRequest RequestState => this; [JsonIgnore] - RouteValues IRequest.RouteValues { get; } = new RouteValues(); + HttpMethod IRequest.HttpMethod => HttpMethod; [JsonIgnore] TParameters IRequest.RequestParameters { get; set; } = new TParameters(); + [JsonIgnore] + RouteValues IRequest.RouteValues { get; } = new RouteValues(); + + protected virtual void Initialize() { } + protected TOut Q(string name) => RequestState.RequestParameters.GetQueryStringValue(name); protected void Q(string name, object value) => RequestState.RequestParameters.SetQueryString(name, value); - } public abstract partial class PlainRequestBase : RequestBase where TParameters : IRequestParameters, new() { protected PlainRequestBase() { } + protected PlainRequestBase(Func pathSelector) : base(pathSelector) { } /// @@ -81,31 +79,34 @@ public IRequestConfiguration RequestConfiguration } } - /// - /// Base class for all Request descriptor types - /// + /// + /// Base class for all Request descriptor types + /// public abstract partial class RequestDescriptorBase : RequestBase, IDescriptor where TDescriptor : RequestDescriptorBase, TInterface where TParameters : RequestParameters, new() { private readonly TDescriptor _descriptor; - protected RequestDescriptorBase() { _descriptor = (TDescriptor)this; } - protected RequestDescriptorBase(Func pathSelector) : base(pathSelector) { _descriptor = (TDescriptor)this; } + protected RequestDescriptorBase() => _descriptor = (TDescriptor)this; + + protected RequestDescriptorBase(Func pathSelector) : base(pathSelector) => _descriptor = (TDescriptor)this; - protected TInterface Self => _descriptor; protected IRequestConfiguration RequestConfig => ((IRequestParameters)RequestState.RequestParameters).RequestConfiguration; + protected TInterface Self => _descriptor; + protected TDescriptor Assign(Action assign) => Fluent.Assign(_descriptor, assign); protected TDescriptor AssignParam(Action assigner) { - assigner?.Invoke(this.RequestState.RequestParameters); + assigner?.Invoke(RequestState.RequestParameters); return _descriptor; } + protected TDescriptor Qs(Action assigner) { - assigner?.Invoke(this.RequestState.RequestParameters); + assigner?.Invoke(RequestState.RequestParameters); return _descriptor; } @@ -126,21 +127,21 @@ public TDescriptor RequestConfiguration(Func - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => base.Equals(obj); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => base.GetHashCode(); /// - /// Hides the method. + /// Hides the method. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Nest/CommonAbstractions/Request/RouteValues.cs b/src/Nest/CommonAbstractions/Request/RouteValues.cs index e77660c988b..93821e94cbd 100644 --- a/src/Nest/CommonAbstractions/Request/RouteValues.cs +++ b/src/Nest/CommonAbstractions/Request/RouteValues.cs @@ -1,59 +1,58 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Elasticsearch.Net; namespace Nest { public class RouteValues { - private readonly Dictionary _routeValues = new Dictionary(); private readonly Dictionary _resolved = new Dictionary(); + private readonly Dictionary _routeValues = new Dictionary(); + public string ActionId => GetResolved("action_id"); + public string Alias => GetResolved("alias"); + public string CategoryId => GetResolved("category_id"); + public string Context => GetResolved("context"); + public string DatafeedId => GetResolved("datafeed_id"); + public string Feature => GetResolved("feature"); + public string Field => GetResolved("field"); + public string Fields => GetResolved("fields"); + public string FilterId => GetResolved("filter_id"); + public string Id => GetResolved("id"); public string Index => GetResolved("index"); - public string Type => GetResolved("type"); - public string Id => GetResolved("id"); + public string IndexMetric => GetResolved("index_metric"); + public string JobId => GetResolved("job_id"); + public string Lang => GetResolved("lang"); + public string Metric => GetResolved("metric"); public string Name => GetResolved("name"); - public string Field => GetResolved("field"); - public string ScrollId => GetResolved("scroll_id"); + public string NewIndex => GetResolved("new_index"); public string NodeId => GetResolved("node_id"); - public string Fields => GetResolved("fields"); + public string Realms => GetResolved("realms"); public string Repository => GetResolved("repository"); + public string ScrollId => GetResolved("scroll_id"); public string Snapshot => GetResolved("snapshot"); - public string Feature => GetResolved("feature"); - public string Metric => GetResolved("metric"); - public string IndexMetric => GetResolved("index_metric"); - public string Lang => GetResolved("lang"); - public string TaskId => GetResolved("task_id"); - public string Realms => GetResolved("realms"); - public string Username => GetResolved("username"); + public string SnapshotId => GetResolved("snapshot_id"); public string Target => GetResolved("target"); - public string NewIndex => GetResolved("new_index"); - public string Alias => GetResolved("alias"); - public string WatchId => GetResolved("watch_id"); + public string TaskId => GetResolved("task_id"); public string ThreadPoolPatterns => GetResolved("thread_pool_patterns"); - public string ActionId => GetResolved("action_id"); - public string JobId => GetResolved("job_id"); - public string DatafeedId => GetResolved("datafeed_id"); - public string FilterId => GetResolved("filter_id"); - public string SnapshotId => GetResolved("snapshot_id"); - public string CategoryId => GetResolved("category_id"); public string Timestamp => GetResolved("timestamp"); - public string Context => GetResolved("context"); + public string Type => GetResolved("type"); + public string Username => GetResolved("username"); public WatcherStatsMetric? WatcherStatsMetric => GetResolved("watcher_stats_metric").ToEnum(); + public string WatchId => GetResolved("watch_id"); - private string GetResolved(string route) => this._resolved.TryGetValue(route, out var resolved) ? resolved : null; + private string GetResolved(string route) => _resolved.TryGetValue(route, out var resolved) ? resolved : null; private RouteValues Route(string name, IUrlParameter routeValue, bool required = true) { if (routeValue == null && !required) { - if (this._routeValues.ContainsKey(name)) - this._routeValues.Remove(name); + if (_routeValues.ContainsKey(name)) + _routeValues.Remove(name); return this; } if (routeValue == null) return this; - this._routeValues[name] = routeValue; + _routeValues[name] = routeValue; return this; } @@ -62,25 +61,27 @@ public void Resolve(IConnectionSettingsValues settings) foreach (var kv in _routeValues) { var key = kv.Value.GetString(settings); - this._resolved[kv.Key] = key.IsNullOrEmpty() ? key : key; + _resolved[kv.Key] = key.IsNullOrEmpty() ? key : key; } } internal RouteValues Required(string route, IUrlParameter value) => Route(route, value); + internal RouteValues Optional(string route, IUrlParameter value) => Route(route, value, false); internal TActual Get(string route) where TActual : class, IUrlParameter { IUrlParameter actual; - if (this._routeValues.TryGetValue(route, out actual) && actual != null) + if (_routeValues.TryGetValue(route, out actual) && actual != null) return (TActual)actual; + return null; } public void Remove(string route) { - this._resolved.Remove(route); - this._routeValues.Remove(route); + _resolved.Remove(route); + _routeValues.Remove(route); } } } diff --git a/src/Nest/CommonAbstractions/Response/DictionaryResponseBase.cs b/src/Nest/CommonAbstractions/Response/DictionaryResponseBase.cs index b8af6a47120..65b020264cc 100644 --- a/src/Nest/CommonAbstractions/Response/DictionaryResponseBase.cs +++ b/src/Nest/CommonAbstractions/Response/DictionaryResponseBase.cs @@ -29,10 +29,10 @@ public static JObject ReadServerErrorFirst(JsonReader reader, out Error error, o if (errorProperty?.Value?.Type == JTokenType.String) { var reason = errorProperty.Value.Value(); - error = new Error {Reason = reason}; + error = new Error { Reason = reason }; errorProperty.Remove(); } - else if (errorProperty?.Value?.Type == JTokenType.Object && ((JObject) errorProperty.Value)["reason"] != null) + else if (errorProperty?.Value?.Type == JTokenType.Object && ((JObject)errorProperty.Value)["reason"] != null) { error = errorProperty.Value.ToObject(); errorProperty.Remove(); @@ -51,10 +51,11 @@ public static JObject ReadServerErrorFirst(JsonReader reader, out Error error, o internal class DictionaryResponseJsonConverter : JsonConverter where TResponse : ResponseBase, IDictionaryResponse, new() { - public override bool CanConvert(Type objectType) => true; public override bool CanRead => true; public override bool CanWrite => false; + public override bool CanConvert(Type objectType) => true; + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var j = DictionaryResponseJsonConverterHelpers.ReadServerErrorFirst(reader, out var error, out var statusCode); @@ -68,6 +69,5 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { } - } } diff --git a/src/Nest/CommonAbstractions/Response/ElasticsearchVersionInfo.cs b/src/Nest/CommonAbstractions/Response/ElasticsearchVersionInfo.cs index 97bd7578018..c1d5bd4d802 100644 --- a/src/Nest/CommonAbstractions/Response/ElasticsearchVersionInfo.cs +++ b/src/Nest/CommonAbstractions/Response/ElasticsearchVersionInfo.cs @@ -2,15 +2,14 @@ namespace Nest { - public class ElasticsearchVersionInfo { - public string Number { get; set; } - [JsonProperty("snapshot_build")] public bool IsSnapShotBuild { get; set; } [JsonProperty("lucene_version")] public string LuceneVersion { get; set; } + + public string Number { get; set; } } } diff --git a/src/Nest/CommonAbstractions/Response/ResolvableDictionaryProxy.cs b/src/Nest/CommonAbstractions/Response/ResolvableDictionaryProxy.cs index 0dff88b0263..7e1c0dadc9c 100644 --- a/src/Nest/CommonAbstractions/Response/ResolvableDictionaryProxy.cs +++ b/src/Nest/CommonAbstractions/Response/ResolvableDictionaryProxy.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Elasticsearch.Net; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace Nest { @@ -11,54 +10,55 @@ public class ResolvableDictionaryProxy : IIsAReadOnlyDictionary Original { get; } = EmptyReadOnly.Dictionary; - protected internal IReadOnlyDictionary BackingDictionary { get; } = EmptyReadOnly.Dictionary; internal ResolvableDictionaryProxy(IConnectionConfigurationValues connectionSettings, IReadOnlyDictionary backingDictionary) { - this._connectionSettings = connectionSettings; + _connectionSettings = connectionSettings; if (backingDictionary == null) return; - this.Original = backingDictionary; + Original = backingDictionary; var dictionary = new Dictionary(); foreach (var key in backingDictionary.Keys) dictionary[Sanitize(key)] = backingDictionary[key]; - this.BackingDictionary = dictionary; + BackingDictionary = dictionary; } - private string Sanitize(TKey key) => key?.GetString(_connectionSettings); + public int Count => BackingDictionary.Count; - IEnumerator> IEnumerable>.GetEnumerator() => - this.Original.GetEnumerator(); + public TValue this[TKey key] => BackingDictionary.TryGetValue(Sanitize(key), out var v) ? v : default(TValue); + public TValue this[string key] => BackingDictionary.TryGetValue(key, out var v) ? v : default(TValue); - IEnumerator IEnumerable.GetEnumerator() => this.Original.GetEnumerator(); + public IEnumerable Keys => Original.Keys; + public IEnumerable ResolvedKeys => BackingDictionary.Keys; - public int Count => this.BackingDictionary.Count; + public IEnumerable Values => BackingDictionary.Values; + protected internal IReadOnlyDictionary BackingDictionary { get; } = EmptyReadOnly.Dictionary; + private IReadOnlyDictionary Original { get; } = EmptyReadOnly.Dictionary; - public bool ContainsKey(TKey key) => this.BackingDictionary.ContainsKey(Sanitize(key)); + IEnumerator IEnumerable.GetEnumerator() => Original.GetEnumerator(); - public bool TryGetValue(TKey key, out TValue value) => - this.BackingDictionary.TryGetValue(Sanitize(key), out value); + IEnumerator> IEnumerable>.GetEnumerator() => + Original.GetEnumerator(); - public TValue this[TKey key] => this.BackingDictionary.TryGetValue(Sanitize(key), out var v) ? v : default(TValue); - public TValue this[string key] => this.BackingDictionary.TryGetValue(key, out var v) ? v : default(TValue); + public bool ContainsKey(TKey key) => BackingDictionary.ContainsKey(Sanitize(key)); - public IEnumerable Keys => this.Original.Keys; - public IEnumerable ResolvedKeys => this.BackingDictionary.Keys; + public bool TryGetValue(TKey key, out TValue value) => + BackingDictionary.TryGetValue(Sanitize(key), out value); - public IEnumerable Values => this.BackingDictionary.Values; + private string Sanitize(TKey key) => key?.GetString(_connectionSettings); } internal abstract class ResolvableDictionaryJsonConverterBase : JsonConverter where TDictionary : ResolvableDictionaryProxy where TKey : IUrlParameter { - public override bool CanConvert(Type objectType) => true; public override bool CanRead => true; public override bool CanWrite => false; + public override bool CanConvert(Type objectType) => true; + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) @@ -71,11 +71,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } protected abstract TDictionary Create(IConnectionSettingsValues settings, Dictionary dictionary); - } internal class ResolvableDictionaryJsonConverter - : ResolvableDictionaryJsonConverterBase,TKey, TValue> + : ResolvableDictionaryJsonConverterBase, TKey, TValue> where TKey : IUrlParameter { protected override ResolvableDictionaryProxy Create(IConnectionSettingsValues s, Dictionary d) => @@ -83,12 +82,13 @@ protected override ResolvableDictionaryProxy Create(IConnectionSet } internal class ResolvableDictionaryResponseJsonConverter : JsonConverter - where TResponse : ResponseBase, IDictionaryResponse , new() where TKey : IUrlParameter + where TResponse : ResponseBase, IDictionaryResponse, new() where TKey : IUrlParameter { - public override bool CanConvert(Type objectType) => true; public override bool CanRead => true; public override bool CanWrite => false; + public override bool CanConvert(Type objectType) => true; + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var j = DictionaryResponseJsonConverterHelpers.ReadServerErrorFirst(reader, out var error, out var statusCode); diff --git a/src/Nest/CommonAbstractions/Response/ResponseBase.cs b/src/Nest/CommonAbstractions/Response/ResponseBase.cs index 115c2f62b48..ce8bd6a588a 100644 --- a/src/Nest/CommonAbstractions/Response/ResponseBase.cs +++ b/src/Nest/CommonAbstractions/Response/ResponseBase.cs @@ -1,6 +1,4 @@ using System; -using System.Diagnostics; -using System.Linq; using System.Text; using Elasticsearch.Net; using Newtonsoft.Json; @@ -13,60 +11,92 @@ namespace Nest public interface IResponse : IElasticsearchResponse { /// - /// This property can be used to check if a response is functionally valid or not. - /// This is a NEST abstraction to have a single point to check whether something wrong happened with the request. - /// For instance an elasticsearch bulk response always returns 200 and individual bulk items may fail, will be false in that case - /// You can also configure the client to always throw an using if the response is not valid + /// A lazy human readable string representation of what happened during this request for both successful and + /// failed requests, very useful while developing or to log when is false on responses. /// [JsonIgnore] - bool IsValid { get; } + string DebugInformation { get; } /// - /// If the response results in an error on elasticsearch's side an
error
element will be returned, this is mapped to in NEST. - /// Possibly set when is false, depending on the cause of the error - /// You can also configure the client to always throw an using if the response is not valid + /// This property can be used to check if a response is functionally valid or not. + /// This is a NEST abstraction to have a single point to check whether something wrong happened with the request. + /// + /// For instance an elasticsearch bulk response always returns 200 and individual bulk items may fail, will be + /// false in that case + /// + /// + /// You can also configure the client to always throw an using + /// if the response is not valid + /// ///
[JsonIgnore] - ServerError ServerError { get; } + bool IsValid { get; } /// /// If the request resulted in an exception on the client side this will hold the exception that was thrown. - /// This property is a shortcut to 's and is possibly set when is false depending on the cause of the error - /// You can also configure the client to always throw an using if the response is not valid + /// + /// This property is a shortcut to 's and + /// is possibly set when is false depending on the cause of the error + /// + /// + /// You can also configure the client to always throw an using + /// if the response is not valid + /// /// [JsonIgnore] Exception OriginalException { get; } - /// - /// A lazy human readable string representation of what happened during this request for both successful and - /// failed requests, very useful while developing or to log when is false on responses. - /// - [JsonIgnore] - string DebugInformation { get; } + /// + /// If the response results in an error on elasticsearch's side an
error
element will be returned, this is mapped to + /// in NEST. + /// Possibly set when is false, depending on the cause of the error + /// + /// You can also configure the client to always throw an using + /// if the response is not valid + /// + ///
+ [JsonIgnore] + ServerError ServerError { get; } } public abstract class ResponseBase : IResponse { + private Error _error; private IApiCallDetails _originalApiCall; private ServerError _serverError; - private Error _error; private int? _statusCode; - [JsonIgnore] - IApiCallDetails IElasticsearchResponse.ApiCall { get => _originalApiCall; set => _originalApiCall = value; } + /// Returns useful information about the request(s) that were part of this API call. + public virtual IApiCallDetails ApiCall => _originalApiCall; - bool IElasticsearchResponse.TryGetServerErrorReason(out string reason) + /// + public string DebugInformation { - reason = this.ServerError?.Error?.ToString(); - return !reason.IsNullOrEmpty(); + get + { + var sb = new StringBuilder(); + sb.Append($"{(!IsValid ? "Inv" : "V")}alid NEST response built from a "); + sb.AppendLine(ApiCall?.ToString().ToCamelCase() ?? "null ApiCall which is highly exceptional, please open a bug if you see this"); + if (!IsValid) DebugIsValid(sb); + if (ApiCall != null) ResponseStatics.DebugInformationBuilder(ApiCall, sb); + return sb.ToString(); + } } + /// + public virtual bool IsValid => (ApiCall?.Success ?? false) && ServerError == null; + + + /// + public Exception OriginalException => ApiCall?.OriginalException; + public ServerError ServerError { get { if (_serverError != null) return _serverError; if (_error == null) return null; + _serverError = new ServerError(_error, _statusCode); return _serverError; } @@ -94,32 +124,22 @@ internal int? StatusCode } } - /// - public virtual bool IsValid => (this.ApiCall?.Success ?? false) && (this.ServerError == null); - - /// Returns useful information about the request(s) that were part of this API call. - public virtual IApiCallDetails ApiCall => _originalApiCall; - - - /// - public Exception OriginalException => this.ApiCall?.OriginalException; + [JsonIgnore] + IApiCallDetails IElasticsearchResponse.ApiCall + { + get => _originalApiCall; + set => _originalApiCall = value; + } - /// - public string DebugInformation + bool IElasticsearchResponse.TryGetServerErrorReason(out string reason) { - get - { - var sb = new StringBuilder(); - sb.Append($"{(!this.IsValid ? "Inv" : "V")}alid NEST response built from a "); - sb.AppendLine(this.ApiCall?.ToString().ToCamelCase() ?? "null ApiCall which is highly exceptional, please open a bug if you see this"); - if (!this.IsValid) this.DebugIsValid(sb); - if (this.ApiCall != null) ResponseStatics.DebugInformationBuilder(ApiCall, sb); - return sb.ToString(); - } + reason = ServerError?.Error?.ToString(); + return !reason.IsNullOrEmpty(); } + /// Subclasses can override this to provide more information on why a call is not valid. protected virtual void DebugIsValid(StringBuilder sb) { } - public override string ToString() => $"{(!this.IsValid ? "Inv" : "V")}alid NEST response built from a {this.ApiCall?.ToString().ToCamelCase()}"; + public override string ToString() => $"{(!IsValid ? "Inv" : "V")}alid NEST response built from a {ApiCall?.ToString().ToCamelCase()}"; } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/IgnoreAttribute.cs b/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/IgnoreAttribute.cs index 1c2059e0e69..24d2cb09215 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/IgnoreAttribute.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/IgnoreAttribute.cs @@ -4,4 +4,4 @@ namespace Nest { [AttributeUsage(AttributeTargets.Property)] public class IgnoreAttribute : Attribute { } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/PropertyNameAttribute.cs b/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/PropertyNameAttribute.cs index ef28549ee45..cf38fa2c110 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/PropertyNameAttribute.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/PropertyNameAttribute.cs @@ -5,7 +5,8 @@ namespace Nest [AttributeUsage(AttributeTargets.Property)] public class PropertyNameAttribute : Attribute { - public string Name { get; set; } public PropertyNameAttribute(string name) => Name = name; + + public string Name { get; set; } } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/StringTimeSpanAttribute.cs b/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/StringTimeSpanAttribute.cs index b3b6c9f6ac5..2ffcf994020 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/StringTimeSpanAttribute.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/Attributes/StringTimeSpanAttribute.cs @@ -4,4 +4,4 @@ namespace Nest { [AttributeUsage(AttributeTargets.Property)] public class StringTimeSpanAttribute : Attribute { } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/ContractJsonConverterAttribute.cs b/src/Nest/CommonAbstractions/SerializationBehavior/ContractJsonConverterAttribute.cs index 905158e50fe..4d5c98e28f9 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/ContractJsonConverterAttribute.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/ContractJsonConverterAttribute.cs @@ -3,29 +3,23 @@ namespace Nest { - internal class ContractJsonConverterAttribute : Attribute { - public JsonConverter Converter { get; } - public ContractJsonConverterAttribute(Type jsonConverter) { - if (typeof(JsonConverter).IsAssignableFrom(jsonConverter)) - { - Converter = jsonConverter.CreateInstance(); - } + if (typeof(JsonConverter).IsAssignableFrom(jsonConverter)) Converter = jsonConverter.CreateInstance(); } + + public JsonConverter Converter { get; } } + internal class ExactContractJsonConverterAttribute : Attribute { - public JsonConverter Converter { get; } - public ExactContractJsonConverterAttribute(Type jsonConverter) { - if (typeof(JsonConverter).IsAssignableFrom(jsonConverter)) - { - Converter = jsonConverter.CreateInstance(); - } + if (typeof(JsonConverter).IsAssignableFrom(jsonConverter)) Converter = jsonConverter.CreateInstance(); } + + public JsonConverter Converter { get; } } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/ElasticContractResolver.cs b/src/Nest/CommonAbstractions/SerializationBehavior/ElasticContractResolver.cs index 3e490d7d473..9d4c99e2b8b 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/ElasticContractResolver.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/ElasticContractResolver.cs @@ -13,15 +13,29 @@ namespace Nest { internal class ElasticContractResolver : DefaultContractResolver { + private static readonly Type _readAsType = typeof(ReadAsTypeJsonConverter<>); + private static readonly MachineLearningDateTimeConverter MachineLearningDateTimeConverter = new MachineLearningDateTimeConverter(); + + private static readonly StringEnumConverter StringEnumConverter = new StringEnumConverter(); + private static readonly Type[] StringSignalTypes = { typeof(KeywordAttribute), typeof(TextAttribute) }; + private static readonly StringTimeSpanConverter StringTimeSpanConverter = new StringTimeSpanConverter(); + + private static readonly Assembly ThisAssembly = typeof(ElasticContractResolver).Assembly(); private readonly Lazy _usingSourceSerializer; - public static JsonSerializer Empty { get; } = new JsonSerializer(); + public ElasticContractResolver(IConnectionSettingsValues connectionSettings) + { + ConnectionSettings = connectionSettings; + _usingSourceSerializer = new Lazy(() => connectionSettings.RequestResponseSerializer != connectionSettings.SourceSerializer); + } /// /// ConnectionSettings can be requested by JsonConverters. /// public IConnectionSettingsValues ConnectionSettings { get; } + public static JsonSerializer Empty { get; } = new JsonSerializer(); + public bool UsingSourceSerializer => _usingSourceSerializer.Value; /// @@ -29,60 +43,50 @@ internal class ElasticContractResolver : DefaultContractResolver /// internal JsonConverterPiggyBackState PiggyBackState { get; set; } - public ElasticContractResolver(IConnectionSettingsValues connectionSettings) - { - this.ConnectionSettings = connectionSettings; - _usingSourceSerializer = new Lazy(() => connectionSettings.RequestResponseSerializer != connectionSettings.SourceSerializer); - } - protected bool CanRemoveSourceConverter(JsonConverter converter) { if (UsingSourceSerializer || converter == null) return false; + return converter is SourceConverter; } - protected override JsonContract CreateContract(Type objectType) + protected override JsonContract CreateContract(Type objectType) => ConnectionSettings.Inferrer.Contracts.GetOrAdd(objectType, o => { - // cache contracts per connection settings - return this.ConnectionSettings.Inferrer.Contracts.GetOrAdd(objectType, o => - { - var contract = base.CreateContract(o); + var contract = base.CreateContract(o); - if (o == typeof(Error)) contract.Converter = new ErrorJsonConverter(); - else if (o == typeof(ErrorCause)) contract.Converter = new ErrorCauseJsonConverter(); - else if (CanRemoveSourceConverter(contract.Converter)) contract.Converter = null; //rely on defaults - else if (o.IsGeneric() && o.GetGenericTypeDefinition() == typeof(SuggestDictionary<>)) - contract.Converter = - (JsonConverter)typeof(SuggestDictionaryConverter<>).CreateGenericInstance(o.GetGenericArguments()); + if (o == typeof(Error)) contract.Converter = new ErrorJsonConverter(); + else if (o == typeof(ErrorCause)) contract.Converter = new ErrorCauseJsonConverter(); + else if (CanRemoveSourceConverter(contract.Converter)) contract.Converter = null; //rely on defaults + else if (o.IsGeneric() && o.GetGenericTypeDefinition() == typeof(SuggestDictionary<>)) + contract.Converter = + (JsonConverter)typeof(SuggestDictionaryConverter<>).CreateGenericInstance(o.GetGenericArguments()); - else if (contract.Converter == null && - (typeof(IDictionary).IsAssignableFrom(o) || o.IsGenericDictionary()) && !typeof(IIsADictionary).IsAssignableFrom(o)) - { - if (!o.TryGetGenericDictionaryArguments(out var genericArguments)) - contract.Converter = new VerbatimDictionaryKeysJsonConverter(); - else - contract.Converter = - (JsonConverter)typeof(VerbatimDictionaryKeysJsonConverter<,>).CreateGenericInstance(genericArguments); - } + else if (contract.Converter == null && + (typeof(IDictionary).IsAssignableFrom(o) || o.IsGenericDictionary()) && !typeof(IIsADictionary).IsAssignableFrom(o)) + { + if (!o.TryGetGenericDictionaryArguments(out var genericArguments)) + contract.Converter = new VerbatimDictionaryKeysJsonConverter(); + else + contract.Converter = + (JsonConverter)typeof(VerbatimDictionaryKeysJsonConverter<,>).CreateGenericInstance(genericArguments); + } - else if (o == typeof(DateTime) || o == typeof(DateTime?)) - contract.Converter = new IsoDateTimeConverter { Culture = CultureInfo.InvariantCulture }; - else if (o == typeof(TimeSpan) || o == typeof(TimeSpan?)) - contract.Converter = new TimeSpanToStringConverter(); - else if (typeof(IEnumerable).IsAssignableFrom(o)) - contract.Converter = new QueryContainerCollectionJsonConverter(); + else if (o == typeof(DateTime) || o == typeof(DateTime?)) + contract.Converter = new IsoDateTimeConverter { Culture = CultureInfo.InvariantCulture }; + else if (o == typeof(TimeSpan) || o == typeof(TimeSpan?)) + contract.Converter = new TimeSpanToStringConverter(); + else if (typeof(IEnumerable).IsAssignableFrom(o)) + contract.Converter = new QueryContainerCollectionJsonConverter(); - ApplyBuildInSerializersForType(o, contract); + ApplyBuildInSerializersForType(o, contract); - if (!o.FullName.StartsWith("Nest.", StringComparison.OrdinalIgnoreCase)) return contract; - if (ApplyExactContractJsonAttribute(o, contract)) return contract; - if (ApplyContractJsonAttribute(o, contract)) return contract; + if (!o.FullName.StartsWith("Nest.", StringComparison.OrdinalIgnoreCase)) return contract; + if (ApplyExactContractJsonAttribute(o, contract)) return contract; + if (ApplyContractJsonAttribute(o, contract)) return contract; - return contract; - }); - } + return contract; + }); - private static Type _readAsType = typeof(ReadAsTypeJsonConverter<>); protected override JsonConverter ResolveContractConverter(Type objectType) { var info = objectType.GetTypeInfo(); @@ -93,20 +97,22 @@ protected override JsonConverter ResolveContractConverter(Type objectType) var readAsType = attribute.Type; var readAsTypeInfo = readAsType.GetTypeInfo(); if (!readAsTypeInfo.IsGenericType || !readAsTypeInfo.IsGenericTypeDefinition) - return (JsonConverter) _readAsType.CreateGenericInstance(objectType); + return (JsonConverter)_readAsType.CreateGenericInstance(objectType); var targetType = objectType; if (info.IsGenericType) targetType = targetType.GetGenericArguments().First(); var concreteType = readAsType.MakeGenericType(targetType); - return (JsonConverter) _readAsType.CreateGenericInstance(concreteType); - + return (JsonConverter)_readAsType.CreateGenericInstance(concreteType); } private static bool ApplyExactContractJsonAttribute(Type objectType, JsonContract contract) { - var attribute = (ExactContractJsonConverterAttribute)objectType.GetTypeInfo().GetCustomAttributes(typeof(ExactContractJsonConverterAttribute)).FirstOrDefault(); + var attribute = (ExactContractJsonConverterAttribute)objectType.GetTypeInfo() + .GetCustomAttributes(typeof(ExactContractJsonConverterAttribute)) + .FirstOrDefault(); if (attribute?.Converter == null) return false; + contract.Converter = attribute.Converter; return true; } @@ -115,8 +121,12 @@ private static bool ApplyContractJsonAttribute(Type objectType, JsonContract con { foreach (var t in TypeWithInterfaces(objectType)) { - var attribute = (ContractJsonConverterAttribute)t.GetTypeInfo().GetCustomAttributes(typeof(ContractJsonConverterAttribute), true).FirstOrDefault(); + var attribute = + (ContractJsonConverterAttribute)t.GetTypeInfo() + .GetCustomAttributes(typeof(ContractJsonConverterAttribute), true) + .FirstOrDefault(); if (attribute?.Converter == null) continue; + contract.Converter = attribute.Converter; return true; } @@ -126,11 +136,10 @@ private static bool ApplyContractJsonAttribute(Type objectType, JsonContract con private static IEnumerable TypeWithInterfaces(Type objectType) { yield return objectType; + foreach (var i in objectType.GetInterfaces()) yield return i; } - private static readonly Assembly ThisAssembly = typeof(ElasticContractResolver).Assembly(); - protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) { var property = base.CreateProperty(member, memberSerialization); @@ -165,41 +174,32 @@ protected override IList CreateProperties(Type type, MemberSeriali return base.CreateProperties(type, memberSerialization); } - public IList PropertiesOfAllInterfaces(Type t, MemberSerialization memberSerialization) - { - return ( + public IList PropertiesOfAllInterfaces(Type t, MemberSerialization memberSerialization) => ( from i in t.GetInterfaces() select base.CreateProperties(i, memberSerialization) - ) - .SelectMany(interfaceProps => interfaceProps) - .DistinctBy(p => p.PropertyName) - .ToList(); - } + ) + .SelectMany(interfaceProps => interfaceProps) + .DistinctBy(p => p.PropertyName) + .ToList(); public IList PropertiesOfInterface(Type t, MemberSerialization memberSerialization) - where TInterface : class - { - return ( + where TInterface : class => ( from i in t.GetInterfaces().Where(i => typeof(TInterface).IsAssignableFrom(i)) select base.CreateProperties(i, memberSerialization) - ) - .SelectMany(interfaceProps => interfaceProps) - .DistinctBy(p => p.PropertyName) - .ToList(); - } + ) + .SelectMany(interfaceProps => interfaceProps) + .DistinctBy(p => p.PropertyName) + .ToList(); - public IList PropertiesOfAll(Type t, MemberSerialization memberSerialization) - { - return base.CreateProperties(t, memberSerialization) - .Concat(PropertiesOfAllInterfaces(t, memberSerialization)) - .DistinctBy(p => p.PropertyName) - .ToList(); - } + public IList PropertiesOfAll(Type t, MemberSerialization memberSerialization) => base.CreateProperties(t, memberSerialization) + .Concat(PropertiesOfAllInterfaces(t, memberSerialization)) + .DistinctBy(p => p.PropertyName) + .ToList(); protected override string ResolvePropertyName(string fieldName) { - if (this.ConnectionSettings.DefaultFieldNameInferrer != null) - return this.ConnectionSettings.DefaultFieldNameInferrer(fieldName); + if (ConnectionSettings.DefaultFieldNameInferrer != null) + return ConnectionSettings.DefaultFieldNameInferrer(fieldName); return fieldName.ToCamelCase(); } @@ -208,42 +208,43 @@ protected static bool ShouldSerializeQueryContainer(object o, JsonProperty prop) { if (o == null) return false; if (!(prop.ValueProvider.GetValue(o) is QueryContainer q)) return false; + return q.IsWritable; } protected static bool ShouldSerializeQueryContainers(object o, JsonProperty prop) { if (o == null) return false; + var q = prop.ValueProvider.GetValue(o) as IEnumerable; - return (q.AsInstanceOrToListOrNull()?.Any(qq=>qq != null && qq.IsWritable)).GetValueOrDefault(false); + return (q.AsInstanceOrToListOrNull()?.Any(qq => qq != null && qq.IsWritable)).GetValueOrDefault(false); } + protected bool ShouldSerializeRouting(object o, JsonProperty prop) { if (o == null) return false; + var q = prop.ValueProvider.GetValue(o) as Routing; if (q == null) return false; + //not ideal to resolve twice but for now the only way not to send routing: null - var resolved = this.ConnectionSettings.Inferrer.Resolve(q); + var resolved = ConnectionSettings.Inferrer.Resolve(q); return !resolved.IsNullOrEmpty(); } - private static readonly StringEnumConverter StringEnumConverter = new StringEnumConverter(); - private static readonly StringTimeSpanConverter StringTimeSpanConverter = new StringTimeSpanConverter(); - private static readonly MachineLearningDateTimeConverter MachineLearningDateTimeConverter = new MachineLearningDateTimeConverter(); - private static readonly Type[] StringSignalTypes = {typeof(KeywordAttribute), typeof(TextAttribute)}; private static void ApplyBuildInSerializers(MemberInfo member, JsonProperty property) { var attributes = member.GetCustomAttributes().ToList(); var stringy = attributes.Any(a => StringSignalTypes.Contains(a.GetType())); - if (attributes.OfType().Any() || (property.PropertyType.IsEnumType() && stringy)) + if (attributes.OfType().Any() || property.PropertyType.IsEnumType() && stringy) property.Converter = StringEnumConverter; if ((property.PropertyType == typeof(TimeSpan) || property.PropertyType == typeof(TimeSpan?)) - && (attributes.OfType().Any() || stringy)) + && (attributes.OfType().Any() || stringy)) property.Converter = StringTimeSpanConverter; if ((property.PropertyType == typeof(DateTime) || property.PropertyType == typeof(DateTime?)) - && (attributes.OfType().Any())) + && attributes.OfType().Any()) property.Converter = MachineLearningDateTimeConverter; } @@ -256,10 +257,10 @@ private static void ApplyBuildInSerializersForType(Type type, JsonContract contr /// Renames/Ignores a property based on the connection settings mapping or custom attributes for the property private void ApplyPropertyOverrides(MemberInfo member, JsonProperty property) { - if (!this.ConnectionSettings.PropertyMappings.TryGetValue(member, out var propertyMapping)) + if (!ConnectionSettings.PropertyMappings.TryGetValue(member, out var propertyMapping)) propertyMapping = ElasticsearchPropertyAttributeBase.From(member); - var serializerMapping = this.ConnectionSettings.PropertyMappingProvider?.CreatePropertyMapping(member); + var serializerMapping = ConnectionSettings.PropertyMappingProvider?.CreatePropertyMapping(member); var nameOverride = propertyMapping?.Name ?? serializerMapping?.Name; if (!nameOverride.IsNullOrEmpty()) property.PropertyName = nameOverride; @@ -280,20 +281,21 @@ private void ApplyShouldSerializer(JsonProperty property) // Skip serialization of empty collections that have DefaultValueHandling set to Ignore. else if (property.DefaultValueHandling.HasValue - && property.DefaultValueHandling.Value == DefaultValueHandling.Ignore - && !typeof(string).IsAssignableFrom(property.PropertyType) - && typeof(IEnumerable).IsAssignableFrom(property.PropertyType)) + && property.DefaultValueHandling.Value == DefaultValueHandling.Ignore + && !typeof(string).IsAssignableFrom(property.PropertyType) + && typeof(IEnumerable).IsAssignableFrom(property.PropertyType)) { bool ShouldSerialize(object obj) { if (!(property.ValueProvider.GetValue(obj) is ICollection collection)) return true; + return collection.Count != 0 && collection.Cast().Any(item => item != null); } property.ShouldSerialize = property.ShouldSerialize == null - ? (Predicate) ShouldSerialize - : (o => property.ShouldSerialize(o) && ShouldSerialize(o)); + ? (Predicate)ShouldSerialize + : o => property.ShouldSerialize(o) && ShouldSerialize(o); } } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/CompositeJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/CompositeJsonConverter.cs index 51da6df74d0..179c728f081 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/CompositeJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/CompositeJsonConverter.cs @@ -7,31 +7,22 @@ internal class CompositeJsonConverter : JsonConverter where TRead : JsonConverter, new() where TWrite : JsonConverter, new() { - private TRead Read { get; set; } - private TWrite Write { get; set; } - - public override bool CanRead => true; - public override bool CanWrite => true; - public CompositeJsonConverter() { - this.Read = new TRead(); - this.Write = new TWrite(); + Read = new TRead(); + Write = new TWrite(); } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - this.Write.WriteJson(writer, value, serializer); - } + public override bool CanRead => true; + public override bool CanWrite => true; + private TRead Read { get; set; } + private TWrite Write { get; set; } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - return this.Read.ReadJson(reader, objectType, existingValue, serializer); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => Write.WriteJson(writer, value, serializer); - public override bool CanConvert(Type objectType) - { - return true; - } + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => + Read.ReadJson(reader, objectType, existingValue, serializer); + + public override bool CanConvert(Type objectType) => true; } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/EnumMemberValueCasingJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/EnumMemberValueCasingJsonConverter.cs index 58268ab53b0..2d19d4edd22 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/EnumMemberValueCasingJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/EnumMemberValueCasingJsonConverter.cs @@ -5,13 +5,14 @@ using Newtonsoft.Json; #if DOTNETCORE using System.Reflection; + #endif namespace Nest { /// /// A Json converter that can serialize enums to strings where the string values - /// are specified using and where values + /// are specified using and where values /// differ in casing. /// /// @@ -81,9 +82,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return Enum.TryParse(value, true, out enumValue) ? enumValue : default(TEnum); } - public override bool CanConvert(Type objectType) - { - return objectType == typeof(TEnum); - } + public override bool CanConvert(Type objectType) => objectType == typeof(TEnum); } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorCauseJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorCauseJsonConverter.cs index a3c25abae51..27def9ffedf 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorCauseJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorCauseJsonConverter.cs @@ -14,6 +14,7 @@ internal class ErrorCauseJsonConverter : JsonConverter { public override bool CanRead => true; public override bool CanWrite => false; + public override bool CanConvert(Type objectType) => objectType == typeof(Error); public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { } @@ -21,7 +22,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => ReadError(reader, serializer, (e, prop) => { - if (!this.ReadProperty(e, prop, reader, serializer)) + if (!ReadProperty(e, prop, reader, serializer)) reader.Skip(); }); @@ -35,7 +36,7 @@ private TInnerError ReadError(JsonReader reader, JsonSerializer ser { if (reader.TokenType == JsonToken.String) { - var reason = (string) reader.Value; + var reason = (string)reader.Value; return new TInnerError { Reason = reason }; } if (reader.TokenType != JsonToken.StartObject) @@ -49,7 +50,7 @@ private TInnerError ReadError(JsonReader reader, JsonSerializer ser reader.Read(); do { - var propertyName = (string) reader.Value; + var propertyName = (string)reader.Value; switch (propertyName) { case "type": @@ -139,6 +140,7 @@ protected static IReadOnlyCollection ExtractFailedShards(JsonReade { reader.Read(); if (reader.TokenType != JsonToken.StartArray) return EmptyReadOnly.Collection; + var shardFailures = serializer.Deserialize>(reader); return new ReadOnlyCollection(shardFailures); } @@ -148,7 +150,7 @@ private static IReadOnlyCollection ReadArray(JsonReader reader) var a = new string[0] { }; reader.Read(); if (reader.TokenType == JsonToken.String) - a = new[] {(reader.Value as string)}; + a = new[] { reader.Value as string }; else if (reader.TokenType == JsonToken.StartArray) a = JArray.Load(reader).ToObject>().ToArray(); return new ReadOnlyCollection(a); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorJsonConverter.cs index a9c7fcce0ea..3473bc8c7a7 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ErrorJsonConverter.cs @@ -23,8 +23,10 @@ private static bool ExtractHeaders(Error error, JsonReader reader, JsonSerialize reader.Read(); if (reader.TokenType != JsonToken.StartObject) return false; + var dict = serializer.Deserialize>(reader); if (dict == null) return false; + error.Headers = new ReadOnlyDictionary(dict); return true; } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/FromJson.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/FromJson.cs index 14d14a5688a..b26dadc0853 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/FromJson.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/FromJson.cs @@ -16,7 +16,8 @@ public static T ReadAs(JsonReader reader, JsonSerializer serializer) } /// - /// Read the json as an instance of + /// Read the json as an instance of + /// /// public static object Read(JsonReader reader, Type objectType, JsonSerializer serializer) { @@ -24,6 +25,5 @@ public static object Read(JsonReader reader, Type objectType, JsonSerializer ser serializer.Populate(reader, t); return t; } - } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/GenericProxyRequestConverterBase.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/GenericProxyRequestConverterBase.cs index e4c974b7d0e..9899465bb3e 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/GenericProxyRequestConverterBase.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/GenericProxyRequestConverterBase.cs @@ -3,7 +3,6 @@ using System.Reflection; using System.Text; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using static Elasticsearch.Net.SerializationFormatting; namespace Nest @@ -17,6 +16,7 @@ protected GenericProxyRequestConverterBase(Type genericRequestType) => public override bool CanRead => true; public override bool CanWrite => true; + public override bool CanConvert(Type objectType) => true; public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) @@ -24,13 +24,13 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist var token = reader.ReadTokenWithDateParseHandlingNone(); using (var ms = token.ToStream(serializer.GetConnectionSettings().MemoryStreamFactory)) { - //not optimized but deserializing create requests is far from common practice - var genericType = objectType.GetTypeInfo().GenericTypeArguments[0]; + //not optimized but deserializing create requests is far from common practice + var genericType = objectType.GetTypeInfo().GenericTypeArguments[0]; var o = serializer.GetConnectionSettings().SourceSerializer.Deserialize(genericType, ms); var path = typeof(DocumentPath<>).CreateGenericInstance(genericType, o); - // index, type and id are optional parameters on _genericRequestType but need to be passed to construct through reflection - var x = _genericRequestType.CreateGenericInstance(genericType, path, null, null, null); - return x; + // index, type and id are optional parameters on _genericRequestType but need to be passed to construct through reflection + var x = _genericRequestType.CreateGenericInstance(genericType, path, null, null, null); + return x; } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/IndicesBoostJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/IndicesBoostJsonConverter.cs index 6f0c6fb3011..e4e5199b605 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/IndicesBoostJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/IndicesBoostJsonConverter.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using Newtonsoft.Json; namespace Nest @@ -18,7 +17,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s var settings = serializer.GetConnectionSettings(); writer.WriteStartArray(); - foreach(var entry in dictionary) + foreach (var entry in dictionary) { writer.WriteStartObject(); var indexName = settings.Inferrer.IndexName(entry.Key); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/JsonConverterBase.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/JsonConverterBase.cs index 304e84d59be..937125e5c1f 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/JsonConverterBase.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/JsonConverterBase.cs @@ -5,14 +5,16 @@ namespace Nest { internal abstract class JsonConverterBase : JsonConverter where T : class { - public override bool CanConvert(Type objectType) => true; - public override bool CanWrite => true; public override bool CanRead => true; + public override bool CanWrite => true; + + public override bool CanConvert(Type objectType) => true; public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (!(value is T v)) return; - this.WriteJson(writer, v, serializer); + + WriteJson(writer, v, serializer); } public abstract void WriteJson(JsonWriter writer, T value, JsonSerializer serializer); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/KeyValueJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/KeyValueJsonConverter.cs index addb0aa99a2..0ac1b39cd3e 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/KeyValueJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/KeyValueJsonConverter.cs @@ -6,11 +6,13 @@ namespace Nest { - internal class KeyValueConversion { private static readonly ConcurrentDictionary KnownTypes = new ConcurrentDictionary(); + public JsonProperty KeyProperty { get; set; } + public JsonProperty ValueProperty { get; set; } + public static KeyValueConversion Create() where TContainer : class, new() { var t = typeof(TContainer); @@ -22,23 +24,21 @@ internal class KeyValueConversion var valueProp = properties.FirstOrDefault(p => p.PropertyType == typeof(TValue)); if (keyProp == null) throw new Exception($"No key property found on type {t.Name}"); if (valueProp == null) throw new Exception($"No value property found on type {t.Name}"); - conversion = new KeyValueConversion { KeyProperty = keyProp, ValueProperty = valueProp}; + + conversion = new KeyValueConversion { KeyProperty = keyProp, ValueProperty = valueProp }; KnownTypes.TryAdd(t, conversion); return conversion; } - - public JsonProperty KeyProperty { get; set; } - public JsonProperty ValueProperty { get; set; } } internal class KeyValueJsonConverter : JsonConverter where TContainer : class, new() { - - public override bool CanConvert(Type objectType) => true; public override bool CanRead => true; public override bool CanWrite => true; + public override bool CanConvert(Type objectType) => true; + public override void WriteJson(JsonWriter writer, object v, JsonSerializer serializer) { var conversion = KeyValueConversion.Create(); @@ -46,7 +46,8 @@ public override void WriteJson(JsonWriter writer, object v, JsonSerializer seria { writer.WriteNull(); return; - }; + } + ; var key = conversion.KeyProperty.ValueProvider.GetValue(v).ToString(); var value = conversion.ValueProperty.ValueProvider.GetValue(v); @@ -54,7 +55,8 @@ public override void WriteJson(JsonWriter writer, object v, JsonSerializer seria { writer.WriteNull(); return; - }; + } + ; writer.WriteStartObject(); writer.WritePropertyName(key); @@ -66,6 +68,7 @@ public override void WriteJson(JsonWriter writer, object v, JsonSerializer seria public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.StartObject) return null; + var depth = reader.Depth; reader.Read(); //property name @@ -76,9 +79,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist if (reader.Depth > depth) { do - { reader.Read(); - } while (reader.Depth >= depth && reader.TokenType != JsonToken.EndObject); + while (reader.Depth >= depth && reader.TokenType != JsonToken.EndObject); } var conversion = KeyValueConversion.Create(); @@ -89,6 +91,5 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist conversion.ValueProperty.ValueProvider.SetValue(o, value); return o; } - } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadAsTypeJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadAsTypeJsonConverter.cs index 240036c83e2..77c4d9d0f49 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadAsTypeJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadAsTypeJsonConverter.cs @@ -19,11 +19,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist internal class ReadAsAttribute : Attribute { - public Type Type { get; } + public ReadAsAttribute(Type readAs) => Type = readAs; - public ReadAsAttribute(Type readAs) - { - this.Type = readAs; - } + public Type Type { get; } } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadOnlyCollectionJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadOnlyCollectionJsonConverter.cs index cec6bc92bb4..724a1aeacf4 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadOnlyCollectionJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadOnlyCollectionJsonConverter.cs @@ -6,12 +6,12 @@ namespace Nest { /// - /// Json converter that deserializes into an or - /// where does not have a custom deserializer and should be deserialized - /// into concrete types of + /// Json converter that deserializes into an or + /// where does not have a custom deserializer and should be deserialized + /// into concrete types of /// /// - /// may not have a deserializer for valid reasons, for example, an interface may be implemented by two + /// may not have a deserializer for valid reasons, for example, an interface may be implemented by two /// concrete types that need to be deserialized. In this case, a deserializer would not know which concrete type to deserialize to in /// a given context. /// @@ -21,13 +21,10 @@ internal class ReadOnlyCollectionJsonConverter : JsonConv where TDocument : TInterface where TInterface : class { - public override bool CanWrite => false; public override bool CanRead => true; + public override bool CanWrite => false; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotSupportedException(); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadSingleOrEnumerableJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadSingleOrEnumerableJsonConverter.cs index ed414f96137..3ce69043b10 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadSingleOrEnumerableJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReadSingleOrEnumerableJsonConverter.cs @@ -5,16 +5,14 @@ namespace Nest { internal class ReadSingleOrEnumerableJsonConverter : JsonConverter { + public override bool CanWrite => false; + public override bool CanConvert(Type objectType) => true; - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - return reader.TokenType == JsonToken.StartArray + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => + reader.TokenType == JsonToken.StartArray ? serializer.Deserialize(reader) : new[] { serializer.Deserialize(reader) }; - } - - public override bool CanWrite => false; public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReserializeJsonConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReserializeJsonConverter.cs index 12f0233a1f6..6bee77714c3 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReserializeJsonConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/ReserializeJsonConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using Newtonsoft.Json; namespace Nest @@ -8,54 +7,54 @@ internal class ReserializeJsonConverter : JsonConverter where TReadAs : class, TInterface where TInterface : class { - protected ReadAsTypeJsonConverter Reader { get; } = new ReadAsTypeJsonConverter(); - public override bool CanRead => true; public override bool CanWrite => true; + protected ReadAsTypeJsonConverter Reader { get; } = new ReadAsTypeJsonConverter(); public override bool CanConvert(Type objectType) => typeof(TInterface).IsAssignableFrom(objectType); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.StartObject) return null; + var depth = reader.Depth; - var deserialized = this.DeserializeJson(reader, objectType, existingValue, serializer); + var deserialized = DeserializeJson(reader, objectType, existingValue, serializer); return reader.ReadToEnd(depth, deserialized); } - protected TReadAs ReadAs(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - return this.Reader.ReadJson(reader, objectType, existingValue, serializer) as TReadAs; - } + protected TReadAs ReadAs(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => + Reader.ReadJson(reader, objectType, existingValue, serializer) as TReadAs; protected virtual object DeserializeJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => - this.ReadAs(reader, objectType, existingValue, serializer); + ReadAs(reader, objectType, existingValue, serializer); public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (!(value is TInterface v)) return; - this.SerializeJson(writer, value, v, serializer); - } - protected virtual void SerializeJson(JsonWriter writer, object value, TInterface castValue, JsonSerializer serializer) - { - this.Reserialize(writer, value, serializer); + SerializeJson(writer, value, v, serializer); } + protected virtual void SerializeJson(JsonWriter writer, object value, TInterface castValue, JsonSerializer serializer) => + Reserialize(writer, value, serializer); + protected virtual bool SkipWriteProperty(string propertyName) => false; protected void Reserialize(JsonWriter writer, object value, JsonSerializer serializer, Action inlineWriter = null) { var properties = value.GetType().GetCachedObjectProperties(); if (properties.Count == 0) return; + writer.WriteStartObject(); inlineWriter?.Invoke(writer); foreach (var p in properties) { if (p.Ignored || SkipWriteProperty(p.PropertyName)) continue; + var vv = p.ValueProvider.GetValue(value); if (vv == null) continue; + writer.WritePropertyName(p.PropertyName); if (p.Converter?.GetType() == typeof(SourceValueWriteConverter)) SourceValueWriteConverter.Write(writer, vv, serializer); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/TimeSpanToStringConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/TimeSpanToStringConverter.cs index a66c2d2d871..21265fde70c 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/TimeSpanToStringConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/TimeSpanToStringConverter.cs @@ -11,7 +11,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s writer.WriteNull(); else { - var timeSpan = (TimeSpan) value; + var timeSpan = (TimeSpan)value; writer.WriteValue(timeSpan.Ticks); } } @@ -21,12 +21,12 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist switch (reader.TokenType) { case JsonToken.Null: return null; - case JsonToken.String: return TimeSpan.Parse((string) reader.Value); - case JsonToken.Integer: return new TimeSpan((long) reader.Value); + case JsonToken.String: return TimeSpan.Parse((string)reader.Value); + case JsonToken.Integer: return new TimeSpan((long)reader.Value); } throw new JsonSerializationException($"Cannot convert token of type {reader.TokenType} to {objectType}."); } - public override bool CanConvert(Type objectType) => objectType == typeof (TimeSpan) || objectType == typeof (TimeSpan?); + public override bool CanConvert(Type objectType) => objectType == typeof(TimeSpan) || objectType == typeof(TimeSpan?); } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/VerbatimDictionaryKeysConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/VerbatimDictionaryKeysConverter.cs index d8c207d81f5..1855783b398 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/VerbatimDictionaryKeysConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/VerbatimDictionaryKeysConverter.cs @@ -1,8 +1,8 @@ using System; -using System.Linq; using System.Collections; using System.Collections.Generic; using System.Globalization; +using System.Linq; using Newtonsoft.Json; namespace Nest @@ -13,14 +13,12 @@ namespace Nest /// internal class VerbatimDictionaryKeysJsonConverter : JsonConverter { - public override bool CanConvert(Type t) => typeof(IDictionary).IsAssignableFrom(t); - public override bool CanRead => false; - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { + public override bool CanConvert(Type t) => typeof(IDictionary).IsAssignableFrom(t); + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => throw new NotSupportedException(); - } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { @@ -38,37 +36,30 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { if (entry.Value == null && serializer.NullValueHandling == NullValueHandling.Ignore) continue; + string key; if (settings == null) key = Convert.ToString(entry.Key, CultureInfo.InvariantCulture); else { if (AsType(entry.Key, out Field fieldName)) - { key = settings.Inferrer.Field(fieldName); - } else { if (AsType(entry.Key, out PropertyName propertyName)) { - if (propertyName?.Property != null && - (settings.PropertyMappings.TryGetValue(propertyName.Property, out var mapping) && mapping.Ignore)) + if (propertyName?.Property != null && settings.PropertyMappings.TryGetValue(propertyName.Property, out var mapping) + && mapping.Ignore) continue; key = settings.Inferrer.PropertyName(propertyName); } else if (AsType(entry.Key, out IndexName indexName)) - { key = settings.Inferrer.IndexName(indexName); - } else if (AsType(entry.Key, out TypeName typeName)) - { key = settings.Inferrer.TypeName(typeName); - } else if (AsType(entry.Key, out RelationName relationName)) - { key = settings.Inferrer.RelationName(relationName); - } else key = Convert.ToString(entry.Key, CultureInfo.InvariantCulture); } @@ -101,19 +92,19 @@ private static bool AsType(object value, out T convertedValue) where T : clas /// internal class VerbatimDictionaryKeysJsonConverter : JsonConverter { - private readonly bool _keyIsString = typeof(TKey) == typeof(string); private readonly bool _keyIsField = typeof(TKey) == typeof(Field); - private readonly bool _keyIsPropertyName = typeof(TKey) == typeof(PropertyName); private readonly bool _keyIsIndexName = typeof(TKey) == typeof(IndexName); - private readonly bool _keyIsTypeName = typeof(TKey) == typeof(TypeName); + private readonly bool _keyIsPropertyName = typeof(TKey) == typeof(PropertyName); private readonly bool _keyIsRelationName = typeof(TKey) == typeof(RelationName); + private readonly bool _keyIsString = typeof(TKey) == typeof(string); + private readonly bool _keyIsTypeName = typeof(TKey) == typeof(TypeName); + + public override bool CanRead => false; public override bool CanConvert(Type t) => typeof(IDictionary).IsAssignableFrom(t) || typeof(IReadOnlyDictionary).IsAssignableFrom(t); - public override bool CanRead => false; - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => throw new NotSupportedException(); @@ -133,6 +124,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { if (SkipValue(serializer, entry)) continue; + string key; if (_keyIsString) key = entry.Key?.ToString(); @@ -146,8 +138,8 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s else if (_keyIsPropertyName) { var propertyName = entry.Key as PropertyName; - if (propertyName?.Property != null && - (settings.PropertyMappings.TryGetValue(propertyName.Property, out var mapping) && mapping.Ignore)) + if (propertyName?.Property != null && settings.PropertyMappings.TryGetValue(propertyName.Property, out var mapping) + && mapping.Ignore) continue; key = settings.Inferrer.PropertyName(propertyName); @@ -175,7 +167,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s } writer.WriteStartObject(); - foreach(var entry in seenEntries) + foreach (var entry in seenEntries) { writer.WritePropertyName(entry.Key); serializer.Serialize(writer, entry.Value); @@ -183,19 +175,17 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s writer.WriteEndObject(); } - protected virtual bool SkipValue(JsonSerializer serializer, KeyValuePair entry) - { - return entry.Value == null && serializer.NullValueHandling == NullValueHandling.Ignore; - } + protected virtual bool SkipValue(JsonSerializer serializer, KeyValuePair entry) => + entry.Value == null && serializer.NullValueHandling == NullValueHandling.Ignore; } internal class VerbatimDictionaryKeysJsonConverter : VerbatimDictionaryKeysJsonConverter where TIsADictionary : IIsADictionary { - public override bool CanConvert(Type t) => true; - public override bool CanRead => true; + public override bool CanConvert(Type t) => true; + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var dictionary = serializer.Deserialize>(reader); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/InternalSerializer.cs b/src/Nest/CommonAbstractions/SerializationBehavior/InternalSerializer.cs index ae7c5551ab8..7f28a6a9d06 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/InternalSerializer.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/InternalSerializer.cs @@ -11,20 +11,28 @@ namespace Nest /// The built in internal serializer that the high level client NEST uses. internal class InternalSerializer : IElasticsearchSerializer { - // Default buffer size of StreamWriter, which is private :( internal const int DefaultBufferSize = 1024; - + private static readonly Task CompletedTask = Task.CompletedTask; internal static readonly Encoding ExpectedEncoding = new UTF8Encoding(false); + private readonly JsonSerializer _indentedSerializer; - private static readonly Task CompletedTask = Task.CompletedTask; + public InternalSerializer(IConnectionSettingsValues settings) : this(settings, null) { } - private readonly JsonSerializer _indentedSerializer; - internal JsonSerializer Serializer { get; } + /// + /// this constructor is only here for stateful (de)serialization + /// + protected internal InternalSerializer(IConnectionSettingsValues settings, JsonConverter statefulConverter) + { + Settings = settings; + var piggyBackState = statefulConverter == null ? null : new JsonConverterPiggyBackState { ActualJsonConverter = statefulConverter }; + ContractResolver = new ElasticContractResolver(Settings) { PiggyBackState = piggyBackState }; - protected IConnectionSettingsValues Settings { get; } + var collapsed = CreateSettings(SerializationFormatting.None); + var indented = CreateSettings(SerializationFormatting.Indented); - /// Resolves JsonContracts for types - private ElasticContractResolver ContractResolver { get; } + Serializer = JsonSerializer.Create(collapsed); + _indentedSerializer = JsonSerializer.Create(indented); + } /// /// The size of the buffer to use when writing the serialized request @@ -34,22 +42,28 @@ internal class InternalSerializer : IElasticsearchSerializer // to be a good compromise buffer size for performance throughput and bytes allocated. protected virtual int BufferSize => DefaultBufferSize; - public InternalSerializer(IConnectionSettingsValues settings) : this(settings, null) { } + protected IConnectionSettingsValues Settings { get; } + internal JsonSerializer Serializer { get; } - /// - /// this constructor is only here for stateful (de)serialization - /// - protected internal InternalSerializer(IConnectionSettingsValues settings, JsonConverter statefulConverter) + /// Resolves JsonContracts for types + private ElasticContractResolver ContractResolver { get; } + + public T Deserialize(Stream stream) { - this.Settings = settings; - var piggyBackState = statefulConverter == null ? null : new JsonConverterPiggyBackState { ActualJsonConverter = statefulConverter }; - this.ContractResolver = new ElasticContractResolver(this.Settings) { PiggyBackState = piggyBackState }; + if (stream == null || stream.CanSeek && stream.Length == 0) return default(T); - var collapsed = this.CreateSettings(SerializationFormatting.None); - var indented = this.CreateSettings(SerializationFormatting.Indented); + using (var streamReader = new StreamReader(stream)) + using (var jsonTextReader = new JsonTextReader(streamReader)) + return Serializer.Deserialize(jsonTextReader); + } - this.Serializer = JsonSerializer.Create(collapsed); - this._indentedSerializer = JsonSerializer.Create(indented); + public object Deserialize(Type type, Stream stream) + { + if (stream == null || stream.CanSeek && stream.Length == 0) return type.DefaultValue(); + + using (var streamReader = new StreamReader(stream)) + using (var jsonTextReader = new JsonTextReader(streamReader)) + return Serializer.Deserialize(jsonTextReader, type); } public virtual void Serialize(T data, Stream writableStream, SerializationFormatting formatting = SerializationFormatting.Indented) @@ -61,7 +75,7 @@ public virtual void Serialize(T data, Stream writableStream, SerializationFor //this leaveOpen is most likely here because in PostData when we serialize IEnumerable as multi json //we call this multiple times, it would be better to have a dedicated Serialize(IEnumerable) on the //IElasticsearchSerializer interface more explicitly - using (var writer = new StreamWriter(writableStream, ExpectedEncoding, BufferSize, leaveOpen: true)) + using (var writer = new StreamWriter(writableStream, ExpectedEncoding, BufferSize, true)) using (var jsonWriter = new JsonTextWriter(writer)) { serializer.Serialize(jsonWriter, data); @@ -71,42 +85,28 @@ public virtual void Serialize(T data, Stream writableStream, SerializationFor } public Task SerializeAsync(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.Indented, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default(CancellationToken) + ) { //This makes no sense now but we need the async method on the interface in 6.x so we can start swapping this out //for an implementation that does make sense without having to wait for 7.x - this.Serialize(data, stream, formatting); + Serialize(data, stream, formatting); return CompletedTask; } - public T Deserialize(JsonReader reader) => this.Serializer.Deserialize(reader); - - public object Deserialize(JsonReader reader, Type objectType) => this.Serializer.Deserialize(reader, objectType); - - public T Deserialize(Stream stream) - { - if (stream == null || stream.CanSeek && stream.Length == 0) return default(T); - using (var streamReader = new StreamReader(stream)) - using (var jsonTextReader = new JsonTextReader(streamReader)) - return this.Serializer.Deserialize(jsonTextReader); - } - - public object Deserialize(Type type, Stream stream) - { - if (stream == null || stream.CanSeek && stream.Length == 0) return type.DefaultValue(); - using (var streamReader = new StreamReader(stream)) - using (var jsonTextReader = new JsonTextReader(streamReader)) - return this.Serializer.Deserialize(jsonTextReader, type); - } + public T Deserialize(JsonReader reader) => Serializer.Deserialize(reader); + public object Deserialize(JsonReader reader, Type objectType) => Serializer.Deserialize(reader, objectType); + // Default buffer size of StreamWriter, which is private :( #pragma warning disable 1998 // we know this is not an async operation public async Task DeserializeAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) #pragma warning restore 1998 { if (stream == null || stream.CanSeek && stream.Length == 0) return default(T); - using (var sr = new StreamReader(stream)) - using (var jtr = new JsonTextReader(sr)) - return this.Serializer.Deserialize(jtr); + + using (var sr = new StreamReader(stream)) + using (var jtr = new JsonTextReader(sr)) + return Serializer.Deserialize(jtr); } #pragma warning disable 1998 // we know this is not an async operation @@ -114,9 +114,10 @@ public object Deserialize(Type type, Stream stream) #pragma warning restore 1998 { if (stream == null || stream.CanSeek && stream.Length == 0) return type.DefaultValue(); - using (var sr = new StreamReader(stream)) - using (var jtr = new JsonTextReader(sr)) - return this.Serializer.Deserialize(jtr, type); + + using (var sr = new StreamReader(stream)) + using (var jtr = new JsonTextReader(sr)) + return Serializer.Deserialize(jtr, type); } private JsonSerializerSettings CreateSettings(SerializationFormatting formatting) @@ -124,7 +125,7 @@ private JsonSerializerSettings CreateSettings(SerializationFormatting formatting var settings = new JsonSerializerSettings { Formatting = formatting == SerializationFormatting.Indented ? Formatting.Indented : Formatting.None, - ContractResolver = this.ContractResolver, + ContractResolver = ContractResolver, DefaultValueHandling = DefaultValueHandling.Include, NullValueHandling = NullValueHandling.Ignore }; diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/JTokenExtensions.cs b/src/Nest/CommonAbstractions/SerializationBehavior/JTokenExtensions.cs index 0e993ec17fc..7ce15551638 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/JTokenExtensions.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/JTokenExtensions.cs @@ -1,7 +1,5 @@ -using System; -using System.IO; +using System.IO; using System.Runtime.CompilerServices; -using System.Text; using System.Threading; using System.Threading.Tasks; using Elasticsearch.Net; @@ -13,15 +11,16 @@ namespace Nest internal static class JTokenExtensions { /// - /// Writes a to a using + /// Writes a to a using /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static MemoryStream ToStream( this JToken token, - IMemoryStreamFactory memoryStreamFactory = null) + IMemoryStreamFactory memoryStreamFactory = null + ) { var ms = memoryStreamFactory?.Create() ?? new MemoryStream(); - using (var streamWriter = new StreamWriter(ms, InternalSerializer.ExpectedEncoding, InternalSerializer.DefaultBufferSize, leaveOpen: true)) + using (var streamWriter = new StreamWriter(ms, InternalSerializer.ExpectedEncoding, InternalSerializer.DefaultBufferSize, true)) using (var writer = new JsonTextWriter(streamWriter)) { token.WriteTo(writer); @@ -32,16 +31,17 @@ public static MemoryStream ToStream( } /// - /// Writes a asynchronously to a using + /// Writes a asynchronously to a using /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static async Task ToStreamAsync( this JToken token, IMemoryStreamFactory memoryStreamFactory = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default(CancellationToken) + ) { var ms = memoryStreamFactory?.Create() ?? new MemoryStream(); - using (var streamWriter = new StreamWriter(ms, InternalSerializer.ExpectedEncoding, InternalSerializer.DefaultBufferSize, leaveOpen: true)) + using (var streamWriter = new StreamWriter(ms, InternalSerializer.ExpectedEncoding, InternalSerializer.DefaultBufferSize, true)) using (var writer = new JsonTextWriter(streamWriter)) { await token.WriteToAsync(writer, cancellationToken).ConfigureAwait(false); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/JsonReaderExtensions.cs b/src/Nest/CommonAbstractions/SerializationBehavior/JsonReaderExtensions.cs index 2536de619ca..ebe592661d3 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/JsonReaderExtensions.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/JsonReaderExtensions.cs @@ -21,10 +21,10 @@ public static T ReadToEnd(this JsonReader reader, int depth, T r = null) where T : class { if (reader.Depth <= depth) return r; + do - { reader.Read(); - } while (reader.Depth >= depth && reader.TokenType != JsonToken.EndObject); + while (reader.Depth >= depth && reader.TokenType != JsonToken.EndObject); return r; } @@ -32,18 +32,18 @@ public static T ExhaustTo(this JsonReader reader, int depth, T r = null, Json where T : class { if (reader.Depth < depth) return r; + while (reader.Depth >= depth) { - if (reader.Depth == depth && reader.TokenType == endType) - { - break; - } + if (reader.Depth == depth && reader.TokenType == endType) break; + var readAnything = reader.Read(); if (!readAnything || reader.Depth < depth) break; } return r; } - public static object ExhaustTo(this JsonReader reader, int depth, JsonToken endType = JsonToken.EndObject) => reader.ExhaustTo(depth, null, endType); + public static object ExhaustTo(this JsonReader reader, int depth, JsonToken endType = JsonToken.EndObject) => + reader.ExhaustTo(depth, null, endType); } } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/PropertyMapping.cs b/src/Nest/CommonAbstractions/SerializationBehavior/PropertyMapping.cs index b72febddd4e..cea17eab878 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/PropertyMapping.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/PropertyMapping.cs @@ -8,26 +8,27 @@ namespace Nest /// Determines how a POCO property maps to the property on a JSON object when serialized public interface IPropertyMapping { - /// Override the property name serialized to JSON for this property - string Name { get; set; } /// /// Ignore this property completely - /// - When mapping automatically using + /// - When mapping automatically using /// - When Indexing this type do not serialize this property and its value /// bool Ignore { get; set; } + + /// Override the property name serialized to JSON for this property + string Name { get; set; } } - /// + /// public class PropertyMapping : IPropertyMapping { public static PropertyMapping Ignored = new PropertyMapping { Ignore = true }; /// - public string Name { get; set; } + public bool Ignore { get; set; } /// - public bool Ignore { get; set; } + public string Name { get; set; } } /// @@ -36,24 +37,24 @@ public class PropertyMapping : IPropertyMapping public interface IPropertyMappingProvider { /// - /// Creates an for a + /// Creates an for a /// IPropertyMapping CreatePropertyMapping(MemberInfo memberInfo); } - /// + /// public class PropertyMappingProvider : IPropertyMappingProvider { protected readonly ConcurrentDictionary Properties = new ConcurrentDictionary(); - /// + /// public virtual IPropertyMapping CreatePropertyMapping(MemberInfo memberInfo) { var memberInfoString = $"{memberInfo.DeclaringType?.FullName}.{memberInfo.Name}"; if (Properties.TryGetValue(memberInfoString, out var mapping)) return mapping; mapping = PropertyMappingFromAttributes(memberInfo); - this.Properties.TryAdd(memberInfoString, mapping); + Properties.TryAdd(memberInfoString, mapping); return mapping; } @@ -64,9 +65,9 @@ private static IPropertyMapping PropertyMappingFromAttributes(MemberInfo memberI var propertyName = memberInfo.GetCustomAttribute(true); var ignore = memberInfo.GetCustomAttribute(true); if (jsonProperty == null && ignore == null && propertyName == null && dataMemberProperty == null) return null; - return new PropertyMapping {Name = propertyName?.Name ?? jsonProperty?.PropertyName ?? dataMemberProperty?.Name, Ignore = ignore != null}; + + return new PropertyMapping + { Name = propertyName?.Name ?? jsonProperty?.PropertyName ?? dataMemberProperty?.Name, Ignore = ignore != null }; } } - - } diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/SourceConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/SourceConverter.cs index e789c4fb0aa..5fb4f1838a6 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/SourceConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/SourceConverter.cs @@ -1,9 +1,6 @@ using System; -using System.IO; -using System.Text; using Elasticsearch.Net; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using static Elasticsearch.Net.SerializationFormatting; namespace Nest @@ -12,10 +9,11 @@ internal class SourceConverter : JsonConverter { public override bool CanRead => true; public override bool CanWrite => true; - public override bool CanConvert(Type objectType) => true; public virtual SerializationFormatting? ForceFormatting { get; } = null; + public override bool CanConvert(Type objectType) => true; + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var sourceSerializer = serializer.GetConnectionSettings().SourceSerializer; diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/SourceValueWriteConverter.cs b/src/Nest/CommonAbstractions/SerializationBehavior/SourceValueWriteConverter.cs index 32256e5d365..a69b879409b 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/SourceValueWriteConverter.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/SourceValueWriteConverter.cs @@ -8,12 +8,10 @@ internal class SourceValueWriteConverter : JsonConverter { public override bool CanRead => false; public override bool CanWrite => true; + public override bool CanConvert(Type objectType) => true; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - Write(writer, value, serializer); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => Write(writer, value, serializer); public static void Write(JsonWriter writer, object value, JsonSerializer serializer) { diff --git a/src/Nest/CommonAbstractions/Static/Infer.cs b/src/Nest/CommonAbstractions/Static/Infer.cs index 1f45a7c0a94..f123460d473 100644 --- a/src/Nest/CommonAbstractions/Static/Infer.cs +++ b/src/Nest/CommonAbstractions/Static/Infer.cs @@ -8,38 +8,49 @@ namespace Nest { public static class Infer { + public static Indices AllIndices = Nest.Indices.All; + public static Types AllTypes = Types.All; + public static IndexName Index(IndexName index) => index; + public static IndexName Index() => typeof(T); + public static IndexName Index(string clusterName) => IndexName.From(clusterName); public static Indices Indices() => typeof(T); + public static Indices Indices(params IndexName[] indices) => indices; + public static Indices Indices(IEnumerable indices) => indices.ToArray(); - public static Indices AllIndices = Nest.Indices.All; public static TypeName Type(TypeName type) => type; + public static TypeName Type() => typeof(T); + public static Types Type(IEnumerable types) => new Types.ManyTypes(types); + public static Types Type(params TypeName[] types) => new Types.ManyTypes(types); - public static Types AllTypes = Nest.Types.All; public static RelationName Relation(string type) => type; + public static RelationName Relation(Type type) => type; + public static RelationName Relation() => typeof(T); - public static Routing Route(T instance) where T : class => Nest.Routing.From(instance); + public static Routing Route(T instance) where T : class => Routing.From(instance); public static Names Names(params string[] names) => string.Join(",", names); + public static Names Names(IEnumerable names) => string.Join(",", names); public static Id Id(T document) where T : class => Nest.Id.From(document); public static Fields Fields(params Expression>[] fields) where T : class => - new Fields(fields.Select(f=>(Field)f)); + new Fields(fields.Select(f => (Field)f)); - public static Fields Fields(params string[] fields) => new Fields(fields.Select(f=>(Field)f)); + public static Fields Fields(params string[] fields) => new Fields(fields.Select(f => (Field)f)); - public static Fields Fields(params PropertyInfo[] properties) => new Fields(properties.Select(f=>(Field)f)); + public static Fields Fields(params PropertyInfo[] properties) => new Fields(properties.Select(f => (Field)f)); /// /// Create a strongly typed string field name representation of the path to a property diff --git a/src/Nest/CommonAbstractions/Union/Union.cs b/src/Nest/CommonAbstractions/Union/Union.cs index de74bcda625..dfa196c6534 100644 --- a/src/Nest/CommonAbstractions/Union/Union.cs +++ b/src/Nest/CommonAbstractions/Union/Union.cs @@ -4,7 +4,7 @@ namespace Nest { /// - /// Represents the union of two types, and . Used + /// Represents the union of two types, and . Used /// in scenarios where an Elasticsearch API may accept more than one different input data structure. /// /// The first type @@ -12,27 +12,35 @@ namespace Nest [JsonConverter(typeof(UnionJsonConverter))] public class Union { + internal readonly int _tag; internal readonly TFirst Item1; internal readonly TSecond Item2; - internal readonly int _tag; /// - /// Creates an new instance of that encapsulates value + /// Creates an new instance of that encapsulates value /// /// The value to encapsulate - public Union(TFirst item) { Item1 = item; _tag = 0; } + public Union(TFirst item) + { + Item1 = item; + _tag = 0; + } /// - /// Creates an new instance of that encapsulates value + /// Creates an new instance of that encapsulates value /// /// The value to encapsulate - public Union(TSecond item) { Item2 = item; _tag = 1; } + public Union(TSecond item) + { + Item2 = item; + _tag = 1; + } /// - /// Runs an delegate against the encapsulated value + /// Runs an delegate against the encapsulated value /// - /// The delegate to run when this instance encapsulates an instance of - /// The delegate to run when this instance encapsulates an instance of + /// The delegate to run when this instance encapsulates an instance of + /// The delegate to run when this instance encapsulates an instance of public void Match(Action first, Action second) { switch (_tag) @@ -48,10 +56,10 @@ public void Match(Action first, Action second) } /// - /// Runs a delegate against the encapsulated value + /// Runs a delegate against the encapsulated value /// - /// The delegate to run when this instance encapsulates an instance of - /// The delegate to run when this instance encapsulates an instance of + /// The delegate to run when this instance encapsulates an instance of + /// The delegate to run when this instance encapsulates an instance of public T Match(Func first, Func second) { switch (_tag) @@ -63,6 +71,7 @@ public T Match(Func first, Func second) } public static implicit operator Union(TFirst first) => new Union(first); + public static implicit operator Union(TSecond second) => new Union(second); } } diff --git a/src/Nest/CommonAbstractions/Union/UnionJsonConverter.cs b/src/Nest/CommonAbstractions/Union/UnionJsonConverter.cs index 38d46c576ba..77abef76bf7 100644 --- a/src/Nest/CommonAbstractions/Union/UnionJsonConverter.cs +++ b/src/Nest/CommonAbstractions/Union/UnionJsonConverter.cs @@ -1,15 +1,14 @@ using System; using System.Collections.Concurrent; -using System.Linq; using System.Reflection; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace Nest { internal class UnionJsonConverter : JsonConverter { - private static readonly ConcurrentDictionary KnownTypes = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary KnownTypes = + new ConcurrentDictionary(); public override bool CanConvert(Type objectType) => true; @@ -22,11 +21,10 @@ public static UnionJsonConverterBase CreateConverter(Type t) switch (genericArguments.Length) { case 2: - conversion = typeof (UnionJsonConverter<,>).CreateGenericInstance(genericArguments) as UnionJsonConverterBase; + conversion = typeof(UnionJsonConverter<,>).CreateGenericInstance(genericArguments) as UnionJsonConverterBase; break; default: throw new Exception($"No union converter registered that takes {genericArguments.Length} type arguments for {t.Name}"); - } KnownTypes.TryAdd(t, conversion); return conversion; @@ -62,6 +60,7 @@ public bool TryRead(JsonReader reader, JsonSerializer serializer, out T v) } public abstract void WriteJson(JsonWriter writer, object v, JsonSerializer serializer); + public abstract object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer); } @@ -86,11 +85,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist Union u = null; using (var r = reader.ReadTokenWithDateParseHandlingNone().CreateReader()) { - if (this.TryRead(r, serializer, out TFirst first)) u = first; - else if (this.TryRead(r, serializer, out TSecond second)) u = second; + if (TryRead(r, serializer, out TFirst first)) u = first; + else if (TryRead(r, serializer, out TSecond second)) u = second; } return u; } - } } diff --git a/src/Nest/CommonOptions/Attributes/AlternativeEnumMemberAttribute.cs b/src/Nest/CommonOptions/Attributes/AlternativeEnumMemberAttribute.cs index 5516d9f0732..1e552b67a9c 100644 --- a/src/Nest/CommonOptions/Attributes/AlternativeEnumMemberAttribute.cs +++ b/src/Nest/CommonOptions/Attributes/AlternativeEnumMemberAttribute.cs @@ -3,7 +3,7 @@ namespace Nest { /// - /// Similar to , but allows an alternative string + /// Similar to , but allows an alternative string /// value to be specified for an enum field value. /// [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] diff --git a/src/Nest/CommonOptions/DateFormat/DateFormat.cs b/src/Nest/CommonOptions/DateFormat/DateFormat.cs index 50da3c61a06..ebfa10ddf06 100644 --- a/src/Nest/CommonOptions/DateFormat/DateFormat.cs +++ b/src/Nest/CommonOptions/DateFormat/DateFormat.cs @@ -4,159 +4,307 @@ //these const reflect their output on purpose public static class DateFormat { - ///A formatter for the number of milliseconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN_VALUE and Long.MAX_VALUE. - public const string epoch_millis = "epoch_millis"; - ///A formatter for the number of seconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN_VALUE and Long. MAX_VALUE divided by 1000 (the number of milliseconds in a second). - public const string epoch_second = "epoch_second"; - ///A basic formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyyMMdd. - public const string date_optional_time = "date_optional_time"; ///A basic formatter that combines a basic date and time, separated by a T: yyyyMMdd'T'HHmmss.SSSZ. public const string basic_date = "basic_date"; + ///A basic formatter that combines a basic date and time, separated by a T: yyyyMMdd'T'HHmmss.SSSZ. public const string basic_date_time = "basic_date_time"; + ///A basic formatter that combines a basic date and time without millis, separated by a T: yyyyMMdd'T'HHmmssZ. public const string basic_date_time_no_millis = "basic_date_time_no_millis"; + ///A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyyDDD. public const string basic_ordinal_date = "basic_ordinal_date"; + ///A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear: yyyyDDD'T'HHmmss.SSSZ. public const string basic_ordinal_date_time = "basic_ordinal_date_time"; + ///A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: yyyyDDD'T'HHmmssZ. public const string basic_ordinal_date_time_no_millis = "basic_ordinal_date_time_no_millis"; - ///A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time zone offset: HHmmss.SSSZ. - public const string basic_time = "basic_time"; - ///A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HHmmssZ. - public const string basic_time_no_millis = "basic_time_no_millis"; - ///A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time zone off set prefixed by T: 'T'HHmmss.SSSZ. + + /// + /// A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time + /// zone off set prefixed by T: 'T'HHmmss.SSSZ. + /// public const string basic_t_time = "basic_t_time"; - ///A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: 'T'HHmmssZ. + + /// + /// A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed + /// by T: 'T'HHmmssZ. + /// public const string basic_t_time_no_millis = "basic_t_time_no_millis"; + + /// + /// A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time + /// zone offset: HHmmss.SSSZ. + /// + public const string basic_time = "basic_time"; + + /// + /// A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: + /// HHmmssZ. + /// + public const string basic_time_no_millis = "basic_time_no_millis"; + ///A basic formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx'W'wwe. public const string basic_week_date = "basic_week_date"; - ///A basic formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx'W'wwe. - public const string strict_basic_week_date = "strict_basic_week_date"; + ///A basic formatter that combines a basic weekyear date and time, separated by a T: xxxx'W'wwe'T'HHmmss.SSSZ. public const string basic_week_date_time = "basic_week_date_time"; - ///A basic formatter that combines a basic weekyear date and time, separated by a T: xxxx'W'wwe'T'HHmmss.SSSZ. - public const string strict_basic_week_date_time = "strict_basic_week_date_time"; + ///A basic formatter that combines a basic weekyear date and time without millis, separated by a T: xxxx'W'wwe'T'HHmmssZ. public const string basic_week_date_time_no_millis = "basic_week_date_time_no_millis"; - ///A basic formatter that combines a basic weekyear date and time without millis, separated by a T: xxxx'W'wwe'T'HHmmssZ. - public const string strict_basic_week_date_time_no_millis = "strict_basic_week_date_time_no_millis"; + ///A formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd. public const string date = "date"; - ///A formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd. - public const string strict_date = "strict_date"; + ///A formatter that combines a full date and two digit hour of day: yyyy-MM-dd'T'HH. public const string date_hour = "date_hour"; - ///A formatter that combines a full date and two digit hour of day: yyyy-MM-dd'T'HH. - public const string strict_date_hour = "strict_date_hour"; + ///A formatter that combines a full date, two digit hour of day, and two digit minute of hour: yyyy-MM-dd'T'HH:mm. public const string date_hour_minute = "date_hour_minute"; - ///A formatter that combines a full date, two digit hour of day, and two digit minute of hour: yyyy-MM-dd'T'HH:mm. - public const string strict_date_hour_minute = "strict_date_hour_minute"; - ///A formatter that combines a full date, two digit hour of day, two digit minute of hour, and two digit second of minute: yyyy-MM-dd'T'HH:mm:ss. + + /// + /// A formatter that combines a full date, two digit hour of day, two digit minute of hour, and two digit second of minute: + /// yyyy-MM-dd'T'HH:mm:ss. + /// public const string date_hour_minute_second = "date_hour_minute_second"; - ///A formatter that combines a full date, two digit hour of day, two digit minute of hour, and two digit second of minute: yyyy-MM-dd'T'HH:mm:ss. - public const string strict_date_hour_minute_second = "strict_date_hour_minute_second"; - ///A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. + + /// + /// A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three + /// digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. + /// public const string date_hour_minute_second_fraction = "date_hour_minute_second_fraction"; - ///A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. - public const string strict_date_hour_minute_second_fraction = "strict_date_hour_minute_second_fraction"; - ///A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. + + /// + /// A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three + /// digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. + /// public const string date_hour_minute_second_millis = "date_hour_minute_second_millis"; - ///A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. - public const string strict_date_hour_minute_second_millis = "strict_date_hour_minute_second_millis"; + + ///A basic formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyyMMdd. + public const string date_optional_time = "date_optional_time"; + ///A formatter that combines a full date and time, separated by a T: yyyy-MM-dd'T'HH:mm:ss.SSSZZ. public const string date_time = "date_time"; - ///A formatter that combines a full date and time, separated by a T: yyyy-MM-dd'T'HH:mm:ss.SSSZZ. - public const string strict_date_time = "strict_date_time"; + ///A formatter that combines a full date and time without millis, separated by a T: yyyy-MM-dd'T'HH:mm:ssZZ. public const string date_time_no_millis = "date_time_no_millis"; - ///A formatter that combines a full date and time without millis, separated by a T: yyyy-MM-dd'T'HH:mm:ssZZ. - public const string strict_date_time_no_millis = "strict_date_time_no_millis"; + + /// + /// A formatter for the number of milliseconds since the epoch. Note, that this timestamp is subject to the limits of a Java + /// Long.MIN_VALUE and Long.MAX_VALUE. + /// + public const string epoch_millis = "epoch_millis"; + + /// + /// A formatter for the number of seconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN_VALUE + /// and Long. MAX_VALUE divided by 1000 (the number of milliseconds in a second). + /// + public const string epoch_second = "epoch_second"; + ///A formatter for a two digit hour of day: HH public const string hour = "hour"; - ///A formatter for a two digit hour of day: HH - public const string strict_hour = "strict_hour"; + ///A formatter for a two digit hour of day and two digit minute of hour: HH:mm. public const string hour_minute = "hour_minute"; - ///A formatter for a two digit hour of day and two digit minute of hour: HH:mm. - public const string strict_hour_minute = "strict_hour_minute"; + ///A formatter for a two digit hour of day, two digit minute of hour, and two digit second of minute: HH:mm:ss. public const string hour_minute_second = "hour_minute_second"; - ///A formatter for a two digit hour of day, two digit minute of hour, and two digit second of minute: HH:mm:ss. - public const string strict_hour_minute_second = "strict_hour_minute_second"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS. + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: + /// HH:mm:ss.SSS. + /// public const string hour_minute_second_fraction = "hour_minute_second_fraction"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS. - public const string strict_hour_minute_second_fraction = "strict_hour_minute_second_fraction"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS. + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: + /// HH:mm:ss.SSS. + /// public const string hour_minute_second_millis = "hour_minute_second_millis"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS. - public const string strict_hour_minute_second_millis = "strict_hour_minute_second_millis"; + ///A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyy-DDD. public const string ordinal_date = "ordinal_date"; - ///A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyy-DDD. - public const string strict_ordinal_date = "strict_ordinal_date"; + ///A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ss.SSSZZ. public const string ordinal_date_time = "ordinal_date_time"; + + /// + /// A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: + /// yyyy-DDD'T'HH:mm:ssZZ. + /// + public const string ordinal_date_time_no_millis = "ordinal_date_time_no_millis"; + + ///A basic formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx'W'wwe. + public const string strict_basic_week_date = "strict_basic_week_date"; + + ///A basic formatter that combines a basic weekyear date and time, separated by a T: xxxx'W'wwe'T'HHmmss.SSSZ. + public const string strict_basic_week_date_time = "strict_basic_week_date_time"; + + ///A basic formatter that combines a basic weekyear date and time without millis, separated by a T: xxxx'W'wwe'T'HHmmssZ. + public const string strict_basic_week_date_time_no_millis = "strict_basic_week_date_time_no_millis"; + + ///A formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd. + public const string strict_date = "strict_date"; + + ///A formatter that combines a full date and two digit hour of day: yyyy-MM-dd'T'HH. + public const string strict_date_hour = "strict_date_hour"; + + ///A formatter that combines a full date, two digit hour of day, and two digit minute of hour: yyyy-MM-dd'T'HH:mm. + public const string strict_date_hour_minute = "strict_date_hour_minute"; + + /// + /// A formatter that combines a full date, two digit hour of day, two digit minute of hour, and two digit second of minute: + /// yyyy-MM-dd'T'HH:mm:ss. + /// + public const string strict_date_hour_minute_second = "strict_date_hour_minute_second"; + + /// + /// A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three + /// digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. + /// + public const string strict_date_hour_minute_second_fraction = "strict_date_hour_minute_second_fraction"; + + /// + /// A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three + /// digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS. + /// + public const string strict_date_hour_minute_second_millis = "strict_date_hour_minute_second_millis"; + + ///A formatter that combines a full date and time, separated by a T: yyyy-MM-dd'T'HH:mm:ss.SSSZZ. + public const string strict_date_time = "strict_date_time"; + + ///A formatter that combines a full date and time without millis, separated by a T: yyyy-MM-dd'T'HH:mm:ssZZ. + public const string strict_date_time_no_millis = "strict_date_time_no_millis"; + + ///A formatter for a two digit hour of day: HH + public const string strict_hour = "strict_hour"; + + ///A formatter for a two digit hour of day and two digit minute of hour: HH:mm. + public const string strict_hour_minute = "strict_hour_minute"; + + ///A formatter for a two digit hour of day, two digit minute of hour, and two digit second of minute: HH:mm:ss. + public const string strict_hour_minute_second = "strict_hour_minute_second"; + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: + /// HH:mm:ss.SSS. + /// + public const string strict_hour_minute_second_fraction = "strict_hour_minute_second_fraction"; + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: + /// HH:mm:ss.SSS. + /// + public const string strict_hour_minute_second_millis = "strict_hour_minute_second_millis"; + + ///A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyy-DDD. + public const string strict_ordinal_date = "strict_ordinal_date"; + ///A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ss.SSSZZ. public const string strict_ordinal_date_time = "strict_ordinal_date_time"; - ///A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ssZZ. - public const string ordinal_date_time_no_millis = "ordinal_date_time_no_millis"; - ///A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ssZZ. + + /// + /// A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: + /// yyyy-DDD'T'HH:mm:ssZZ. + /// public const string strict_ordinal_date_time_no_millis = "strict_ordinal_date_time_no_millis"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset: HH:mm:ss.SSSZZ. - public const string time = "time"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset: HH:mm:ss.SSSZZ. + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and + /// time zone offset prefixed by T: 'T'HH:mm:ss.SSSZZ. + /// + public const string strict_t_time = "strict_t_time"; + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: + /// 'T'HH:mm:ssZZ. + /// + public const string strict_t_time_no_millis = "strict_t_time_no_millis"; + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and + /// time zone offset: HH:mm:ss.SSSZZ. + /// public const string strict_time = "strict_time"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HH:mm:ssZZ. - public const string time_no_millis = "time_no_millis"; + ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HH:mm:ssZZ. public const string strict_time_no_millis = "strict_time_no_millis"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset prefixed by T: 'T'HH:mm:ss.SSSZZ. + + ///A formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e. + public const string strict_week_date = "strict_week_date"; + + ///A formatter that combines a full weekyear date and time, separated by a T: xxxx-'W'ww-e'T'HH:mm:ss.SSSZZ. + public const string strict_week_date_time = "strict_week_date_time"; + + ///A formatter that combines a full weekyear date and time without millis, separated by a T: xxxx-'W'ww-e'T'HH:mm:ssZZ. + public const string strict_week_date_time_no_millis = "strict_week_date_time_no_millis"; + + ///A formatter for a four digit weekyear: xxxx. + public const string strict_weekyear = "strict_weekyear"; + + ///A formatter for a four digit weekyear and two digit week of weekyear: xxxx-'W'ww. + public const string strict_weekyear_week = "strict_weekyear_week"; + + ///A formatter for a four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e. + public const string strict_weekyear_week_day = "strict_weekyear_week_day"; + + ///A formatter for a four digit year: yyyy. + public const string strict_year = "strict_year"; + + ///A formatter for a four digit year and two digit month of year: yyyy-MM. + public const string strict_year_month = "strict_year_month"; + + ///A formatter for a four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd. + public const string strict_year_month_day = "strict_year_month_day"; + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and + /// time zone offset prefixed by T: 'T'HH:mm:ss.SSSZZ. + /// public const string t_time = "t_time"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset prefixed by T: 'T'HH:mm:ss.SSSZZ. - public const string strict_t_time = "strict_t_time"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: 'T'HH:mm:ssZZ. + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: + /// 'T'HH:mm:ssZZ. + /// public const string t_time_no_millis = "t_time_no_millis"; - ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: 'T'HH:mm:ssZZ. - public const string strict_t_time_no_millis = "strict_t_time_no_millis"; + + /// + /// A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and + /// time zone offset: HH:mm:ss.SSSZZ. + /// + public const string time = "time"; + + ///A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HH:mm:ssZZ. + public const string time_no_millis = "time_no_millis"; + ///A formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e. public const string week_date = "week_date"; - ///A formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e. - public const string strict_week_date = "strict_week_date"; + ///A formatter that combines a full weekyear date and time, separated by a T: xxxx-'W'ww-e'T'HH:mm:ss.SSSZZ. public const string week_date_time = "week_date_time"; - ///A formatter that combines a full weekyear date and time, separated by a T: xxxx-'W'ww-e'T'HH:mm:ss.SSSZZ. - public const string strict_week_date_time = "strict_week_date_time"; + ///A formatter that combines a full weekyear date and time without millis, separated by a T: xxxx-'W'ww-e'T'HH:mm:ssZZ. public const string week_date_time_no_millis = "week_date_time_no_millis"; - ///A formatter that combines a full weekyear date and time without millis, separated by a T: xxxx-'W'ww-e'T'HH:mm:ssZZ. - public const string strict_week_date_time_no_millis = "strict_week_date_time_no_millis"; + ///A formatter for a four digit weekyear: xxxx. public const string weekyear = "weekyear"; - ///A formatter for a four digit weekyear: xxxx. - public const string strict_weekyear = "strict_weekyear"; + ///A formatter for a four digit weekyear and two digit week of weekyear: xxxx-'W'ww. public const string weekyear_week = "weekyear_week"; - ///A formatter for a four digit weekyear and two digit week of weekyear: xxxx-'W'ww. - public const string strict_weekyear_week = "strict_weekyear_week"; + ///A formatter for a four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e. public const string weekyear_week_day = "weekyear_week_day"; - ///A formatter for a four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e. - public const string strict_weekyear_week_day = "strict_weekyear_week_day"; + ///A formatter for a four digit year: yyyy. public const string year = "year"; - ///A formatter for a four digit year: yyyy. - public const string strict_year = "strict_year"; + ///A formatter for a four digit year and two digit month of year: yyyy-MM. public const string year_month = "year_month"; - ///A formatter for a four digit year and two digit month of year: yyyy-MM. - public const string strict_year_month = "strict_year_month"; + ///A formatter for a four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd. public const string year_month_day = "year_month_day"; - ///A formatter for a four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd. - public const string strict_year_month_day = "strict_year_month_day"; } } diff --git a/src/Nest/CommonOptions/DateMath/DateMath.cs b/src/Nest/CommonOptions/DateMath/DateMath.cs index 08f9680afe7..8a2986f20e6 100644 --- a/src/Nest/CommonOptions/DateMath/DateMath.cs +++ b/src/Nest/CommonOptions/DateMath/DateMath.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; -using Elasticsearch.Net; using Newtonsoft.Json; namespace Nest @@ -14,30 +13,31 @@ public interface IDateMath DateMathTimeUnit? Round { get; } } - [JsonConverter(typeof(DateMath.Json))] + [JsonConverter(typeof(Json))] public abstract class DateMath : IDateMath { private static readonly Regex DateMathRegex = new Regex(@"^(?now|.+(?:\|\||$))(?(?:(?:\+|\-)[^\/]*))?(?\/(?:y|M|w|d|h|m|s))?$"); - Union IDateMath.Anchor => Anchor; - DateMathTimeUnit? IDateMath.Round => Round; - IList> IDateMath.Ranges { get; } = new List>(); - - protected IDateMath Self => this; - protected Union Anchor; protected DateMathTimeUnit? Round; public static DateMathExpression Now => new DateMathExpression("now"); + protected IDateMath Self => this; + + Union IDateMath.Anchor => Anchor; + IList> IDateMath.Ranges { get; } = new List>(); + DateMathTimeUnit? IDateMath.Round => Round; + public static DateMathExpression Anchored(DateTime anchor) => new DateMathExpression(anchor); public static DateMathExpression Anchored(string dateAnchor) => new DateMathExpression(dateAnchor); - public static implicit operator DateMath(DateTime dateTime) => DateMath.Anchored(dateTime); - public static implicit operator DateMath(string dateMath) => DateMath.FromString(dateMath); + public static implicit operator DateMath(DateTime dateTime) => Anchored(dateTime); + + public static implicit operator DateMath(string dateMath) => FromString(dateMath); public static DateMath FromString(string dateMath) { @@ -112,11 +112,12 @@ public override void WriteJson(JsonWriter writer, DateMath value, JsonSerializer public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.String) - return DateMath.FromString(reader.Value as string); + return FromString(reader.Value as string); + if (reader.TokenType == JsonToken.Date) { var d = reader.Value as DateTime?; - return d.HasValue ? DateMath.Anchored(d.Value) : null; + return d.HasValue ? Anchored(d.Value) : null; } return null; } diff --git a/src/Nest/CommonOptions/DateMath/DateMathExpression.cs b/src/Nest/CommonOptions/DateMath/DateMathExpression.cs index f3057b37db8..daefa90e92f 100644 --- a/src/Nest/CommonOptions/DateMath/DateMathExpression.cs +++ b/src/Nest/CommonOptions/DateMath/DateMathExpression.cs @@ -4,15 +4,16 @@ namespace Nest { public class DateMathExpression : DateMath { - public DateMathExpression(string anchor) { this.Anchor = anchor; } - public DateMathExpression(DateTime anchor) { this.Anchor = anchor; } + public DateMathExpression(string anchor) => Anchor = anchor; + + public DateMathExpression(DateTime anchor) => Anchor = anchor; public DateMathExpression(Union anchor, DateMathTime range, DateMathOperation operation) { anchor.ThrowIfNull(nameof(anchor)); range.ThrowIfNull(nameof(range)); operation.ThrowIfNull(nameof(operation)); - this.Anchor = anchor; + Anchor = anchor; Self.Ranges.Add(Tuple.Create(operation, range)); } @@ -36,7 +37,7 @@ public DateMathExpression Operation(DateMathTime expression, DateMathOperation o public DateMath RoundTo(DateMathTimeUnit round) { - this.Round = round; + Round = round; return this; } } diff --git a/src/Nest/CommonOptions/DateMath/DateMathOperation.cs b/src/Nest/CommonOptions/DateMath/DateMathOperation.cs index 64ab47aa05e..e440720022e 100644 --- a/src/Nest/CommonOptions/DateMath/DateMathOperation.cs +++ b/src/Nest/CommonOptions/DateMath/DateMathOperation.cs @@ -10,6 +10,7 @@ public enum DateMathOperation { [EnumMember(Value = "+")] Add, + [EnumMember(Value = "-")] Subtract } @@ -27,7 +28,6 @@ public static string GetStringValue(this DateMathOperation value) default: throw new ArgumentOutOfRangeException(nameof(value), value, null); } - } } } diff --git a/src/Nest/CommonOptions/DateMath/DateMathTime.cs b/src/Nest/CommonOptions/DateMath/DateMathTime.cs index 6da281169f7..cfcb9398205 100644 --- a/src/Nest/CommonOptions/DateMath/DateMathTime.cs +++ b/src/Nest/CommonOptions/DateMath/DateMathTime.cs @@ -1,24 +1,22 @@ using System; -using System.Diagnostics; using System.Globalization; using System.Text.RegularExpressions; -using Newtonsoft.Json; namespace Nest { /// - /// A time representation for use within expressions. + /// A time representation for use within expressions. /// public class DateMathTime : IComparable, IEquatable { - private const int MonthsInAYear = 12; - private const double MillisecondsInAYearApproximate = MillisecondsInADay * 365; - private const double MillisecondsInAMonthApproximate = MillisecondsInAYearApproximate / MonthsInAYear; - private const double MillisecondsInAWeek = MillisecondsInADay * 7; private const double MillisecondsInADay = MillisecondsInAnHour * 24; - private const double MillisecondsInAnHour = MillisecondsInAMinute * 60; private const double MillisecondsInAMinute = MillisecondsInASecond * 60; + private const double MillisecondsInAMonthApproximate = MillisecondsInAYearApproximate / MonthsInAYear; + private const double MillisecondsInAnHour = MillisecondsInAMinute * 60; private const double MillisecondsInASecond = 1000; + private const double MillisecondsInAWeek = MillisecondsInADay * 7; + private const double MillisecondsInAYearApproximate = MillisecondsInADay * 365; + private const int MonthsInAYear = 12; private static readonly Regex ExpressionRegex = new Regex(@"^ @@ -34,41 +32,27 @@ public class DateMathTime : IComparable, IEquatable private double _approximateSeconds; /// - /// The numeric time factor - /// - public int Factor { get; private set; } - - /// - /// The time units - /// - public DateMathTimeUnit Interval { get; private set; } - - public static implicit operator DateMathTime(TimeSpan span) => new DateMathTime(span); - public static implicit operator DateMathTime(double milliseconds) => new DateMathTime(milliseconds); - public static implicit operator DateMathTime(string expression) => new DateMathTime(expression); - - /// - /// Instantiates a new instance of from a TimeSpan. + /// Instantiates a new instance of from a TimeSpan. /// Rounding can be specified to determine how fractional second values should be rounded. /// public DateMathTime(TimeSpan timeSpan, MidpointRounding rounding = MidpointRounding.AwayFromZero) : this(timeSpan.TotalMilliseconds, rounding) { } /// - /// Instantiates a new instance of from a milliseconds value. + /// Instantiates a new instance of from a milliseconds value. /// Rounding can be specified to determine how fractional second values should be rounded. /// public DateMathTime(double milliseconds, MidpointRounding rounding = MidpointRounding.AwayFromZero) => SetWholeFactorIntervalAndSeconds(milliseconds, rounding); /// - /// Instantiates a new instance of from a factor and interval. + /// Instantiates a new instance of from a factor and interval. /// public DateMathTime(int factor, DateMathTimeUnit interval) => SetWholeFactorIntervalAndSeconds(factor, interval, MidpointRounding.AwayFromZero); /// - /// Instantiates a new instance of from the timeUnit string expression. + /// Instantiates a new instance of from the timeUnit string expression. /// Rounding can be specified to determine how fractional second values should be rounded. /// public DateMathTime(string timeUnit, MidpointRounding rounding = MidpointRounding.AwayFromZero) @@ -80,7 +64,7 @@ public DateMathTime(string timeUnit, MidpointRounding rounding = MidpointRoundin if (!match.Success) throw new ArgumentException($"Expression '{timeUnit}' string is invalid", nameof(timeUnit)); var factor = match.Groups["factor"].Value; - if (!double.TryParse(factor, NumberStyles.Any ,CultureInfo.InvariantCulture, out double fraction)) + if (!double.TryParse(factor, NumberStyles.Any, CultureInfo.InvariantCulture, out var fraction)) throw new ArgumentException($"Expression '{timeUnit}' contains invalid factor: {factor}", nameof(timeUnit)); var intervalValue = match.Groups["interval"].Value; @@ -89,7 +73,7 @@ public DateMathTime(string timeUnit, MidpointRounding rounding = MidpointRoundin switch (intervalValue) { case "M": - interval= DateMathTimeUnit.Month; + interval = DateMathTimeUnit.Month; break; case "m": interval = DateMathTimeUnit.Minute; @@ -102,6 +86,39 @@ public DateMathTime(string timeUnit, MidpointRounding rounding = MidpointRoundin SetWholeFactorIntervalAndSeconds(fraction, interval, rounding); } + /// + /// The numeric time factor + /// + public int Factor { get; private set; } + + /// + /// The time units + /// + public DateMathTimeUnit Interval { get; private set; } + + public int CompareTo(DateMathTime other) + { + if (other == null) return 1; + if (_approximateSeconds == other._approximateSeconds) return 0; + if (_approximateSeconds < other._approximateSeconds) return -1; + + return 1; + } + + public bool Equals(DateMathTime other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return _approximateSeconds == other._approximateSeconds; + } + + public static implicit operator DateMathTime(TimeSpan span) => new DateMathTime(span); + + public static implicit operator DateMathTime(double milliseconds) => new DateMathTime(milliseconds); + + public static implicit operator DateMathTime(string expression) => new DateMathTime(expression); + private void SetWholeFactorIntervalAndSeconds(double factor, DateMathTimeUnit interval, MidpointRounding rounding) { var fraction = factor; @@ -110,30 +127,30 @@ private void SetWholeFactorIntervalAndSeconds(double factor, DateMathTimeUnit in // if the factor is already a whole number then use it if (TryGetIntegerGreaterThanZero(fraction, out var whole)) { - this.Factor = whole; - this.Interval = interval; + Factor = whole; + Interval = interval; switch (interval) { case DateMathTimeUnit.Second: - this._approximateSeconds = whole; + _approximateSeconds = whole; break; case DateMathTimeUnit.Minute: - this._approximateSeconds = whole * (MillisecondsInAMinute / MillisecondsInASecond); + _approximateSeconds = whole * (MillisecondsInAMinute / MillisecondsInASecond); break; case DateMathTimeUnit.Hour: - this._approximateSeconds = whole * (MillisecondsInAnHour / MillisecondsInASecond); + _approximateSeconds = whole * (MillisecondsInAnHour / MillisecondsInASecond); break; case DateMathTimeUnit.Day: - this._approximateSeconds = whole * (MillisecondsInADay / MillisecondsInASecond); + _approximateSeconds = whole * (MillisecondsInADay / MillisecondsInASecond); break; case DateMathTimeUnit.Week: - this._approximateSeconds = whole * (MillisecondsInAWeek / MillisecondsInASecond); + _approximateSeconds = whole * (MillisecondsInAWeek / MillisecondsInASecond); break; case DateMathTimeUnit.Month: - this._approximateSeconds = whole * (MillisecondsInAMonthApproximate / MillisecondsInASecond); + _approximateSeconds = whole * (MillisecondsInAMonthApproximate / MillisecondsInASecond); break; case DateMathTimeUnit.Year: - this._approximateSeconds = whole * (MillisecondsInAYearApproximate / MillisecondsInASecond); + _approximateSeconds = whole * (MillisecondsInAYearApproximate / MillisecondsInASecond); break; default: throw new ArgumentOutOfRangeException(nameof(interval), interval, null); @@ -161,9 +178,9 @@ private void SetWholeFactorIntervalAndSeconds(double factor, DateMathTimeUnit in case DateMathTimeUnit.Month: if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = interval; - this._approximateSeconds = whole * (MillisecondsInAMonthApproximate / MillisecondsInASecond); + Factor = whole; + Interval = interval; + _approximateSeconds = whole * (MillisecondsInAMonthApproximate / MillisecondsInASecond); return; } @@ -172,18 +189,18 @@ private void SetWholeFactorIntervalAndSeconds(double factor, DateMathTimeUnit in case DateMathTimeUnit.Year: if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = interval; - this._approximateSeconds = whole * (MillisecondsInAYearApproximate / MillisecondsInASecond); + Factor = whole; + Interval = interval; + _approximateSeconds = whole * (MillisecondsInAYearApproximate / MillisecondsInASecond); return; } fraction = fraction * MonthsInAYear; if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = DateMathTimeUnit.Month; - this._approximateSeconds = whole * (MillisecondsInAMonthApproximate / MillisecondsInASecond); + Factor = whole; + Interval = DateMathTimeUnit.Month; + _approximateSeconds = whole * (MillisecondsInAMonthApproximate / MillisecondsInASecond); return; } milliseconds = factor * MillisecondsInAYearApproximate; @@ -205,9 +222,9 @@ private void SetWholeFactorIntervalAndSeconds(double milliseconds, MidpointRound fraction = milliseconds / MillisecondsInAWeek; if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = DateMathTimeUnit.Week; - this._approximateSeconds = Factor * (MillisecondsInAWeek / MillisecondsInASecond); + Factor = whole; + Interval = DateMathTimeUnit.Week; + _approximateSeconds = Factor * (MillisecondsInAWeek / MillisecondsInASecond); return; } } @@ -216,9 +233,9 @@ private void SetWholeFactorIntervalAndSeconds(double milliseconds, MidpointRound fraction = milliseconds / MillisecondsInADay; if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = DateMathTimeUnit.Day; - this._approximateSeconds = Factor * (MillisecondsInADay / MillisecondsInASecond); + Factor = whole; + Interval = DateMathTimeUnit.Day; + _approximateSeconds = Factor * (MillisecondsInADay / MillisecondsInASecond); return; } } @@ -227,9 +244,9 @@ private void SetWholeFactorIntervalAndSeconds(double milliseconds, MidpointRound fraction = milliseconds / MillisecondsInAnHour; if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = DateMathTimeUnit.Hour; - this._approximateSeconds = Factor * (MillisecondsInAnHour / MillisecondsInASecond); + Factor = whole; + Interval = DateMathTimeUnit.Hour; + _approximateSeconds = Factor * (MillisecondsInAnHour / MillisecondsInASecond); return; } } @@ -238,9 +255,9 @@ private void SetWholeFactorIntervalAndSeconds(double milliseconds, MidpointRound fraction = milliseconds / MillisecondsInAMinute; if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = DateMathTimeUnit.Minute; - this._approximateSeconds = Factor * (MillisecondsInAMinute / MillisecondsInASecond); + Factor = whole; + Interval = DateMathTimeUnit.Minute; + _approximateSeconds = Factor * (MillisecondsInAMinute / MillisecondsInASecond); return; } } @@ -249,25 +266,17 @@ private void SetWholeFactorIntervalAndSeconds(double milliseconds, MidpointRound fraction = milliseconds / MillisecondsInASecond; if (TryGetIntegerGreaterThanZero(fraction, out whole)) { - this.Factor = whole; - this.Interval = DateMathTimeUnit.Second; - this._approximateSeconds = Factor; + Factor = whole; + Interval = DateMathTimeUnit.Second; + _approximateSeconds = Factor; return; } } // round to nearest second, using specified rounding - this.Factor = Convert.ToInt32(Math.Round(milliseconds / MillisecondsInASecond, rounding)); - this.Interval = DateMathTimeUnit.Second; - this._approximateSeconds = Factor; - } - - public int CompareTo(DateMathTime other) - { - if (other == null) return 1; - if (this._approximateSeconds == other._approximateSeconds) return 0; - if (this._approximateSeconds < other._approximateSeconds) return -1; - return 1; + Factor = Convert.ToInt32(Math.Round(milliseconds / MillisecondsInASecond, rounding)); + Interval = DateMathTimeUnit.Second; + _approximateSeconds = Factor; } private static bool TryGetIntegerGreaterThanZero(double d, out int value) @@ -283,9 +292,11 @@ private static bool TryGetIntegerGreaterThanZero(double d, out int value) } public static bool operator <(DateMathTime left, DateMathTime right) => left.CompareTo(right) < 0; + public static bool operator <=(DateMathTime left, DateMathTime right) => left.CompareTo(right) < 0 || left.Equals(right); public static bool operator >(DateMathTime left, DateMathTime right) => left.CompareTo(right) > 0; + public static bool operator >=(DateMathTime left, DateMathTime right) => left.CompareTo(right) > 0 || left.Equals(right); public static bool operator ==(DateMathTime left, DateMathTime right) => @@ -293,23 +304,17 @@ private static bool TryGetIntegerGreaterThanZero(double d, out int value) public static bool operator !=(DateMathTime left, DateMathTime right) => !(left == right); - public override string ToString() => this.Factor + this.Interval.GetStringValue(); - - public bool Equals(DateMathTime other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return this._approximateSeconds == other._approximateSeconds; - } + public override string ToString() => Factor + Interval.GetStringValue(); public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((DateMathTime) obj); + if (obj.GetType() != GetType()) return false; + + return Equals((DateMathTime)obj); } - public override int GetHashCode() => this._approximateSeconds.GetHashCode(); + public override int GetHashCode() => _approximateSeconds.GetHashCode(); } } diff --git a/src/Nest/CommonOptions/DateMath/DateMathTimeUnit.cs b/src/Nest/CommonOptions/DateMath/DateMathTimeUnit.cs index f3cba059615..b190b18600c 100644 --- a/src/Nest/CommonOptions/DateMath/DateMathTimeUnit.cs +++ b/src/Nest/CommonOptions/DateMath/DateMathTimeUnit.cs @@ -9,16 +9,22 @@ public enum DateMathTimeUnit { [EnumMember(Value = "s")] Second, + [EnumMember(Value = "m")] Minute, + [EnumMember(Value = "h")] Hour, + [EnumMember(Value = "d")] Day, + [EnumMember(Value = "w")] Week, + [EnumMember(Value = "M")] Month, + [EnumMember(Value = "y")] Year } diff --git a/src/Nest/CommonOptions/Failures/BulkError.cs b/src/Nest/CommonOptions/Failures/BulkError.cs index 09dee1933e9..0e7036dd71f 100644 --- a/src/Nest/CommonOptions/Failures/BulkError.cs +++ b/src/Nest/CommonOptions/Failures/BulkError.cs @@ -7,15 +7,13 @@ namespace Nest [ContractJsonConverter(typeof(ErrorCauseJsonConverter))] public class BulkError : Error { - public string Index => this.Metadata?.Index; + public string Index => Metadata?.Index; - public int Shard => this.Metadata.Shard.GetValueOrDefault(); + public int Shard => Metadata.Shard.GetValueOrDefault(); public override string ToString() { - var cause = (CausedBy != null) ? - $" CausedBy:\n{CausedBy}" : - string.Empty; + var cause = CausedBy != null ? $" CausedBy:\n{CausedBy}" : string.Empty; return $"Type: {Type} Reason: \"{Reason}\"{cause}"; } diff --git a/src/Nest/CommonOptions/Fuzziness/Fuzziness.cs b/src/Nest/CommonOptions/Fuzziness/Fuzziness.cs index b005701838d..1e38b0548c1 100644 --- a/src/Nest/CommonOptions/Fuzziness/Fuzziness.cs +++ b/src/Nest/CommonOptions/Fuzziness/Fuzziness.cs @@ -6,12 +6,12 @@ public class Fuzziness : IFuzziness private int? _editDistance; private double? _ratio; - bool IFuzziness.Auto => this._auto; - int? IFuzziness.EditDistance => this._editDistance; - double? IFuzziness.Ratio => this._ratio; - public static Fuzziness Auto => new Fuzziness { _auto = true }; + bool IFuzziness.Auto => _auto; + int? IFuzziness.EditDistance => _editDistance; + double? IFuzziness.Ratio => _ratio; + public static Fuzziness EditDistance(int distance) => new Fuzziness { _editDistance = distance }; public static Fuzziness Ratio(double ratio) => new Fuzziness { _ratio = ratio }; diff --git a/src/Nest/CommonOptions/Fuzziness/FuzzinessJsonConverter.cs b/src/Nest/CommonOptions/Fuzziness/FuzzinessJsonConverter.cs index a284bfae6f9..e0f2c9fa2dd 100644 --- a/src/Nest/CommonOptions/Fuzziness/FuzzinessJsonConverter.cs +++ b/src/Nest/CommonOptions/Fuzziness/FuzzinessJsonConverter.cs @@ -5,23 +5,25 @@ namespace Nest { internal class FuzzinessJsonConverter : JsonConverter { + public override bool CanRead => true; public override bool CanWrite => true; + public override bool CanConvert(Type objectType) => true; - public override bool CanRead => true; public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var v = value as IFuzziness; - if (v.Auto) writer.WriteValue("AUTO"); - else if (v.EditDistance.HasValue) writer.WriteValue(v.EditDistance.Value); + if (v.Auto) writer.WriteValue("AUTO"); + else if (v.EditDistance.HasValue) writer.WriteValue(v.EditDistance.Value); else if (v.Ratio.HasValue) writer.WriteValue(v.Ratio.Value); - else writer.WriteNull(); + else writer.WriteNull(); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.String) return Fuzziness.Auto; + if (reader.TokenType == JsonToken.Integer) { var editDistance = Convert.ToInt32(reader.Value); @@ -34,6 +36,5 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } return null; } - } } diff --git a/src/Nest/CommonOptions/Fuzziness/IFuzziness.cs b/src/Nest/CommonOptions/Fuzziness/IFuzziness.cs index ab283986a76..61d7148e7f1 100644 --- a/src/Nest/CommonOptions/Fuzziness/IFuzziness.cs +++ b/src/Nest/CommonOptions/Fuzziness/IFuzziness.cs @@ -1,13 +1,12 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { [JsonConverter(typeof(FuzzinessJsonConverter))] public interface IFuzziness { - bool Auto { get; } - int? EditDistance { get; } - double? Ratio { get; } + bool Auto { get; } + int? EditDistance { get; } + double? Ratio { get; } } } diff --git a/src/Nest/CommonOptions/Geo/Distance.cs b/src/Nest/CommonOptions/Geo/Distance.cs index ed6edad5d38..5e8b61afde8 100644 --- a/src/Nest/CommonOptions/Geo/Distance.cs +++ b/src/Nest/CommonOptions/Geo/Distance.cs @@ -8,17 +8,15 @@ namespace Nest [JsonConverter(typeof(DistanceJsonConverter))] public class Distance { - private static readonly Regex _distanceUnitRegex = new Regex(@"^(?\d+(?:\.\d+)?)(?\D+)?$", RegexOptions.Compiled | RegexOptions.ExplicitCapture); - - public double Precision { get; private set; } - public DistanceUnit Unit { get; private set; } + private static readonly Regex _distanceUnitRegex = + new Regex(@"^(?\d+(?:\.\d+)?)(?\D+)?$", RegexOptions.Compiled | RegexOptions.ExplicitCapture); public Distance(double distance) : this(distance, DistanceUnit.Meters) { } - public Distance(double distance, DistanceUnit unit) + public Distance(double distance, DistanceUnit unit) { - this.Precision = distance; - this.Unit = unit; + Precision = distance; + Unit = unit; } public Distance(string distanceUnit) @@ -32,35 +30,39 @@ public Distance(string distanceUnit) var precision = double.Parse(match.Groups["precision"].Value, NumberStyles.Any, CultureInfo.InvariantCulture); var unit = match.Groups["unit"].Value; - this.Precision = precision; + Precision = precision; if (string.IsNullOrEmpty(unit)) { - this.Unit = DistanceUnit.Meters; + Unit = DistanceUnit.Meters; return; } var unitMeasure = unit.ToEnum(); - if (unitMeasure == null) - { - throw new InvalidCastException($"cannot parse {typeof(DistanceUnit).Name} from string '{unit}'"); - } + if (unitMeasure == null) throw new InvalidCastException($"cannot parse {typeof(DistanceUnit).Name} from string '{unit}'"); - this.Unit = unitMeasure.Value; + Unit = unitMeasure.Value; } + public double Precision { get; private set; } + public DistanceUnit Unit { get; private set; } + public static Distance Inches(double inches) => new Distance(inches, DistanceUnit.Inch); + public static Distance Yards(double yards) => new Distance(yards, DistanceUnit.Yards); + public static Distance Miles(double miles) => new Distance(miles, DistanceUnit.Miles); + public static Distance Kilometers(double kilometers) => new Distance(kilometers, DistanceUnit.Kilometers); + public static Distance Meters(double meters) => new Distance(meters, DistanceUnit.Meters); + public static Distance Centimeters(double centimeters) => new Distance(centimeters, DistanceUnit.Centimeters); + public static Distance Millimeters(double millimeter) => new Distance(millimeter, DistanceUnit.Millimeters); + public static Distance NauticalMiles(double nauticalMiles) => new Distance(nauticalMiles, DistanceUnit.NauticalMiles); - - public static implicit operator Distance(string distanceUnit) - { - return new Distance(distanceUnit); - } + + public static implicit operator Distance(string distanceUnit) => new Distance(distanceUnit); } } diff --git a/src/Nest/CommonOptions/Geo/DistanceJsonConverter.cs b/src/Nest/CommonOptions/Geo/DistanceJsonConverter.cs index 9aa43bb19e3..21b810fe131 100644 --- a/src/Nest/CommonOptions/Geo/DistanceJsonConverter.cs +++ b/src/Nest/CommonOptions/Geo/DistanceJsonConverter.cs @@ -29,15 +29,13 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.String) return null; + var v = reader.Value as string; if (v == null) return null; return new Distance(v); } - public override bool CanConvert(Type objectType) - { - return true; - } + public override bool CanConvert(Type objectType) => true; } } diff --git a/src/Nest/CommonOptions/Geo/DistanceUnit.cs b/src/Nest/CommonOptions/Geo/DistanceUnit.cs index 2a1113eaeb4..5d3d90147ed 100644 --- a/src/Nest/CommonOptions/Geo/DistanceUnit.cs +++ b/src/Nest/CommonOptions/Geo/DistanceUnit.cs @@ -9,21 +9,29 @@ public enum DistanceUnit { [EnumMember(Value = "in")] Inch, + [EnumMember(Value = "ft")] Feet, + [EnumMember(Value = "yd")] Yards, + [EnumMember(Value = "mi")] Miles, + [EnumMember(Value = "nmi")] [AlternativeEnumMember("NM")] NauticalMiles, + [EnumMember(Value = "km")] Kilometers, + [EnumMember(Value = "m")] Meters, + [EnumMember(Value = "cm")] Centimeters, + [EnumMember(Value = "mm")] Millimeters } diff --git a/src/Nest/CommonOptions/Geo/GeoDistanceType.cs b/src/Nest/CommonOptions/Geo/GeoDistanceType.cs index fdd56c2ef57..0d31bb76ee8 100644 --- a/src/Nest/CommonOptions/Geo/GeoDistanceType.cs +++ b/src/Nest/CommonOptions/Geo/GeoDistanceType.cs @@ -9,6 +9,7 @@ public enum GeoDistanceType { [EnumMember(Value = "arc")] Arc, + [EnumMember(Value = "plane")] Plane } diff --git a/src/Nest/CommonOptions/Geo/GeoShapeRelation.cs b/src/Nest/CommonOptions/Geo/GeoShapeRelation.cs index 7a6be8b61de..d109d943898 100644 --- a/src/Nest/CommonOptions/Geo/GeoShapeRelation.cs +++ b/src/Nest/CommonOptions/Geo/GeoShapeRelation.cs @@ -9,10 +9,13 @@ public enum GeoShapeRelation { [EnumMember(Value = "intersects")] Intersects, + [EnumMember(Value = "disjoint")] Disjoint, + [EnumMember(Value = "within")] Within, + [EnumMember(Value = "contains")] Contains } diff --git a/src/Nest/CommonOptions/Hit/ShardStatistics.cs b/src/Nest/CommonOptions/Hit/ShardStatistics.cs index 3d5d034ffb1..43a14b165ac 100644 --- a/src/Nest/CommonOptions/Hit/ShardStatistics.cs +++ b/src/Nest/CommonOptions/Hit/ShardStatistics.cs @@ -7,17 +7,16 @@ namespace Nest [JsonObject] public class ShardStatistics { - [JsonProperty] - public int Total { get; internal set; } - - [JsonProperty] - public int Successful { get; internal set; } - [JsonProperty] public int Failed { get; internal set; } [JsonProperty("failures")] public IReadOnlyCollection Failures { get; internal set; } = EmptyReadOnly.Collection; + [JsonProperty] + public int Successful { get; internal set; } + + [JsonProperty] + public int Total { get; internal set; } } } diff --git a/src/Nest/CommonOptions/MinimumShouldMatch/MinimumShouldMatch.cs b/src/Nest/CommonOptions/MinimumShouldMatch/MinimumShouldMatch.cs index 88ff4f01fe6..5523a9af4cb 100644 --- a/src/Nest/CommonOptions/MinimumShouldMatch/MinimumShouldMatch.cs +++ b/src/Nest/CommonOptions/MinimumShouldMatch/MinimumShouldMatch.cs @@ -11,31 +11,32 @@ public MinimumShouldMatch(int count) : base(count) { } public MinimumShouldMatch(string percentage) : base(percentage) { } public static MinimumShouldMatch Fixed(int count) => count; + public static MinimumShouldMatch Percentage(double percentage) => $"{percentage}%"; public static implicit operator MinimumShouldMatch(string first) => new MinimumShouldMatch(first); + public static implicit operator MinimumShouldMatch(int second) => new MinimumShouldMatch(second); + public static implicit operator MinimumShouldMatch(double second) => Percentage(second); } - internal class MinimumShouldMatchJsonConverter :JsonConverter + internal class MinimumShouldMatchJsonConverter : JsonConverter { + public static UnionJsonConverter Unionconverter = new UnionJsonConverter(); public override bool CanRead => true; public override bool CanWrite => true; - public static UnionJsonConverter Unionconverter = new UnionJsonConverter(); - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var union = Unionconverter.ReadJson(reader, objectType, existingValue, serializer) as Union; if (union.Item1.HasValue) return new MinimumShouldMatch(union.Item1.Value); + return new MinimumShouldMatch(union.Item2); } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => Unionconverter.WriteJson(writer, value, serializer); - } public override bool CanConvert(Type objectType) => true; } diff --git a/src/Nest/CommonOptions/Range/AggregationRange.cs b/src/Nest/CommonOptions/Range/AggregationRange.cs index e0a8adb08a2..ade6e0e16f3 100644 --- a/src/Nest/CommonOptions/Range/AggregationRange.cs +++ b/src/Nest/CommonOptions/Range/AggregationRange.cs @@ -1,11 +1,10 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Nest { /// - /// Range that defines a bucket for either the or - /// . If you are looking to store ranges as + /// Range that defines a bucket for either the or + /// . If you are looking to store ranges as /// part of your document please use explicit range class e.g DateRange, FloatRange etc /// [JsonObject(MemberSerialization = MemberSerialization.OptIn)] @@ -15,22 +14,22 @@ public interface IAggregationRange [JsonProperty("from")] double? From { get; set; } - [JsonProperty("to")] - double? To { get; set; } - [JsonProperty("key")] string Key { get; set; } + + [JsonProperty("to")] + double? To { get; set; } } - /// + /// public class AggregationRange : IAggregationRange { public double? From { get; set; } - public double? To { get; set; } public string Key { get; set; } + public double? To { get; set; } } - /// + /// public class AggregationRangeDescriptor : DescriptorBase, IAggregationRange { double? IAggregationRange.From { get; set; } @@ -38,7 +37,9 @@ public class AggregationRangeDescriptor : DescriptorBase Assign(a => a.Key = key); + public AggregationRangeDescriptor From(double? from) => Assign(a => a.From = from); + public AggregationRangeDescriptor To(double? to) => Assign(a => a.To = to); } } diff --git a/src/Nest/CommonOptions/Range/Ranges.cs b/src/Nest/CommonOptions/Range/Ranges.cs index d44d4edfad2..e023bdb0589 100644 --- a/src/Nest/CommonOptions/Range/Ranges.cs +++ b/src/Nest/CommonOptions/Range/Ranges.cs @@ -5,86 +5,91 @@ namespace Nest { public class DateRange { - [JsonProperty("gte")] - public DateTimeOffset? GreaterThanOrEqualTo { get; set; } - - [JsonProperty("lte")] - public DateTimeOffset? LessThanOrEqualTo { get; set; } - [JsonProperty("gt")] public DateTimeOffset? GreaterThan { get; set; } + [JsonProperty("gte")] + public DateTimeOffset? GreaterThanOrEqualTo { get; set; } + [JsonProperty("lt")] public DateTimeOffset? LessThan { get; set; } - } - public class DoubleRange - { - [JsonProperty("gte")] - public double? GreaterThanOrEqualTo { get; set; } [JsonProperty("lte")] - public double? LessThanOrEqualTo { get; set; } + public DateTimeOffset? LessThanOrEqualTo { get; set; } + } + public class DoubleRange + { [JsonProperty("gt")] public double? GreaterThan { get; set; } + [JsonProperty("gte")] + public double? GreaterThanOrEqualTo { get; set; } + [JsonProperty("lt")] public double? LessThan { get; set; } - } - public class FloatRange - { - [JsonProperty("gte")] - public float? GreaterThanOrEqualTo { get; set; } [JsonProperty("lte")] - public float? LessThanOrEqualTo { get; set; } + public double? LessThanOrEqualTo { get; set; } + } + public class FloatRange + { [JsonProperty("gt")] public float? GreaterThan { get; set; } + [JsonProperty("gte")] + public float? GreaterThanOrEqualTo { get; set; } + [JsonProperty("lt")] public float? LessThan { get; set; } - } - public class IntegerRange - { - [JsonProperty("gte")] - public int? GreaterThanOrEqualTo { get; set; } [JsonProperty("lte")] - public int? LessThanOrEqualTo { get; set; } + public float? LessThanOrEqualTo { get; set; } + } + public class IntegerRange + { [JsonProperty("gt")] public int? GreaterThan { get; set; } + [JsonProperty("gte")] + public int? GreaterThanOrEqualTo { get; set; } + [JsonProperty("lt")] public int? LessThan { get; set; } - } - public class LongRange - { - [JsonProperty("gte")] - public long? GreaterThanOrEqualTo { get; set; } [JsonProperty("lte")] - public long? LessThanOrEqualTo { get; set; } + public int? LessThanOrEqualTo { get; set; } + } + public class LongRange + { [JsonProperty("gt")] public long? GreaterThan { get; set; } + [JsonProperty("gte")] + public long? GreaterThanOrEqualTo { get; set; } + [JsonProperty("lt")] public long? LessThan { get; set; } - } - public class IpAddressRange - { - [JsonProperty("gte")] - public string GreaterThanOrEqualTo { get; set; } [JsonProperty("lte")] - public string LessThanOrEqualTo { get; set; } + public long? LessThanOrEqualTo { get; set; } + } + public class IpAddressRange + { [JsonProperty("gt")] public string GreaterThan { get; set; } + [JsonProperty("gte")] + public string GreaterThanOrEqualTo { get; set; } + [JsonProperty("lt")] public string LessThan { get; set; } + + [JsonProperty("lte")] + public string LessThanOrEqualTo { get; set; } } } diff --git a/src/Nest/CommonOptions/Scripting/IndexedScript.cs b/src/Nest/CommonOptions/Scripting/IndexedScript.cs index d43d5e9b78d..0376790e25d 100644 --- a/src/Nest/CommonOptions/Scripting/IndexedScript.cs +++ b/src/Nest/CommonOptions/Scripting/IndexedScript.cs @@ -11,10 +11,7 @@ public interface IIndexedScript : IScript public class IndexedScript : ScriptBase, IIndexedScript { - public IndexedScript(string id) - { - this.Id = id; - } + public IndexedScript(string id) => Id = id; public string Id { get; set; } } @@ -22,14 +19,11 @@ public IndexedScript(string id) public class IndexedScriptDescriptor : ScriptDescriptorBase, IIndexedScript { - string IIndexedScript.Id { get; set; } + public IndexedScriptDescriptor() { } - public IndexedScriptDescriptor() {} + public IndexedScriptDescriptor(string id) => Self.Id = id; - public IndexedScriptDescriptor(string id) - { - Self.Id = id; - } + string IIndexedScript.Id { get; set; } public IndexedScriptDescriptor Id(string id) => Assign(a => a.Id = id); } diff --git a/src/Nest/CommonOptions/Scripting/InlineScript.cs b/src/Nest/CommonOptions/Scripting/InlineScript.cs index 663b2621e70..c37fdbe8262 100644 --- a/src/Nest/CommonOptions/Scripting/InlineScript.cs +++ b/src/Nest/CommonOptions/Scripting/InlineScript.cs @@ -6,20 +6,25 @@ namespace Nest [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public interface IInlineScript : IScript { - [JsonProperty("source")] - string Source { get; set; } - [Obsolete("Use Source. Inline is deprecated and scheduled to be removed in Elasticsearch 7.0")] [JsonIgnore] string Inline { get; set; } + + [JsonProperty("source")] + string Source { get; set; } } public class InlineScript : ScriptBase, IInlineScript { - public InlineScript(string script) => this.Source = script; + public InlineScript(string script) => Source = script; + + public string Inline + { + get => Source; + set => Source = value; + } public string Source { get; set; } - public string Inline { get => this.Source; set => this.Source = value; } public static implicit operator InlineScript(string script) => new InlineScript(script); } @@ -27,13 +32,18 @@ public class InlineScript : ScriptBase, IInlineScript public class InlineScriptDescriptor : ScriptDescriptorBase, IInlineScript { - string IInlineScript.Inline { get => Self.Source; set => Self.Source = value; } - string IInlineScript.Source { get; set; } - public InlineScriptDescriptor() { } public InlineScriptDescriptor(string script) => Self.Source = script; + string IInlineScript.Inline + { + get => Self.Source; + set => Self.Source = value; + } + + string IInlineScript.Source { get; set; } + [Obsolete("Use Source(). Inline() is deprecated and scheduled to be removed in Elasticsearch 7.0")] public InlineScriptDescriptor Inline(string script) => Assign(a => a.Source = script); diff --git a/src/Nest/CommonOptions/Scripting/ScriptBase.cs b/src/Nest/CommonOptions/Scripting/ScriptBase.cs index d313511b229..afb5c8403e5 100644 --- a/src/Nest/CommonOptions/Scripting/ScriptBase.cs +++ b/src/Nest/CommonOptions/Scripting/ScriptBase.cs @@ -10,33 +10,31 @@ namespace Nest public interface IScript { /// - /// Scripts are compiled and cached for faster execution. - /// If the same script can be used, just with different parameters provided, - /// it is preferable to use the ability to pass parameters to the script itself. + /// Language of script. + /// + /// language + /// this + [JsonProperty("lang")] + string Lang { get; set; } + + /// + /// Scripts are compiled and cached for faster execution. + /// If the same script can be used, just with different parameters provided, + /// it is preferable to use the ability to pass parameters to the script itself. /// /// - /// script: "doc['num1'].value > param1" - /// param: "param1" = 5 + /// script: "doc['num1'].value > param1" + /// param: "param1" = 5 /// /// param /// this [JsonProperty("params")] [JsonConverter(typeof(VerbatimDictionaryKeysPreservingNullJsonConverter))] Dictionary Params { get; set; } - - /// - /// Language of script. - /// - /// language - /// this - [JsonProperty("lang")] - string Lang { get; set; } } public abstract class ScriptBase : IScript { - public Dictionary Params { get; set; } - /// /// Language of script. /// @@ -44,8 +42,10 @@ public abstract class ScriptBase : IScript /// this public string Lang { get; set; } + public Dictionary Params { get; set; } + /// - /// Implicit conversion from to + /// Implicit conversion from to /// public static implicit operator ScriptBase(string script) => new InlineScript(script); } @@ -54,30 +54,30 @@ public abstract class ScriptDescriptorBase : Descriptor where TDescriptor : ScriptDescriptorBase, TInterface, IScript where TInterface : class, IScript { - Dictionary IScript.Params { get; set; } string IScript.Lang { get; set; } + Dictionary IScript.Params { get; set; } /// - /// Scripts are compiled and cached for faster execution. - /// If the same script can be used, just with different parameters provided, - /// it is preferable to use the ability to pass parameters to the script itself. + /// Scripts are compiled and cached for faster execution. + /// If the same script can be used, just with different parameters provided, + /// it is preferable to use the ability to pass parameters to the script itself. /// /// - /// script: "doc['num1'].value > param1" - /// param: "param1" = 5 + /// script: "doc['num1'].value > param1" + /// param: "param1" = 5 /// /// param /// this public TDescriptor Params(Dictionary scriptParams) => Assign(a => a.Params = scriptParams); /// - /// Scripts are compiled and cached for faster execution. - /// If the same script can be used, just with different parameters provided, - /// it is preferable to use the ability to pass parameters to the script itself. + /// Scripts are compiled and cached for faster execution. + /// If the same script can be used, just with different parameters provided, + /// it is preferable to use the ability to pass parameters to the script itself. /// /// - /// script: "doc['num1'].value > param1" - /// param: "param1" = 5 + /// script: "doc['num1'].value > param1" + /// param: "param1" = 5 /// /// param /// this diff --git a/src/Nest/CommonOptions/Scripting/ScriptFields.cs b/src/Nest/CommonOptions/Scripting/ScriptFields.cs index 0b5a042eedf..55f16872c9c 100644 --- a/src/Nest/CommonOptions/Scripting/ScriptFields.cs +++ b/src/Nest/CommonOptions/Scripting/ScriptFields.cs @@ -32,14 +32,16 @@ public interface IScriptFields : IIsADictionary { } public class ScriptFields : IsADictionaryBase, IScriptFields { - public ScriptFields() {} + public ScriptFields() { } + public ScriptFields(IDictionary container) : base(container) { } + public ScriptFields(Dictionary container) - : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) - {} + : base(container.Select(kv => kv).ToDictionary(kv => kv.Key, kv => kv.Value)) { } + + public void Add(string name, IScriptField script) => BackingDictionary.Add(name, script); - public void Add(string name, IScriptField script) => this.BackingDictionary.Add(name, script); - public void Add(string name, IScript script) => this.BackingDictionary.Add(name, new ScriptField { Script = script }); + public void Add(string name, IScript script) => BackingDictionary.Add(name, new ScriptField { Script = script }); } public class ScriptFieldsDescriptor : IsADictionaryDescriptorBase diff --git a/src/Nest/CommonOptions/Scripting/ScriptJsonConverter.cs b/src/Nest/CommonOptions/Scripting/ScriptJsonConverter.cs index 5dc1cae788b..227ca471cf1 100644 --- a/src/Nest/CommonOptions/Scripting/ScriptJsonConverter.cs +++ b/src/Nest/CommonOptions/Scripting/ScriptJsonConverter.cs @@ -8,10 +8,11 @@ namespace Nest { internal class ScriptJsonConverter : JsonConverter { - public override bool CanConvert(Type objectType) => typeof(IScript).IsAssignableFrom(objectType); public override bool CanRead => true; public override bool CanWrite => false; + public override bool CanConvert(Type objectType) => typeof(IScript).IsAssignableFrom(objectType); + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var o = JObject.Load(reader); diff --git a/src/Nest/CommonOptions/Sorting/SortJsonConverter.cs b/src/Nest/CommonOptions/Sorting/SortJsonConverter.cs index f1b8df00523..c964b28ae4b 100644 --- a/src/Nest/CommonOptions/Sorting/SortJsonConverter.cs +++ b/src/Nest/CommonOptions/Sorting/SortJsonConverter.cs @@ -10,6 +10,7 @@ internal class SortJsonConverter : ReserializeJsonConverter { public override bool CanRead => true; public override bool CanWrite => true; + public override bool CanConvert(Type objectType) => typeof(ISort).IsAssignableFrom(objectType); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) @@ -28,7 +29,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist var s = FromJson.ReadAs(r, serializer); s.Field = geoLocationProp.Name; using (var rr = geoLocationProp.Value.CreateReader()) - s.Points =FromJson.ReadAs>(rr, serializer); + s.Points = FromJson.ReadAs>(rr, serializer); sort = s; } } @@ -61,12 +62,12 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { case "_script": writer.WritePropertyName("_script"); - base.Reserialize(writer, s, serializer); + Reserialize(writer, s, serializer); break; case "_geo_distance": var geo = s as IGeoDistanceSort; writer.WritePropertyName(geo.SortKey.Name); - base.Reserialize(writer, s, serializer, w => + Reserialize(writer, s, serializer, w => { writer.WritePropertyName(settings.Inferrer.Field(geo.Field)); serializer.Serialize(writer, geo.Points); @@ -74,7 +75,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s break; default: writer.WritePropertyName(settings.Inferrer.Field(s.SortKey)); - base.Reserialize(writer, s, serializer); + Reserialize(writer, s, serializer); break; } writer.WriteEndObject(); diff --git a/src/Nest/CommonOptions/Stats/FieldDataStats.cs b/src/Nest/CommonOptions/Stats/FieldDataStats.cs index 1ff2306ab1d..1bcb570c7b4 100644 --- a/src/Nest/CommonOptions/Stats/FieldDataStats.cs +++ b/src/Nest/CommonOptions/Stats/FieldDataStats.cs @@ -10,8 +10,8 @@ public class FielddataStats [JsonProperty("memory_size")] public string MemorySize { get; set; } + [JsonProperty("memory_size_in_bytes")] public long MemorySizeInBytes { get; set; } - } } diff --git a/src/Nest/CommonOptions/Stats/FlushStats.cs b/src/Nest/CommonOptions/Stats/FlushStats.cs index f2527ff5d15..5e5f0b62db4 100644 --- a/src/Nest/CommonOptions/Stats/FlushStats.cs +++ b/src/Nest/CommonOptions/Stats/FlushStats.cs @@ -5,16 +5,15 @@ namespace Nest [JsonObject] public class FlushStats { - - [JsonProperty("total")] - public long Total { get; set; } - /// /// The number of flushes that were periodically triggered when translog exceeded the flush threshold. /// [JsonProperty("periodic")] public long Periodic { get; set; } + [JsonProperty("total")] + public long Total { get; set; } + /// /// The total time merges have been executed. /// @@ -26,6 +25,5 @@ public class FlushStats /// [JsonProperty("total_time_in_millis")] public long TotalTimeInMilliseconds { get; set; } - } } diff --git a/src/Nest/CommonOptions/Stats/GetStats.cs b/src/Nest/CommonOptions/Stats/GetStats.cs index 4985a9f4036..19ecbcd3851 100644 --- a/src/Nest/CommonOptions/Stats/GetStats.cs +++ b/src/Nest/CommonOptions/Stats/GetStats.cs @@ -10,6 +10,7 @@ public class GetStats [JsonProperty("exists_time")] public string ExistsTime { get; set; } + [JsonProperty("exists_time_in_millis")] public long ExistsTimeInMilliseconds { get; set; } @@ -18,6 +19,7 @@ public class GetStats [JsonProperty("missing_time")] public string MissingTime { get; set; } + [JsonProperty("missing_time_in_millis")] public long MissingTimeInMilliseconds { get; set; } @@ -26,11 +28,11 @@ public class GetStats [JsonProperty("time")] public string Time { get; set; } + [JsonProperty("time_in_millis")] public long TimeInMilliseconds { get; set; } [JsonProperty("total")] public long Total { get; set; } - } } diff --git a/src/Nest/CommonOptions/Stats/IndexingStats.cs b/src/Nest/CommonOptions/Stats/IndexingStats.cs index 9d6d8a22750..98134c7b6af 100644 --- a/src/Nest/CommonOptions/Stats/IndexingStats.cs +++ b/src/Nest/CommonOptions/Stats/IndexingStats.cs @@ -6,6 +6,9 @@ namespace Nest [JsonObject] public class IndexingStats { + [JsonProperty("index_current")] + public long Current { get; set; } + [JsonProperty("delete_current")] public long DeleteCurrent { get; set; } @@ -18,18 +21,6 @@ public class IndexingStats [JsonProperty("delete_total")] public long DeleteTotal { get; set; } - [JsonProperty("index_current")] - public long Current { get; set; } - - [JsonProperty("index_time")] - public string Time { get; set; } - - [JsonProperty("index_time_in_millis")] - public long TimeInMilliseconds { get; set; } - - [JsonProperty("index_total")] - public long Total { get; set; } - [JsonProperty("is_throttled")] public bool IsThrottled { get; set; } @@ -42,6 +33,15 @@ public class IndexingStats [JsonProperty("throttle_time_in_millis")] public long ThrottleTimeInMilliseconds { get; set; } + [JsonProperty("index_time")] + public string Time { get; set; } + + [JsonProperty("index_time_in_millis")] + public long TimeInMilliseconds { get; set; } + + [JsonProperty("index_total")] + public long Total { get; set; } + [JsonProperty("types")] [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] public IReadOnlyDictionary Types { get; set; } diff --git a/src/Nest/CommonOptions/Stats/MergesStats.cs b/src/Nest/CommonOptions/Stats/MergesStats.cs index 3cd6d182bc8..1e37d52fe23 100644 --- a/src/Nest/CommonOptions/Stats/MergesStats.cs +++ b/src/Nest/CommonOptions/Stats/MergesStats.cs @@ -5,7 +5,6 @@ namespace Nest [JsonObject] public class MergesStats { - [JsonProperty("current")] public long Current { get; set; } @@ -14,6 +13,7 @@ public class MergesStats [JsonProperty("current_size")] public string CurrentSize { get; set; } + [JsonProperty("current_size_in_bytes")] public long CurrentSizeInBytes { get; set; } @@ -22,6 +22,7 @@ public class MergesStats [JsonProperty("total_auto_throttle")] public string TotalAutoThrottle { get; set; } + [JsonProperty("total_auto_throttle_in_bytes")] public long TotalAutoThrottleInBytes { get; set; } @@ -30,21 +31,25 @@ public class MergesStats [JsonProperty("total_size")] public string TotalSize { get; set; } + [JsonProperty("total_size_in_bytes")] public string TotalSizeInBytes { get; set; } [JsonProperty("total_stopped_time")] public string TotalStoppedTime { get; set; } + [JsonProperty("total__stopped_time_in_millis")] public long TotalStoppedTimeInMilliseconds { get; set; } [JsonProperty("total_throttled_time")] public string TotalThrottledTime { get; set; } + [JsonProperty("total_throttled_time_in_millis")] public long TotalThrottledTimeInMilliseconds { get; set; } [JsonProperty("total_time")] public string TotalTime { get; set; } + [JsonProperty("total_time_in_millis")] public long TotalTimeInMilliseconds { get; set; } } diff --git a/src/Nest/CommonOptions/Stats/PluginStats.cs b/src/Nest/CommonOptions/Stats/PluginStats.cs index 0bbd718d1b9..388a47890d1 100644 --- a/src/Nest/CommonOptions/Stats/PluginStats.cs +++ b/src/Nest/CommonOptions/Stats/PluginStats.cs @@ -5,25 +5,25 @@ namespace Nest [JsonObject] public class PluginStats { - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("version")] - public string Version { get; set; } + [JsonProperty("classname")] + public string ClassName { get; set; } [JsonProperty("description")] public string Description { get; set; } - [JsonProperty("classname")] - public string ClassName { get; set; } + [JsonProperty("isolated")] + public bool Isolated { get; set; } [JsonProperty("jvm")] public bool Jvm { get; set; } - [JsonProperty("isolated")] - public bool Isolated { get; set; } + [JsonProperty("name")] + public string Name { get; set; } [JsonProperty("site")] public bool Site { get; set; } + + [JsonProperty("version")] + public string Version { get; set; } } } diff --git a/src/Nest/CommonOptions/Stats/QueryCacheStats.cs b/src/Nest/CommonOptions/Stats/QueryCacheStats.cs index 2c8037ed1d1..90e83128367 100644 --- a/src/Nest/CommonOptions/Stats/QueryCacheStats.cs +++ b/src/Nest/CommonOptions/Stats/QueryCacheStats.cs @@ -5,28 +5,28 @@ namespace Nest [JsonObject] public class QueryCacheStats { - [JsonProperty("memory_size")] - public string MemorySize { get; set; } - [JsonProperty("memory_size_in_bytes")] - public long MemorySizeInBytes { get; set; } + [JsonProperty("cache_count")] + public long CacheCount { get; set; } - [JsonProperty("total_count")] - public long TotalCount { get; set; } + [JsonProperty("cache_size")] + public long CacheSize { get; set; } + + [JsonProperty("evictions")] + public long Evictions { get; set; } [JsonProperty("hit_count")] public long HitCount { get; set; } - [JsonProperty("miss_count")] - public long MissCount { get; set; } - - [JsonProperty("cache_size")] - public long CacheSize { get; set; } + [JsonProperty("memory_size")] + public string MemorySize { get; set; } - [JsonProperty("cache_count")] - public long CacheCount { get; set; } + [JsonProperty("memory_size_in_bytes")] + public long MemorySizeInBytes { get; set; } - [JsonProperty("evictions")] - public long Evictions { get; set; } + [JsonProperty("miss_count")] + public long MissCount { get; set; } + [JsonProperty("total_count")] + public long TotalCount { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonOptions/Stats/RecoveryStats.cs b/src/Nest/CommonOptions/Stats/RecoveryStats.cs index db2ea812c46..62d82deedcc 100644 --- a/src/Nest/CommonOptions/Stats/RecoveryStats.cs +++ b/src/Nest/CommonOptions/Stats/RecoveryStats.cs @@ -16,6 +16,5 @@ public class RecoveryStats [JsonProperty("throttle_time_in_millis")] public long ThrottleTimeInMilliseconds { get; set; } - } } diff --git a/src/Nest/CommonOptions/Stats/RefreshStats.cs b/src/Nest/CommonOptions/Stats/RefreshStats.cs index 148a85982c6..f59a92d85d6 100644 --- a/src/Nest/CommonOptions/Stats/RefreshStats.cs +++ b/src/Nest/CommonOptions/Stats/RefreshStats.cs @@ -5,14 +5,13 @@ namespace Nest [JsonObject] public class RefreshStats { - [JsonProperty("total")] public long Total { get; set; } [JsonProperty("total_time")] public string TotalTime { get; set; } + [JsonProperty("total_time_in_millis")] public long TotalTimeInMilliseconds { get; set; } - } } diff --git a/src/Nest/CommonOptions/Stats/RequestCacheStats.cs b/src/Nest/CommonOptions/Stats/RequestCacheStats.cs index 3e5f3a8907f..fcc606c6529 100644 --- a/src/Nest/CommonOptions/Stats/RequestCacheStats.cs +++ b/src/Nest/CommonOptions/Stats/RequestCacheStats.cs @@ -12,13 +12,12 @@ public class RequestCacheStats public long HitCount { get; set; } [JsonProperty("memory_size")] - public string MemorySize{ get; set; } + public string MemorySize { get; set; } [JsonProperty("memory_size_in_bytes")] public long MemorySizeInBytes { get; set; } [JsonProperty("miss_count")] public long MissCount { get; set; } - } -} \ No newline at end of file +} diff --git a/src/Nest/CommonOptions/Stats/SearchStats.cs b/src/Nest/CommonOptions/Stats/SearchStats.cs index 24dce92911b..92c8270ada0 100644 --- a/src/Nest/CommonOptions/Stats/SearchStats.cs +++ b/src/Nest/CommonOptions/Stats/SearchStats.cs @@ -5,9 +5,6 @@ namespace Nest [JsonObject] public class SearchStats { - [JsonProperty("open_contexts")] - public long OpenContexts { get; set; } - [JsonProperty("fetch_current")] public long FetchCurrent { get; set; } @@ -17,6 +14,9 @@ public class SearchStats [JsonProperty("fetch_total")] public long FetchTotal { get; set; } + [JsonProperty("open_contexts")] + public long OpenContexts { get; set; } + [JsonProperty("query_current")] public long QueryCurrent { get; set; } diff --git a/src/Nest/CommonOptions/Stats/SegmentsStats.cs b/src/Nest/CommonOptions/Stats/SegmentsStats.cs index b269e55a98c..6c954401e62 100644 --- a/src/Nest/CommonOptions/Stats/SegmentsStats.cs +++ b/src/Nest/CommonOptions/Stats/SegmentsStats.cs @@ -10,58 +10,68 @@ public class SegmentsStats [JsonProperty("doc_values_memory")] public string DocValuesMemory { get; set; } + [JsonProperty("doc_values_memory_in_bytes")] public long DocValuesMemoryInBytes { get; set; } [JsonProperty("fixed_bit_set_memory")] public string FixedBitSetMemory { get; set; } + [JsonProperty("fixed_bit_set_memory_in_bytes")] public long FixedBitSetMemoryInBytes { get; set; } [JsonProperty("index_writer_max_memory")] public string IndexWriterMaxMemory { get; set; } + [JsonProperty("index_writer_max_memory_in_bytes")] public long IndexWriterMaxMemoryInBytes { get; set; } [JsonProperty("index_writer_memory")] public string IndexWriterMemory { get; set; } + [JsonProperty("index_writer_memory_in_bytes")] public long IndexWriterMemoryInBytes { get; set; } [JsonProperty("memory")] public string Memory { get; set; } + [JsonProperty("memory_in_bytes")] public long MemoryInBytes { get; set; } [JsonProperty("norms_memory")] public string NormsMemory { get; set; } + [JsonProperty("norms_memory_in_bytes")] public long NormsMemoryInBytes { get; set; } [JsonProperty("points_memory")] public string PointsMemory { get; set; } + [JsonProperty("points_memory_in_bytes")] public long PointsMemoryInBytes { get; set; } [JsonProperty("stored_fields_memory")] public string StoredFieldsMemory { get; set; } + [JsonProperty("stored_fields_memory_in_bytes")] public long StoredFieldsMemoryInBytes { get; set; } - [JsonProperty("term_vectors_memory")] - public string TermVectorsMemory { get; set; } - [JsonProperty("term_vectors_memory_in_bytes")] - public long TermVectorsMemoryInBytes { get; set; } - [JsonProperty("terms_memory")] public string TermsMemory { get; set; } + [JsonProperty("terms_memory_in_bytes")] public long TermsMemoryInBytes { get; set; } + [JsonProperty("term_vectors_memory")] + public string TermVectorsMemory { get; set; } + + [JsonProperty("term_vectors_memory_in_bytes")] + public long TermVectorsMemoryInBytes { get; set; } + [JsonProperty("version_map_memory")] public string VersionMapMemory { get; set; } + [JsonProperty("version_map_memory_in_bytes")] public long VersionMapMemoryInBytes { get; set; } - } } diff --git a/src/Nest/CommonOptions/Stats/StoreStats.cs b/src/Nest/CommonOptions/Stats/StoreStats.cs index e64bf2fae02..3df530d5ff4 100644 --- a/src/Nest/CommonOptions/Stats/StoreStats.cs +++ b/src/Nest/CommonOptions/Stats/StoreStats.cs @@ -10,7 +10,5 @@ public class StoreStats [JsonProperty("size_in_bytes")] public double SizeInBytes { get; set; } - } - } diff --git a/src/Nest/CommonOptions/Stats/TranslogStats.cs b/src/Nest/CommonOptions/Stats/TranslogStats.cs index ebb4ee93f37..f941ead2e91 100644 --- a/src/Nest/CommonOptions/Stats/TranslogStats.cs +++ b/src/Nest/CommonOptions/Stats/TranslogStats.cs @@ -5,28 +5,28 @@ namespace Nest [JsonObject] public class TranslogStats { - [JsonProperty("operations")] - public long Operations { get; set; } + /// + /// Valid only for Elasticsearch 6.3.0+ + /// + [JsonProperty("earliest_last_modified_age")] + public long EarliestLastModifiedAge { get; set; } - [JsonProperty("uncommitted_operations")] - public int UncommittedOperations { get; set; } + [JsonProperty("operations")] + public long Operations { get; set; } [JsonProperty("size")] public string Size { get; set; } [JsonProperty("size_in_bytes")] - public long SizeInBytes { get; set; } + public long SizeInBytes { get; set; } + + [JsonProperty("uncommitted_operations")] + public int UncommittedOperations { get; set; } [JsonProperty("uncommitted_size")] public string UncommittedSize { get; set; } [JsonProperty("uncommitted_size_in_bytes")] - public long UncommittedSizeInBytes { get; set; } - - /// - /// Valid only for Elasticsearch 6.3.0+ - /// - [JsonProperty("earliest_last_modified_age")] - public long EarliestLastModifiedAge { get; set; } + public long UncommittedSizeInBytes { get; set; } } } diff --git a/src/Nest/CommonOptions/Stats/WarmerStats.cs b/src/Nest/CommonOptions/Stats/WarmerStats.cs index 561ff91630a..3defd5a8546 100644 --- a/src/Nest/CommonOptions/Stats/WarmerStats.cs +++ b/src/Nest/CommonOptions/Stats/WarmerStats.cs @@ -17,4 +17,4 @@ public class WarmerStats [JsonProperty("total_time_in_millis")] public long TotalTimeInMilliseconds { get; set; } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonOptions/TimeUnit/Time.cs b/src/Nest/CommonOptions/TimeUnit/Time.cs index 2d80a88156b..afded2dcfb4 100644 --- a/src/Nest/CommonOptions/TimeUnit/Time.cs +++ b/src/Nest/CommonOptions/TimeUnit/Time.cs @@ -12,18 +12,16 @@ namespace Nest [JsonConverter(typeof(TimeJsonConverter))] public class Time : IComparable