.NET Core - DefaultMappingFor<T> hits multiple indexes

We are using the Elastic.Clients.Elasticsearch 8.1 package in our .NET Core application. We are trying to set up the ability to use a single Elastic client, and hit different indexes based on the model type. We have the current settings set up utilizing DefaultMappingFor<T> setting:

        var settings = new ElasticsearchClientSettings(pool)
            .SniffOnStartup()
            .SniffOnConnectionFault()
            .SniffLifeSpan(TimeSpan.FromMinutes(30))
            .ConnectionLimit(160)
            .EnableHttpCompression()
            .MaximumRetries(5)
            .MaxRetryTimeout(TimeSpan.FromSeconds(60))
            .RequestTimeout(TimeSpan.FromSeconds(120))
            .ThrowExceptions()
            .DefaultMappingFor<JobMessage>(i => i.IndexName($"{prefix}job_messages")
                .RoutingProperty(x => x.CompanyId))
            .DefaultMappingFor<Core.ElasticModels.V2.Email>(i => i.IndexName($"{prefix}emails")
                .RoutingProperty(x => x.CompanyId))
            .DefaultMappingFor<TextMessage>(i => i.IndexName($"{prefix}texts")
                .RoutingProperty(x => x.CompanyId))
            .DefaultMappingFor<ThreadParticipants>(i => i.IndexName($"{prefix}thread_participants")
                .RoutingProperty(x => x.CompanyId));

The issue is that all of these indexes all have the same named id column ("id"), so when we utilize SearchAsync<ThreadParticipants> passing in an id, if that id also exists in the job_messages index we get 2 documents returned. Is there way I can set up the settings to only look in the index that is set up for a specific model here in the settings?

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