feat(app): add get all addresses feature
This commit is contained in:
@@ -10,6 +10,7 @@ public interface IQdrantService
|
||||
Task InitializeCollectionAsync(CancellationToken cancellationToken = default);
|
||||
Task StoreAddressAsync(Address address, float[] embedding, CancellationToken cancellationToken = default);
|
||||
Task<List<AddressEmbedding>> SearchSimilarAddressesAsync(float[] queryEmbedding, int limit = 5, float scoreThreshold = 0.0f, CancellationToken cancellationToken = default);
|
||||
Task<List<AddressEmbedding>> GetAllAddressesAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public class QdrantService : IQdrantService
|
||||
@@ -67,4 +68,22 @@ public class QdrantService : IQdrantService
|
||||
Score = r.Score
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public async Task<List<AddressEmbedding>> GetAllAddressesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var response = await _client.ScrollAsync(_collectionName, limit: 10000, cancellationToken: cancellationToken);
|
||||
|
||||
var addresses = new List<AddressEmbedding>();
|
||||
foreach (var point in response.Result)
|
||||
{
|
||||
addresses.Add(new AddressEmbedding
|
||||
{
|
||||
Id = Guid.Parse(point.Id.Uuid),
|
||||
FullAddress = point.Payload["address"].StringValue,
|
||||
Vector = Array.Empty<float>(),
|
||||
Score = 0f
|
||||
});
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user