# Preloading fielddata in c#

**URL:** https://discuss.elastic.co/t/preloading-fielddata-in-c/154954
**Category:** Elasticsearch
**Created:** [November 1, 2018, 4:30am UTC](https://discuss.elastic.co/t/preloading-fielddata-in-c/154954 "2018-11-01T04:30:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![namprat](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@namprat](https://discuss.elastic.co/u/namprat)
#### Post date: [November 1, 2018, 4:30am UTC](https://discuss.elastic.co/t/preloading-fielddata-in-c/154954/1 "2018-11-01T04:30:33Z")

</div>

Trying to implement preloading fielddata using NEST. I have two questions

1. How to preload fielddata for mapped child attachment object
2. After preloading some of the fields, search is still slow for the first run.

Pls someone identify my mistake here

//my code here

var indexResponse = client.CreateIndex(documentsIndex, c =\> c  
.Settings(s =\> s  
.Analysis(a =\> a  
.Analyzers(ad =\> ad  
.Custom("index-file", ca =\> ca  
.CharFilters("html\_strip")  
.Tokenizer("standard-tokenizer")  
.Filters("standard", "lowercase")  
)  
)  
)  
)  
.Mappings(m =\> m  
.Map(mp =\> mp  
.AllField(all =\> all  
.Enabled(false)  
)  
.Properties(ps =\> ps  
.Number(n =\> n  
.Name(nn =\> nn.Id).Fielddata(x=\>x.Loading(FielddataLoading.Eager))  
)  
.Number(n =\> n  
.Name(nn =\> nn.MatterId).Fielddata(x=\>x.Loading(FielddataLoading.Eager))  
)  
.Number(n =\> n  
.Name(nn =\> nn.FirmId)  
)  
.Boolean(n =\> n  
.Name(nn =\> nn.IsRestricted).Fielddata(x =\> x.Loading(FielddataLoading.Eager))  
)  
.Object(a =\> a  
.Name(n =\> n.Attachment)  
.Properties(p =\> p  
.Text(t =\> t  
.Name(n =\> n.Name)  
)  
.Text(t =\> t  
.Name(n =\> n.Content).Store().TermVector(TermVectorOption.WithPositionsOffsets)  
.Analyzer("index-file").Fielddata(true)  
)  
.Text(t =\> t  
.Name(n =\> n.ContentType).Store()  
)  
.Number(n =\> n  
.Name(nn =\> nn.ContentLength).Store()  
)  
.Date(d =\> d  
.Name(n =\> n.Date).Store()  
)  
.Text(t =\> t  
.Name(n =\> n.Author).Store()  
)  
.Text(t =\> t  
.Name(n =\> n.Title).Store()  
)  
.Text(t =\> t  
.Name(n =\> n.Keywords).Store()  
)  
)  
)  
)  
)  
));

---

<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: [November 29, 2018, 4:30am UTC](https://discuss.elastic.co/t/preloading-fielddata-in-c/154954/2 "2018-11-29T04:30:42Z")

</div>

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