Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public override async Task VisitAsync(GroupNode node, IQueryVisitorContext conte
var termNode = child as TermNode;
if (termNode != null && termsAggregation != null)
{
// Look into this...
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment 'Look into this...' is vague and doesn't provide clear guidance about what needs investigation. Consider replacing it with a more specific description of what needs to be looked into or remove it if it's not necessary.

Suggested change
// Look into this...

Copilot uses AI. Check for mistakes.

// TODO: Move these to the default aggs method using a visitor to walk down the tree to gather them but not going into any sub groups
if (termNode.Field == "@exclude")
{
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