# ElasticSearch.net AND NEST - Indexing without storing file content

**URL:** <https://discuss.elastic.co/t/elasticsearch-net-and-nest-indexing-without-storing-file-content/237526>\
**Category:** Elasticsearch\
**Created:** [June 17, 2020, 7:22pm UTC](https://discuss.elastic.co/t/elasticsearch-net-and-nest-indexing-without-storing-file-content/237526 "2020-06-17T19:22:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvickery](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@kvickery](https://discuss.elastic.co/u/kvickery)\
**Post date:** [June 17, 2020, 7:22pm UTC](https://discuss.elastic.co/t/elasticsearch-net-and-nest-indexing-without-storing-file-content/237526/1 "2020-06-17T19:22:20Z")

</div>

I am using the NEST API with [Elasticsearch.NET](http://Elasticsearch.NET), and Visual Basic. With the latest version of Elasticsearch how can I create an index so that the when a file is indexed the entire file content is not stored on the server?

Below are my current calls to Indices.Create and PutPipeline. My understanding is that the AllField constructor is now obsolete and ignored - but I think this is what stopped the file content from being stored in in previous versions with the CreateIndex method.

```auto
            Dim result = client.Indices.Create(index_name,
                                                Function(ms) ms.Map(Of IndexFile)(
                                                    Function(m) m.AutoMap().AllField(
                                                        Function(al) al.Enabled(False)).Properties(
                                                            Function(ps) ps.Object(Of Nest.Attachment)(
                                                                Function(a) a.Name(
                                                                    Function(n) n.Attachment).AutoMap()))
                                        ).Settings(
                                            Function(a) a.Analysis(
                                                Function(aa) aa.Analyzers(
                                                    Function(am) am.Custom("filename_analyzier",
                                                        Function(ca) ca.Filters("lowercase", "stop").Tokenizer("whitespace"))))))

           Dim putPipelineResponse = client.Ingest.PutPipeline("attachments",
                                                Function(p) p.Description("Document Attachment Pipeline").Processors(
                                                    Function(pr) pr.Attachment(Of IndexFile)(
                                                        Function(a) a.Field(Function(f) f.FileContent).TargetField(
                                                            Function(f) f.Attachment)).Remove(Of IndexFile)(
                                                                Function(r) r.Field(
                                                                    Function(f) f.Field(Of String)(
                                                                        Function(ff) ff.FileContent)))))

```

---

<div class="post-metadata">

**Author:** ![kvickery](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@kvickery](https://discuss.elastic.co/u/kvickery)\
**Post date:** [June 17, 2020, 7:56pm UTC](https://discuss.elastic.co/t/elasticsearch-net-and-nest-indexing-without-storing-file-content/237526/2 "2020-06-17T19:56:25Z")

</div>

Can I just revise my class something like?:

```auto
Public Class IndexFile

        Public Property Attachment As Attachment
        <ElasticProperty(Store:=False)>
        Public Property FileContent As String
        Public Property FileName As String
        Public Property Description As String

End Class

```

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [June 17, 2020, 11:20pm UTC](https://discuss.elastic.co/t/elasticsearch-net-and-nest-indexing-without-storing-file-content/237526/3 "2020-06-17T23:20:49Z")

</div>

You can use

```auto
Public Class IndexFile

        Public Property Attachment As Attachment
        <Text(Store:=False, Index:=false)>
        Public Property FileContent As String
        Public Property FileName As String
        Public Property Description As String

End Class

```

so that the file content is not stored or indexed in Elasticsearch.

What might be better though is to remove the file content field in the ingest pipeline with a [remove processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/remove-processor.html), after running the [attachment processor](https://www.elastic.co/guide/en/elasticsearch/plugins/current/using-ingest-attachment.html), [like this blog post does](https://www.elastic.co/blog/the-future-of-attachments-for-elasticsearch-and-dotnet#mappings-and-pipelines).

---

<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 15, 2020, 11:20pm UTC](https://discuss.elastic.co/t/elasticsearch-net-and-nest-indexing-without-storing-file-content/237526/4 "2020-07-15T23:20:57Z")

</div>

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