Skip to content
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Foundatio.Parsers.ElasticQueries.Visitors;

public class CombineQueriesVisitor : ChainableQueryVisitor
{

public override async Task VisitAsync(GroupNode node, IQueryVisitorContext context)
{
await base.VisitAsync(node, context).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public ElasticMappingResolverTests(ITestOutputHelper output, ElasticsearchFixtur
Log.DefaultLogLevel = Microsoft.Extensions.Logging.LogLevel.Trace;
}

private ITypeMapping MapMyNestedType(TypeMappingDescriptor<MyNestedType> m)
private ITypeMapping MapMyNestedType(TypeMappingDescriptor<ElasticNestedQueryParserTests.MyNestedType> m)
{
return m
.AutoMap<MyNestedType>()
.AutoMap<ElasticNestedQueryParserTests.MyNestedType>()
.Dynamic()
.DynamicTemplates(t => t.DynamicTemplate("idx_text", t => t.Match("text*").Mapping(m => m.Text(mp => mp.AddKeywordAndSortFields()))))
.Properties(p => p
Expand All @@ -30,10 +30,10 @@ private ITypeMapping MapMyNestedType(TypeMappingDescriptor<MyNestedType> m)
[Fact]
public void CanResolveCodedProperty()
{
string index = CreateRandomIndex<MyNestedType>(MapMyNestedType);
string index = CreateRandomIndex<ElasticNestedQueryParserTests.MyNestedType>(MapMyNestedType);

Client.IndexMany([
new MyNestedType
new ElasticNestedQueryParserTests.MyNestedType
{
Field1 = "value1",
Field2 = "value2",
Expand All @@ -50,12 +50,12 @@ public void CanResolveCodedProperty()
}
]
},
new MyNestedType { Field1 = "value2", Field2 = "value2" },
new MyNestedType { Field1 = "value1", Field2 = "value4" }
new ElasticNestedQueryParserTests.MyNestedType { Field1 = "value2", Field2 = "value2" },
new ElasticNestedQueryParserTests.MyNestedType { Field1 = "value1", Field2 = "value4" }
], index);
Client.Indices.Refresh(index);

var resolver = ElasticMappingResolver.Create<MyNestedType>(MapMyNestedType, Client, index, _logger);
var resolver = ElasticMappingResolver.Create<ElasticNestedQueryParserTests.MyNestedType>(MapMyNestedType, Client, index, _logger);

var payloadProperty = resolver.GetMappingProperty("payload");
Assert.IsType<TextProperty>(payloadProperty);
Expand All @@ -65,10 +65,10 @@ public void CanResolveCodedProperty()
[Fact]
public void CanResolveProperties()
{
string index = CreateRandomIndex<MyNestedType>(MapMyNestedType);
string index = CreateRandomIndex<ElasticNestedQueryParserTests.MyNestedType>(MapMyNestedType);

Client.IndexMany([
new MyNestedType
new ElasticNestedQueryParserTests.MyNestedType
{
Field1 = "value1",
Field2 = "value2",
Expand All @@ -85,12 +85,12 @@ public void CanResolveProperties()
}
]
},
new MyNestedType { Field1 = "value2", Field2 = "value2" },
new MyNestedType { Field1 = "value1", Field2 = "value4" }
new ElasticNestedQueryParserTests.MyNestedType { Field1 = "value2", Field2 = "value2" },
new ElasticNestedQueryParserTests.MyNestedType { Field1 = "value1", Field2 = "value4" }
], index);
Client.Indices.Refresh(index);

var resolver = ElasticMappingResolver.Create<MyNestedType>(MapMyNestedType, Client, index, _logger);
var resolver = ElasticMappingResolver.Create<ElasticNestedQueryParserTests.MyNestedType>(MapMyNestedType, Client, index, _logger);

string dynamicTextAggregation = resolver.GetAggregationsFieldName("nested.data.text-0001");
Assert.Equal("nested.data.text-0001.keyword", dynamicTextAggregation);
Expand Down Expand Up @@ -131,7 +131,7 @@ public void CanResolveProperties()
var field4Property = resolver.GetMappingProperty("Field4");
Assert.IsType<TextProperty>(field4Property);

var field4ReflectionProperty = resolver.GetMappingProperty(new Field(typeof(MyNestedType).GetProperty("Field4")));
var field4ReflectionProperty = resolver.GetMappingProperty(new Field(typeof(ElasticNestedQueryParserTests.MyNestedType).GetProperty("Field4")));
Assert.IsType<TextProperty>(field4ReflectionProperty);

var field4ExpressionProperty = resolver.GetMappingProperty(new Field(GetObjectPath(p => p.Field4)));
Expand Down Expand Up @@ -172,7 +172,7 @@ public void CanResolveProperties()
Assert.IsType<ObjectProperty>(nestedDataProperty);
}

private static Expression GetObjectPath(Expression<Func<MyNestedType, object>> objectPath)
private static Expression GetObjectPath(Expression<Func<ElasticNestedQueryParserTests.MyNestedType, object>> objectPath)
{
return objectPath;
}
Expand Down
Loading
Loading