# ES requires me to specify the type of data that I do not want to index

**URL:** <https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404>\
**Category:** Elasticsearch\
**Created:** [August 8, 2019, 10:40am UTC](https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404 "2019-08-08T10:40:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GreenX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greenx/32/51751_2.png) [@GreenX](https://discuss.elastic.co/u/GreenX)\
**Post date:** [August 8, 2019, 10:40am UTC](https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404/1 "2019-08-08T10:40:50Z")

</div>

I want to save some data just in case (Suddenly, later come in handy).  
I need them to not be indexed and not involved in the search.  
If this data is later needed, I will get it from \_source.  
I tried to add mapping, but ES swears:

```auto
curl -s -H 'content-type: application/json; charset=UTF-8' "http://localhost:9205/test123/_mapping/searchtype?pretty" -XPUT -d'{"properties" : {"name2":{"index":false}}}'
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "No type specified for field [name2]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "No type specified for field [name2]"
  },
  "status" : 400
}

```

Why? This data is in the original JSON.  
ES 6.8.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 9, 2019, 6:00am UTC](https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404/2 "2019-08-09T06:00:11Z")

</div>

you need to specify the type of a field that you want to add. I suppose in this case it should be `text` or `keyword`.

--Alex

---

<div class="post-metadata">

**Author:** ![GreenX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greenx/32/51751_2.png) [@GreenX](https://discuss.elastic.co/u/GreenX)\
**Post date:** [August 9, 2019, 7:24am UTC](https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404/3 "2019-08-09T07:24:50Z")

</div>

You did not understand.  
I know that can specify the type and everything will work.  
But I believe that this is not correct.  
Suppose there is a flow of documents of the form:

```auto
{
  "name":"book3.pdf",
  "type":"book",
  "body":"......"
}
{
  "name":"rec9.pdf",
  "type":"recipе",
  "body":"......"
}
{
  "name":"crt7.pdf",
  "type":"certificate",
  "body":"......"
}

```

I analyze them through a pipeline script. For example:

```auto
"source":"if(ctx.type != 'book')ctx.notanalyzed=ctx.remove(body)"

```

I want to fully process only part of the documents. That is, all fields are indexed and searched by them. About the other part, I only need to know the name and type. Since there can be many documents, and the body can be large, I do not want unnecessary fields to be indexed at all. And I can’t remove the body field from them, because the client can come tomorrow and say: _"We also need to find certificates!"._ In this case, I just correct the script and reindex the documents.

It is clear that in most cases it will be "text". But why should I specify a type for a field if I don't want to analyze and index it. There's some raw data. This data should only remain in \_source and not be included in the index.

---

<div class="post-metadata">

**Author:** ![AlanWoodward](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alanwoodward/32/41962_2.png) [@AlanWoodward](https://discuss.elastic.co/u/AlanWoodward)\
**Post date:** [August 20, 2019, 9:23am UTC](https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404/4 "2019-08-20T09:23:20Z")

</div>

> This data should only remain in \_source and not be included in the index.

You should be able to achieve this by creating a text field mapping with 'index: false'

---

<div class="post-metadata">

**Author:** ![GreenX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greenx/32/51751_2.png) [@GreenX](https://discuss.elastic.co/u/GreenX)\
**Post date:** [August 20, 2019, 9:36am UTC](https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404/5 "2019-08-20T09:36:44Z")

</div>

Naturally, I have two fields in mapping. "Body" to search and "noindexed" not to search.

---

<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:** [September 17, 2019, 9:40am UTC](https://discuss.elastic.co/t/es-requires-me-to-specify-the-type-of-data-that-i-do-not-want-to-index/194404/6 "2019-09-17T09:40:49Z")

</div>

Closed on September 17, 2019, 9:40am UTC

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