Skip to content
Merged
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
9 changes: 4 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<!--<CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>-->
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="8.15.10" />
<PackageVersion Include="Microsoft.SemanticKernel.Abstractions" Version="1.26.0" />
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="8.16.1" />
<PackageVersion Include="Microsoft.SemanticKernel.Abstractions" Version="1.29.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="MinVer" Version="6.0.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>
<ItemGroup>
<!--<GlobalPackageReference Include="Microsoft.Build.CopyOnWrite" Version="1.0.315" />-->
<GlobalPackageReference Include="Microsoft.Build.CopyOnWrite" Version="1.0.334" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static ICollection<Query> BuildFilter(VectorSearchFilter? basicVectorSear
filterQueries.Add(Query.Terms(new TermsQuery
{
Field = mapping.Value!,
Term = new TermsQueryField([FieldValueFromValue(anyTagEqualToClause.Value)])
Terms = new TermsQueryField([FieldValueFromValue(anyTagEqualToClause.Value)])
}));

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public async Task<VectorSearchResults<TRecord>> VectorizedSearchAsync<TVector>(T

// Validate inputs.

if (this._propertyReader.FirstVectorPropertyName is null)
if (_propertyReader.FirstVectorPropertyName is null)
{
throw new InvalidOperationException("The collection does not have any vector fields, so vector search is not possible.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

using Microsoft.SemanticKernel;

using ExistsRequest = Elastic.Clients.Elasticsearch.IndexManagement.ExistsRequest;

namespace Elastic.SemanticKernel.Connectors.Elasticsearch;

#pragma warning disable CA1852 // TODO: Remove after using MockableElasticsearchClient in unit tests
Expand All @@ -27,6 +29,11 @@ namespace Elastic.SemanticKernel.Connectors.Elasticsearch;
/// </summary>
internal class MockableElasticsearchClient
{
private static readonly RequestConfiguration CustomUserAgentRequestConfiguration = new RequestConfiguration
{
UserAgent = UserAgent.Create("elasticsearch-net", typeof(IElasticsearchClientSettings), ["integration=MSSK"])
};

/// <summary>
/// Initializes a new instance of the <see cref="MockableElasticsearchClient" /> class.
/// </summary>
Expand All @@ -38,18 +45,7 @@ public MockableElasticsearchClient(ElasticsearchClient elasticsearchClient)
{
Verify.NotNull(elasticsearchClient);

// Create a private instance of the ElasticsearchClient based on the settings of the original instance.

if (elasticsearchClient.ElasticsearchClientSettings is not ElasticsearchClientSettings settings)
{
throw new NotSupportedException("Unsupported Elasticsearch client instance.");
}

// TODO: Clone Settings

settings.UserAgent(UserAgent.Create($"{elasticsearchClient.ElasticsearchClientSettings.UserAgent}; integration=MSSK"));

ElasticsearchClient = new ElasticsearchClient(settings);
ElasticsearchClient = elasticsearchClient;
}

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
Expand Down Expand Up @@ -77,7 +73,12 @@ internal MockableElasticsearchClient()
public virtual async Task<IReadOnlyList<string>> ListIndicesAsync(CancellationToken cancellationToken = default)
{
var response = await ElasticsearchClient.Indices
.StatsAsync(cancellationToken)
.StatsAsync(
new IndicesStatsRequest
{
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken)
.ConfigureAwait(false);

if (!response.IsSuccess())
Expand All @@ -102,7 +103,12 @@ public virtual async Task<bool> IndexExistsAsync(
Verify.NotNull(indexName);

var response = await ElasticsearchClient.Indices
.ExistsAsync(indexName, cancellationToken)
.ExistsAsync(
new ExistsRequest(indexName)
{
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken)
.ConfigureAwait(false);

if (!response.IsSuccess())
Expand All @@ -129,13 +135,15 @@ public virtual async Task CreateIndexAsync(
Verify.NotNull(indexName);

var response = await ElasticsearchClient.Indices
.CreateAsync(new CreateIndexRequest(indexName)
{
Mappings = new TypeMapping
.CreateAsync(
new CreateIndexRequest(indexName)
{
Properties = properties
}
},
Mappings = new TypeMapping
{
Properties = properties
},
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken)
.ConfigureAwait(false);

Expand All @@ -158,7 +166,12 @@ public virtual async Task DeleteIndexAsync(
{
Verify.NotNull(indexName);

var response = await ElasticsearchClient.Indices.DeleteAsync(indexName, cancellationToken)
var response = await ElasticsearchClient.Indices.DeleteAsync(
new DeleteIndexRequest(indexName)
{
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken)
.ConfigureAwait(false);

if (!response.IsSuccess())
Expand All @@ -176,7 +189,12 @@ public virtual async Task DeleteIndexAsync(
Verify.NotNull(id);

var response = await ElasticsearchClient
.GetAsync<JsonObject>(indexName, id, x => { }, cancellationToken)
.GetAsync<JsonObject>(
new GetRequest(indexName, id)
{
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken)
.ConfigureAwait(false);

if (!response.IsSuccess())
Expand Down Expand Up @@ -212,7 +230,12 @@ public virtual async Task<string> IndexDocumentAsync<TDocument>(
Verify.NotNull(document);

var response = await ElasticsearchClient
.IndexAsync(document, indexName, id, cancellationToken)
.IndexAsync(
new IndexRequest<TDocument>(document, indexName, id)
{
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken)
.ConfigureAwait(false);

if (!response.IsSuccess())
Expand Down Expand Up @@ -240,7 +263,12 @@ public virtual async Task DeleteDocumentAsync(
Verify.NotNull(id);

var response = await ElasticsearchClient
.DeleteAsync(indexName, id, cancellationToken)
.DeleteAsync(
new DeleteRequest(indexName, id)
{
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken)
.ConfigureAwait(false);

if (!response.IsSuccess())
Expand Down Expand Up @@ -270,11 +298,16 @@ public virtual async Task DeleteDocumentAsync(
Verify.NotNull(query);

var response = await ElasticsearchClient
.SearchAsync<JsonObject>(indexName, x => x
.Query(query)
.From(from)
.Size(size),
cancellationToken)
.SearchAsync<JsonObject>(
new SearchRequest(indexName)
{
Query = query,
From = from,
Size = size,
RequestConfiguration = CustomUserAgentRequestConfiguration
},
cancellationToken
)
.ConfigureAwait(false);

if (!response.IsSuccess())
Expand Down
58 changes: 40 additions & 18 deletions Elastic.SemanticKernel.Connectors.Elasticsearch/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
".NETStandard,Version=v2.0": {
"Elastic.Clients.Elasticsearch": {
"type": "Direct",
"requested": "[8.15.10, )",
"resolved": "8.15.10",
"contentHash": "WxbKk/PvNOhhGLkaqdrQwNWxiDtOYQJYZK6VwOkV65r7kQO+cpmjkYr/FoJ4ArfHFzZJf77VHNyvFSWDe3Vqzw==",
"requested": "[8.16.1, )",
"resolved": "8.16.1",
"contentHash": "IIqNXo1hS15aXSfr3f+QzYJqj7k01vx075VJT4d4/oQdpN4HL3IRfnhcgPHMVQSuAw8bY5l3FSztGHT54AwgtQ==",
"dependencies": {
"Elastic.Transport": "0.4.26"
"Elastic.Transport": "0.5.5"
}
},
"Microsoft.Build.CopyOnWrite": {
"type": "Direct",
"requested": "[1.0.334, )",
"resolved": "1.0.334",
"contentHash": "Bi/e5guuwmyPL7Kp1G+PbcDvZFKsZxuHmc39IpYHAhWOvV8I/uIHPwAZ++Fa8k/w6pEqPdHCIrxSCelMNmu0dQ=="
},
"Microsoft.SemanticKernel.Abstractions": {
"type": "Direct",
"requested": "[1.26.0, )",
"resolved": "1.26.0",
"contentHash": "zvSl9tSByc8DZcFR+ii5O4dNg3AskEjtcd5kqp8lJAIhHslyNpR5kD0EkHPaxAsyJyCCD2TR0J1TOUwjBkxDAA==",
"requested": "[1.29.0, )",
"resolved": "1.29.0",
"contentHash": "PJIy7YAkaUtyp9uzRn1wO2lQYb/vuC9jtF7rmoPXe18ugrztnvY8sKyvv+LEMib48cZKfOhxOzQVE/dTa5TjrQ==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "8.0.0",
"Microsoft.Bcl.HashCode": "1.1.1",
Expand Down Expand Up @@ -68,11 +74,12 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.26",
"contentHash": "ZbVlxXn9fnZqMOyOESea5n17096Xa8EPI/I9yD65y6yPXZKrs4GcqKTjfYk0jkxsl3n+CpaNureMA+VutpLZzQ==",
"resolved": "0.5.5",
"contentHash": "sWuMp1yX4R2rHtmZhWVudt5l0zIaqSYCnUtcMrsmfiZxV2qY5WlbViPIH5KdYrI52p71vhScshVJbPDRezm10Q==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
"System.Collections.Immutable": "8.0.0",
"System.Diagnostics.DiagnosticSource": "8.0.0",
"System.Text.Json": "8.0.5",
"System.Threading.Tasks.Extensions": "4.5.4"
Expand Down Expand Up @@ -152,6 +159,15 @@
"resolved": "4.5.1",
"contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
},
"System.Collections.Immutable": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "AurL6Y5BA1WotzlEvVaIDpqzpIPvYnnldxru8oXJU2yFxFUy3+pNXjXd1ymO+RA0rq0+590Q8gaz2l3Sr7fmqg==",
"dependencies": {
"System.Memory": "4.5.5",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.Diagnostics.DiagnosticSource": {
"type": "Transitive",
"resolved": "8.0.1",
Expand Down Expand Up @@ -203,18 +219,24 @@
"net8.0": {
"Elastic.Clients.Elasticsearch": {
"type": "Direct",
"requested": "[8.15.10, )",
"resolved": "8.15.10",
"contentHash": "WxbKk/PvNOhhGLkaqdrQwNWxiDtOYQJYZK6VwOkV65r7kQO+cpmjkYr/FoJ4ArfHFzZJf77VHNyvFSWDe3Vqzw==",
"requested": "[8.16.1, )",
"resolved": "8.16.1",
"contentHash": "IIqNXo1hS15aXSfr3f+QzYJqj7k01vx075VJT4d4/oQdpN4HL3IRfnhcgPHMVQSuAw8bY5l3FSztGHT54AwgtQ==",
"dependencies": {
"Elastic.Transport": "0.4.26"
"Elastic.Transport": "0.5.5"
}
},
"Microsoft.Build.CopyOnWrite": {
"type": "Direct",
"requested": "[1.0.334, )",
"resolved": "1.0.334",
"contentHash": "Bi/e5guuwmyPL7Kp1G+PbcDvZFKsZxuHmc39IpYHAhWOvV8I/uIHPwAZ++Fa8k/w6pEqPdHCIrxSCelMNmu0dQ=="
},
"Microsoft.SemanticKernel.Abstractions": {
"type": "Direct",
"requested": "[1.26.0, )",
"resolved": "1.26.0",
"contentHash": "zvSl9tSByc8DZcFR+ii5O4dNg3AskEjtcd5kqp8lJAIhHslyNpR5kD0EkHPaxAsyJyCCD2TR0J1TOUwjBkxDAA==",
"requested": "[1.29.0, )",
"resolved": "1.29.0",
"contentHash": "PJIy7YAkaUtyp9uzRn1wO2lQYb/vuC9jtF7rmoPXe18ugrztnvY8sKyvv+LEMib48cZKfOhxOzQVE/dTa5TjrQ==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "8.0.0",
"Microsoft.Bcl.HashCode": "1.1.1",
Expand Down Expand Up @@ -250,8 +272,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.26",
"contentHash": "ZbVlxXn9fnZqMOyOESea5n17096Xa8EPI/I9yD65y6yPXZKrs4GcqKTjfYk0jkxsl3n+CpaNureMA+VutpLZzQ=="
"resolved": "0.5.5",
"contentHash": "sWuMp1yX4R2rHtmZhWVudt5l0zIaqSYCnUtcMrsmfiZxV2qY5WlbViPIH5KdYrI52p71vhScshVJbPDRezm10Q=="
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
Expand Down
28 changes: 17 additions & 11 deletions Elastic.SemanticKernel.Playground/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
"net8.0": {
"Elastic.Clients.Elasticsearch": {
"type": "Direct",
"requested": "[8.15.10, )",
"resolved": "8.15.10",
"contentHash": "WxbKk/PvNOhhGLkaqdrQwNWxiDtOYQJYZK6VwOkV65r7kQO+cpmjkYr/FoJ4ArfHFzZJf77VHNyvFSWDe3Vqzw==",
"requested": "[8.16.1, )",
"resolved": "8.16.1",
"contentHash": "IIqNXo1hS15aXSfr3f+QzYJqj7k01vx075VJT4d4/oQdpN4HL3IRfnhcgPHMVQSuAw8bY5l3FSztGHT54AwgtQ==",
"dependencies": {
"Elastic.Transport": "0.4.26"
"Elastic.Transport": "0.5.5"
}
},
"Microsoft.Build.CopyOnWrite": {
"type": "Direct",
"requested": "[1.0.334, )",
"resolved": "1.0.334",
"contentHash": "Bi/e5guuwmyPL7Kp1G+PbcDvZFKsZxuHmc39IpYHAhWOvV8I/uIHPwAZ++Fa8k/w6pEqPdHCIrxSCelMNmu0dQ=="
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.26",
"contentHash": "ZbVlxXn9fnZqMOyOESea5n17096Xa8EPI/I9yD65y6yPXZKrs4GcqKTjfYk0jkxsl3n+CpaNureMA+VutpLZzQ=="
"resolved": "0.5.5",
"contentHash": "sWuMp1yX4R2rHtmZhWVudt5l0zIaqSYCnUtcMrsmfiZxV2qY5WlbViPIH5KdYrI52p71vhScshVJbPDRezm10Q=="
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
Expand Down Expand Up @@ -57,17 +63,17 @@
"elastic.semantickernel.connectors.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Clients.Elasticsearch": "[8.15.10, )",
"Microsoft.SemanticKernel.Abstractions": "[1.26.0, )",
"Elastic.Clients.Elasticsearch": "[8.16.1, )",
"Microsoft.SemanticKernel.Abstractions": "[1.29.0, )",
"MinVer": "[6.0.0, )",
"System.Text.Json": "[8.0.5, )"
}
},
"Microsoft.SemanticKernel.Abstractions": {
"type": "CentralTransitive",
"requested": "[1.26.0, )",
"resolved": "1.26.0",
"contentHash": "zvSl9tSByc8DZcFR+ii5O4dNg3AskEjtcd5kqp8lJAIhHslyNpR5kD0EkHPaxAsyJyCCD2TR0J1TOUwjBkxDAA==",
"requested": "[1.29.0, )",
"resolved": "1.29.0",
"contentHash": "PJIy7YAkaUtyp9uzRn1wO2lQYb/vuC9jtF7rmoPXe18ugrztnvY8sKyvv+LEMib48cZKfOhxOzQVE/dTa5TjrQ==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "8.0.0",
"Microsoft.Bcl.HashCode": "1.1.1",
Expand Down
Loading