# Adding properties automatically

**URL:** <https://discuss.elastic.co/t/adding-properties-automatically/13786>\
**Category:** Elasticsearch\
**Created:** [September 27, 2013, 9:49am UTC](https://discuss.elastic.co/t/adding-properties-automatically/13786 "2013-09-27T09:49:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bibin\_Abraham](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@Bibin\_Abraham](https://discuss.elastic.co/u/Bibin_Abraham)\
**Post date:** [September 27, 2013, 9:49am UTC](https://discuss.elastic.co/t/adding-properties-automatically/13786/1 "2013-09-27T09:49:16Z")

</div>

I created a type 'post'  
_curl -XPUT localhost:9200/facebook/post/\_mapping -d '_  
_{_

- "post": {\*
- 

```
 "_id": {*

```

- 

```
    "path": "post_id"*

```

- 

```
 },*

```

- 

```
 "_ttl": {*

```

- 

```
    "enabled": true*

```

- 

```
 },*

```

- 

```
 "_source": {*

```

- 

```
    "enabled": false*

```

- 

```
 },*

```

- 

```
 "properties": {*

```

- 

```
    "post_id": {*

```

- 

```
       "type": "long"*

```

- 

```
    },*

```

- 

```
    "user": {*

```

- 

```
       "type": "string",*

```

- 

```
       "store": true*

```

- 

```
    },*

```

- 

```
    "message": {*

```

- 

```
       "type": "string",*

```

- 

```
       "store": true*

```

- 

```
    }*

```

- 

```
 }*

```

- }\*  
_}'_

Then I add a document _curl -XPOST -s localhost:9200/facebook/post -d  
'{"post\_id":1,"user":"kimchy","message":"Hello  
World","field1":"foo","field2":"bar"}'_  
It successfully adds the document.

Is this the default behaviour? Shouldn't it throw an exception saying that  
the new properties are not supported for this type\*  
\*  
\*  
\*  
Then I do a simple search: _curl -XPOST -s  
localhost:9200/facebook/post/\_search?q=foo | jq '.'_  
I get the result:  
_{_

- "hits": {\*
- "hits": [\*
- 

```
 {*

```

- 

```
   "_score": 0.11506981,*

```

- 

```
   "_id": "1",*

```

- 

```
   "_type": "post",*

```

- 

```
   "_index": "facebook"*

```

- 

```
 }*

```

- ],\*
- "max\_score": 0.11506981,\*
- "total": 1\*
- },\*
- "\_shards": {\*
- "failed": 0,\*
- "successful": 3,\*
- "total": 3\*
- },\*
- "timed\_out": false,\*
- "took": 4\*  
_}_

Is it possible to make the default value of index for all fields "no"  
rather than 'analyzed' since fields are added automatically?

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [September 27, 2013, 10:25pm UTC](https://discuss.elastic.co/t/adding-properties-automatically/13786/2 "2013-09-27T22:25:30Z")

</div>

Responses inline.

On Fri, Sep 27, 2013 at 2:49 AM, bin [bibin.abraham.dev@gmail.com](mailto:bibin.abraham.dev@gmail.com) wrote:

> I created a type 'post'...
> 
> Then I add a document ..._'_  
> It successfully adds the document.
> 
> Is this the default behaviour? Shouldn't it throw an exception saying that  
> the new properties are not supported for this type

Yes, that is the default behavior. Your mapping will be updated dynamically  
when new fields are indexed. You can change this behavior in two ways:  
setting index.mapper.dynamic to false [1] or setting the dynamic property  
to strict [2].

- 

> - 
> 
> Then I do a simple search: _curl -XPOST -s  
> localhost:9200/facebook/post/\_search?q=foo | jq '.'_  
> I get the result:
> 
> Is it possible to make the default value of index for all fields "no"  
> rather than 'analyzed' since fields are added automatically?

Look into dynamic templates [3].

[1] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping/)  
[2] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/object-type/)  
[3] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type/)

Cheers,

Ivan

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:14am UTC](https://discuss.elastic.co/t/adding-properties-automatically/13786/3 "2017-07-06T02:14:21Z")

</div>


