# .NET Core - DefaultMappingFor\<T\> hits multiple indexes

**URL:** https://discuss.elastic.co/t/net-core-defaultmappingfor-t-hits-multiple-indexes/348250
**Category:** Elasticsearch
**Created:** [November 29, 2023, 3:22pm UTC](https://discuss.elastic.co/t/net-core-defaultmappingfor-t-hits-multiple-indexes/348250 "2023-11-29T15:22:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kruegeba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kruegeba/32/128230_2.png) [@kruegeba](https://discuss.elastic.co/u/kruegeba)
#### Post date: [November 29, 2023, 3:22pm UTC](https://discuss.elastic.co/t/net-core-defaultmappingfor-t-hits-multiple-indexes/348250/1 "2023-11-29T15:22:46Z")

</div>

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:

```auto
        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?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 27, 2023, 3:23pm UTC](https://discuss.elastic.co/t/net-core-defaultmappingfor-t-hits-multiple-indexes/348250/2 "2023-12-27T15:23:41Z")

</div>

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