DeleteByQuery using "from"

Hello everyone from elastic

I try to exclude some docs by specifying the starting document offset.

Based on the documentation below

I write this C # code

public async Task EraseData(string indexName, int from, int pageLength)
        {
            var response = this.AnalysisRepository.Client.DeleteByQuery<Dictionary<string, object>>(del => del
                                .Index(indexName)
                                .MaximumDocuments(pageLength)
                                .From(from)
                                .Query(q => q
                                    .QueryString(qs => qs
                                        .Query("*")
                                        )
                                    )
                                );
        }

But I get this error:
Validation Failed: 1: from is not supported in this contex

Elastic version 7.8.1
Nest version 7.8.1

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.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.