Hello I have a simple CRUD app that reads and writes to Elasticsearch, I am up to writing some unit tests for the app, which involves creating dummy data, checking I can search for the data and then deleting the data.
I have noticed that sometimes my tests are failing, as data which was deleted in a previous test sometimes reappears.
I am able to replicate the issue querying Elasticsearch directly:
at this stage I am expecting the _search to return zero results, which it usually does, but sometimes it will return 1 or 2 results which are previously deleted dummy data
I am running Elasticsearch locally on Windows and just used the stock standard ZIP package, no modifications made to the configuration
It'd be useful if you shared your code. Once a document has been deleted (and has been ack'd), then it's not available for Elasticsearch to retrieve. So something else is happening.
var settings = new ConnectionSettings(new Uri(Configuration["ElasticsearchConfiguration:Uri"]))
.BasicAuthentication(Configuration["ElasticsearchConfiguration:Username"], Configuration["ElasticsearchConfiguration:Password"])
.DefaultMappingFor<ElasticDocument>(m => m.IndexName(documentIndexName));
client = new ElasticClient(settings);
client.Indices.Create(documentIndexName, c => c
.Map<ElasticDocument>(m => m.AutoMap()));
Here is how I add to my index:
var elasticDocument = new ElasticDocument()
{
Uid = document.Id
};
client.Index(elasticDocument, o => o);
and delete:
client.Delete<ElasticDocument>(documentId);
the actual model:
[ElasticsearchType(IdProperty = nameof(Uid))]
private class ElasticDocument
{
[Keyword(Name = "uid")]
public string Uid { get; set; }
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.