# Store and index "no" not working

**URL:** https://discuss.elastic.co/t/store-and-index-no-not-working/38589
**Category:** Elasticsearch
**Created:** [January 7, 2016, 9:56am UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589 "2016-01-07T09:56:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 7, 2016, 9:56am UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/1 "2016-01-07T09:56:19Z")

</div>

Here comes another offspring to this question: [Exclude complete path from indexing and \_source](https://discuss.elastic.co/t/exclude-complete-path-from-indexing-and--source/37854/11)

What I want to achieve here is to  
-exclude a field called "ignoreme" from the \_source AND  
-exclude the very same field from the index itself

So in the following example, I start with the following index creation:

```
curl -XPOST 'http://192.168.56.102:9200/test' -d '{"mappings":
{"my_type":{"_all":{"enabled":false},
"_source":{"excludes":["ignoreme"]},
"dynamic_templates":[{"skip":{"match":"ignoreme","mapping":{"type":"string","store":"no","index":"no"}}}]}}}'

```

The index then looks like this:

```
curl -XGET http://192.168.56.102:9200/test?pretty
{
  "test" : {
    "aliases" : { },
    "mappings" : {
      "my_type" : {
        "_all" : {
          "enabled" : false
        },
        "_source" : {
          "excludes" : ["ignoreme"]
        },
        "dynamic_templates" : [ {
          "skip" : {
            "mapping" : {
              "index" : "no",
              "store" : "no",
              "type" : "string"
            },
            "match" : "ignoreme"
          }
        } ]
      }
    },....

```

Next, I post this document:

```
curl -XPOST 'http://192.168.56.102:9200/test/my_type/1' -d '{"title":"Something","ignoreme":"I should not be here"}'

```

I now expect that "ignoreme" should not be searchable at all, but when I run a query for the word "here" in "ignoreme", I still get a result:

```
curl -XGET http://192.168.56.102:9200/test/my_type/_search?pretty&q=ignoreme:here
[1] 3463
ben@ben-ubuntu14:~$ {
  "took" : 7,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test",
      "_type" : "my_type",
      "_id" : "1",
      "_score" : 1.0,
      "_source":{"title":"Something"}
    } ]
  }
}

```

So what do I have to do to TRULY and COMPLETELY exclude "ignoreme"?

In addition, I am wondering whether this type of mapping is also possible for arrays and/or object types.  
E.g. if I have an array of strings like this:  
"messages":["Help, I need someboy","It's been a hard days night","Norwegian Wood"]  
is there a way to exclude the complete array from being indexed and added to the \_source?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 8, 2016, 9:31am UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/2 "2016-01-08T09:31:07Z")

</div>

Can you print your mapping?

```
GET test/my_type/_mapping
```

---

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 8, 2016, 1:41pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/3 "2016-01-08T13:41:36Z")

</div>

Sure, here it is:

```
curl -XGET http://192.168.56.102:9200/test/_mapping/my_type?pretty

{
  "test" : {
    "mappings" : {
      "my_type" : {
        "_all" : {
          "enabled" : false
        },
        "_source" : {
          "excludes" : ["ignoreme"]
        },
        "dynamic_templates" : [ {
          "skip" : {
            "mapping" : {
              "index" : "no",
              "store" : "no",
              "type" : "string"
            },
            "match" : "ignoreme"
          }
        } ],
        "properties" : {
          "ignoreme" : {
            "type" : "string"
          },
          "title" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

```

I.e. this is what the mappings look like after I have POSTed my test document.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 8, 2016, 2:17pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/4 "2016-01-08T14:17:10Z")

</div>

As you can see, your template has not been applied.

May be you add this mapping on an existing index?

This script works well:

```auto
DELETE index
PUT index
{
  "mappings": {
    "type": {
      "dynamic_templates": [
        {
          "skip": {
            "match": "ignoreme",
            "mapping": {
              "type": "string",
              "index": "no",
              "store": "no"
            }
          }
        }
      ]
    }
  }
}
PUT index/type/1
{
  "ignoreme": "foo"
}
GET index/type/_mapping

```

---

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 8, 2016, 3:33pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/5 "2016-01-08T15:33:25Z")

</div>

Hi David,

If you look at my example, this is basically what I have done.

I have now tested some more and left out this part from the initial POST

```
 "_all" : {
      "enabled" : false
    },
    "_source" : {
      "excludes" : ["ignoreme"]
    },

```

After that, the mapping looks better:

```
{
  "test" : {
    "mappings" : {
      "my_type" : {
        "dynamic_templates" : [ {
          "skip" : {
            "mapping" : {
              "index" : "no",
              "store" : "no",
              "type" : "string"
            },
            "match" : "ignoreme"
          }
        } ],
        "properties" : {
          "ignoreme" : {
            "type" : "string",
            "index" : "no"
          },
          "title" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

```

However, the query:

```
  curl -XGET http://192.168.56.102:9200/test/my_type/_search?pretty&q=ignoreme:here

```

still returns the document. This puzzles me.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 8, 2016, 4:07pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/6 "2016-01-08T16:07:33Z")

</div>

Remove the pretty in case you are doing something wrong with the command line. I suspect your score is 1 here so no criteria has been applied.

This works well for me:

```auto
DELETE index
PUT index
{
  "mappings": {
    "type": {
      "dynamic_templates": [
        {
          "skip": {
            "match": "ignoreme",
            "mapping": {
              "type": "string",
              "index": "no",
              "store": "no"
            }
          }
        }
      ]
    }
  }
}
PUT index/type/1
{
  "ignoreme": "foo"
}
GET index/type/_search
{
  "query": {
    "match": {
      "ignoreme": "foo"
    }
  }
}
GET index/type/_search?q=ignoreme:foo

```

---

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 8, 2016, 7:54pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/7 "2016-01-08T19:54:38Z")

</div>

Yes, that did it.  
So

```
curl -XGET http://192.168.56.102:9200/test/my_type/_search?q=ignoreme:here 

```

returns the correct (empty) result, while

```
curl -XGET http://192.168.56.102:9200/test/my_type/_search?pretty&q=ignoreme:here 

```

does not.  
I wonder if there is still a way to add the "pretty" param to this search URL. All the examples in the documentation are pretty-printed, so it should be possible I guess?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 8, 2016, 8:05pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/8 "2016-01-08T20:05:56Z")

</div>

Wrap the URL in ""

---

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 8, 2016, 8:26pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/9 "2016-01-08T20:26:39Z")

</div>

🙂  
Cheers!

---

<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 5, 2017, 11:25pm UTC](https://discuss.elastic.co/t/store-and-index-no-not-working/38589/10 "2017-07-05T23:25:51Z")

</div>


