Exclude documents from Reindex

Okay,

I am using the C# NEST client to trigger a Reindex of documents between two indexes in our Elasticsearch. The problem is that the Elasticsearch cluster only moves around 888 documents of the million that is there because the join_type has changed for a certain document type.

This is the code I am using:

var reindexResponse = Client.ReindexOnServer(reindexOnServerDescriptor => reindexOnServerDescriptor
            .Source(s => s.Index(Indices.Index(current)))
            .Destination(d => d.Index(Indices.Index(previous)))
            .WaitForCompletion(false)
        );

        var taskId = reindexResponse.Task;
        var taskResponse = Client.Tasks.GetTask(taskId);

        while (!taskResponse.Completed)
        {
            Logger.LogInformation("ElasticSearch Reindexing not completed, waiting 30 seconds...");
            Thread.Sleep(TimeSpan.FromSeconds(30));
            taskResponse = Client.Tasks.GetTask(taskId);
        }

I've tried using this instead:

var reindexResponse = Client.ReindexOnServer(reindexOnServerDescriptor => reindexOnServerDescriptor
            .Source(s => s
                .Index(Indices.Index(current))
                .Query<Company>(x => x.MatchAll())
                .Query<Person>(x => x.MatchAll())
                .Query<Location>(x => x.MatchAll())
                .Query<JobPosting>(x => x.MatchAll())
             )
            .Destination(d => d.Index(Indices.Index(previous)))
            .WaitForCompletion(false)
        );

        var taskId = reindexResponse.Task;
        var taskResponse = Client.Tasks.GetTask(taskId);

        while (!taskResponse.Completed)
        {
            Logger.LogInformation("ElasticSearch Reindexing not completed, waiting 30 seconds...");
            Thread.Sleep(TimeSpan.FromSeconds(30));
            taskResponse = Client.Tasks.GetTask(taskId);
        }

The idea is that I only want to move those document types, but the Elasticsearch keeps interrupting the Reindex because it's not excluding the types that cannot be reindexed.

How can I tell Elasticsearch to exclude a specific document from the Reindex?

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