Skip to content

Commit 7d9a25e

Browse files
committed
WIP: Fixed more compiler errors.
1 parent a822889 commit 7d9a25e

File tree

8 files changed

+279
-157
lines changed

8 files changed

+279
-157
lines changed

.idea/.idea.Foundatio.Parsers/.idea/projectSettingsUpdater.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"cSpell.words": [
3+
"aggs",
4+
"Foundatio",
35
"Lucene",
46
"Niemyjski",
5-
"Xunit",
6-
"aggs"
7+
"Xunit"
78
],
89
"msbuildProjectTools.nuget.includePreRelease": true
910
}

src/Foundatio.Parsers.ElasticQueries/ElasticQueryParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public async Task<QueryValidationResult> ValidateSortAsync(string query, QueryVa
229229
return context.GetValidationResult();
230230
}
231231

232-
public async Task<IEnumerable<SortOptions>> BuildSortAsync(string sort, IElasticQueryVisitorContext context = null)
232+
public async Task<ICollection<SortOptions>> BuildSortAsync(string sort, IElasticQueryVisitorContext context = null)
233233
{
234234
context ??= new ElasticQueryVisitorContext();
235235
context.QueryType = QueryTypes.Sort;
@@ -240,7 +240,7 @@ public async Task<IEnumerable<SortOptions>> BuildSortAsync(string sort, IElastic
240240
return await BuildSortAsync(result, context).ConfigureAwait(false);
241241
}
242242

243-
public Task<IEnumerable<SortOptions>> BuildSortAsync(IQueryNode sort, IElasticQueryVisitorContext context = null)
243+
public Task<ICollection<SortOptions>> BuildSortAsync(IQueryNode sort, IElasticQueryVisitorContext context = null)
244244
{
245245
context ??= new ElasticQueryVisitorContext();
246246
return GetSortFieldsVisitor.RunAsync(sort, context);

src/Foundatio.Parsers.ElasticQueries/Visitors/GetSortFieldsVisitor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Foundatio.Parsers.ElasticQueries.Visitors;
1010

11-
public class GetSortFieldsVisitor : QueryNodeVisitorWithResultBase<IEnumerable<SortOptions>>
11+
public class GetSortFieldsVisitor : QueryNodeVisitorWithResultBase<ICollection<SortOptions>>
1212
{
1313
private readonly List<SortOptions> _fields = new();
1414

@@ -29,18 +29,18 @@ public override void Visit(TermNode node, IQueryVisitorContext context)
2929
_fields.Add(sort);
3030
}
3131

32-
public override async Task<IEnumerable<SortOptions>> AcceptAsync(IQueryNode node, IQueryVisitorContext context)
32+
public override async Task<ICollection<SortOptions>> AcceptAsync(IQueryNode node, IQueryVisitorContext context)
3333
{
3434
await node.AcceptAsync(this, context).ConfigureAwait(false);
3535
return _fields;
3636
}
3737

38-
public static Task<IEnumerable<SortOptions>> RunAsync(IQueryNode node, IQueryVisitorContext context = null)
38+
public static Task<ICollection<SortOptions>> RunAsync(IQueryNode node, IQueryVisitorContext context = null)
3939
{
4040
return new GetSortFieldsVisitor().AcceptAsync(node, context);
4141
}
4242

43-
public static IEnumerable<SortOptions> Run(IQueryNode node, IQueryVisitorContext context = null)
43+
public static ICollection<SortOptions> Run(IQueryNode node, IQueryVisitorContext context = null)
4444
{
4545
return RunAsync(node, context).GetAwaiter().GetResult();
4646
}

tests/Foundatio.Parsers.ElasticQueries.Tests/AggregationParserTests.cs

Lines changed: 164 additions & 40 deletions
Large diffs are not rendered by default.

tests/Foundatio.Parsers.ElasticQueries.Tests/ElasticMappingResolverTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ public ElasticMappingResolverTests(ITestOutputHelper output, ElasticsearchFixtur
2020
private TypeMappingDescriptor<MyNestedType> MapMyNestedType(TypeMappingDescriptor<MyNestedType> m)
2121
{
2222
return m
23-
.AutoMap<MyNestedType>()
2423
.Dynamic(DynamicMapping.True)
25-
.DynamicTemplates(t => t.DynamicTemplate("idx_text", t => t.Match("text*").Mapping(m => m.Text(mp => mp.AddKeywordAndSortFields()))))
24+
.DynamicTemplates(t => t.DynamicTemplate("idx_text", t1 => t1.Match("text*").Mapping(m1 => m1.Text(mp => mp.AddKeywordAndSortFields()))))
2625
.Properties(p => p
2726
.Text(p1 => p1.Field1, o => o.AddKeywordAndSortFields())
2827
.Text(p1 => p1.Field4, o => o.AddKeywordAndSortFields())

tests/Foundatio.Parsers.ElasticQueries.Tests/ElasticQueryParserTests.cs

Lines changed: 96 additions & 101 deletions
Large diffs are not rendered by default.

tests/Foundatio.Parsers.ElasticQueries.Tests/Utility/ElasticsearchTestBase.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,26 @@ protected ElasticsearchClient GetClient(Action<ElasticsearchClientSettings> conf
9696
return client;
9797
}
9898

99-
protected virtual void ConfigureConnectionSettings(ElasticsearchClientSettings settings) { }
99+
protected virtual void ConfigureConnectionSettings(ElasticsearchClientSettings settings)
100+
{
101+
}
100102

101103
public async Task CreateNamedIndexAsync<T>(string index, Func<TypeMappingDescriptor<T>, TypeMappingDescriptor<T>> configureMappings = null, Func<IndexSettingsDescriptor, IndexSettingsDescriptor> configureIndex = null) where T : class
102104
{
103-
configureMappings ??= m => m.AutoMap<T>().Dynamic(DynamicMapping.True);
105+
configureMappings ??= m => m.Dynamic(DynamicMapping.True);
104106
configureIndex ??= i => i.NumberOfReplicas(0).Analysis(a => a.AddSortNormalizer());
105107

106-
await CreateIndexAsync(index, i => i.Settings(configureIndex(new IndexSettingsDescriptor())).Map<T>(configureMappings));
108+
await CreateIndexAsync(index, i => i.Settings(configureIndex(new IndexSettingsDescriptor())).Mappings(configureMappings));
107109
Client.ElasticsearchClientSettings.DefaultIndices[typeof(T)] = index;
108110
}
109111

110112
public async Task<string> CreateRandomIndexAsync<T>(Func<TypeMappingDescriptor<T>, TypeMappingDescriptor<T>> configureMappings = null, Func<IndexSettingsDescriptor, IndexSettingsDescriptor> configureIndex = null) where T : class
111113
{
112114
string index = $"test_{Guid.NewGuid():N}";
113-
configureMappings ??= m => m.AutoMap<T>().Dynamic(DynamicMapping.True);
115+
configureMappings ??= m => m.Dynamic(DynamicMapping.True);
114116
configureIndex ??= i => i.NumberOfReplicas(0).Analysis(a => a.AddSortNormalizer());
115117

116-
await CreateIndexAsync(index, i => i.Settings(configureIndex(new IndexSettingsDescriptor())).Map<T>(configureMappings));
118+
await CreateIndexAsync(index, i => i.Settings(configureIndex(new IndexSettingsDescriptor())).Mappings(configureMappings));
117119
Client.ElasticsearchClientSettings.DefaultIndices[typeof(T)] = index;
118120

119121
return index;
@@ -134,7 +136,7 @@ public async Task<CreateIndexResponse> CreateIndexAsync(IndexName index, Action<
134136
protected virtual async Task CleanupTestIndexesAsync(ElasticsearchClient client)
135137
{
136138
if (_createdIndexes.Count > 0)
137-
await client.Indices.DeleteAsync(Indices.Index(_createdIndexes));
139+
await client.Indices.DeleteAsync(_createdIndexes.ToArray());
138140
}
139141

140142
public virtual Task InitializeAsync()

0 commit comments

Comments
 (0)