Hi all from elastic, I find one solution with DeleteMany
// 01 buscar os documentos sem os campos de auto descoberta
var observer = this.AnalysisRepository.Client.ScrollAll<Dictionary<string, object>>("50m", 3, sc => sc
.MaxDegreeOfParallelism(4)
.Search(s => s
.Index(analysis.IndexName)
.Size(1000)
.Source(sf => sf
.Excludes(e => e.Fields("d.*", "n.*")) // <- Exclui os campos de auto descoberta e NER
)
.MatchAll()
)
);
var waitHandle = new ManualResetEvent(false);
Exception ex = null;
observer.Subscribe(new ScrollAllObserver<Dictionary<string, object>>(
onNext: r =>
{
// 02 aplicar dicionario de verbetes
var itens = this.dictionaryService.ApplyDictionary(r.SearchResponse.Documents.ToList<Dictionary<string, object>>(), masks, analysis);
// 03 limpa o indice antes de inserir os itens com as atualizações da auto descoberta
var response = this.AnalysisRepository.Client.DeleteMany(r.SearchResponse.Hits, model.IndexName);
// 04 gravar itens atualizados
Exception ex = this.elasticService.AddItensElastic(itens, model.IndexName, boolNer, analysis);
if (ex != null)
{
throw new Exception("Erro ao realizar atualização da análise!", ex);
}
},
onError: e =>
{
ex = e;
waitHandle.Set();
},
onCompleted: () =>
{
waitHandle.Set();
}
)
);
waitHandle.WaitOne(TimeSpan.FromMinutes(20));
can you explain what you are trying to achieve with a from, when you want to delete documents based on a query criteria? I do not understand the use-case and I have the feeling that this may lead to a wrong solution.
My objective is reindex an index, in small blocks, applying the ApplyDictionary() method.
To update the index I delete the old items and include the new itens by applying the ApplyDictionary() method.
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.