# Child Injectors or Index scoped objects

**URL:** <https://discuss.elastic.co/t/child-injectors-or-index-scoped-objects/18657>\
**Category:** Elasticsearch\
**Created:** [July 14, 2014, 6:09pm UTC](https://discuss.elastic.co/t/child-injectors-or-index-scoped-objects/18657 "2014-07-14T18:09:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AsyncAwait](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asyncawait/32/1346_2.png) [@AsyncAwait](https://discuss.elastic.co/u/AsyncAwait)\
**Post date:** [July 14, 2014, 6:09pm UTC](https://discuss.elastic.co/t/child-injectors-or-index-scoped-objects/18657/1 "2014-07-14T18:09:55Z")

</div>

I am learning the code and sounds like I am getting it.  
Would love to fix bugs and contributions back to such a great code base.

What is the intention behind childInjectors? For example,

```
    ModulesBuilder modules = new ModulesBuilder();
    modules.add(new IndexNameModule(index));
    modules.add(new LocalNodeIdModule(localNodeId));
    modules.add(new IndexSettingsModule(index, indexSettings));
    modules.add(new IndexPluginsModule(indexSettings, pluginsService));
    modules.add(new IndexStoreModule(indexSettings));
    modules.add(new IndexEngineModule(indexSettings));
    modules.add(new AnalysisModule(indexSettings, 

```

indicesAnalysisService));  
modules.add(new SimilarityModule(indexSettings));  
modules.add(new IndexCacheModule(indexSettings));  
modules.add(new IndexFieldDataModule(indexSettings));  
modules.add(new CodecModule(indexSettings));  
modules.add(new MapperServiceModule());  
modules.add(new IndexQueryParserModule(indexSettings));  
modules.add(new IndexAliasesServiceModule());  
modules.add(new IndexGatewayModule(indexSettings,  
injector.getInstance(Gateway.class)));  
modules.add(new IndexModule(indexSettings));

Above modules injects components into a global injector as singletons. I  
was guessing - each index (lucene index) would have one instance available  
of all this components. But sounds like I am wrong.  
What's the point of maintaining such map objects though -

```
private final Map<String, Injector> indicesInjectors = new HashMap<>();

private volatile ImmutableMap<String, IndexService> indices = 

```

ImmutableMap.of();

I see the only new instance injected into every index is just _Index_ instance  
otherwise all other components are singletons. I am not getting the point  
of keeping it in childInjectors.

Any help is greatly appreciated.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8208259b-4dfc-48da-9c4b-fcf2cef6947e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8208259b-4dfc-48da-9c4b-fcf2cef6947e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:15am UTC](https://discuss.elastic.co/t/child-injectors-or-index-scoped-objects/18657/2 "2017-07-06T01:15:55Z")

</div>

Closed on July 6, 2017, 1:15am UTC


