Adding properties automatically

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.
For more options, visit https://groups.google.com/groups/opt_out.

Responses inline.

On Fri, Sep 27, 2013 at 2:49 AM, bin 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
[2] Elasticsearch Platform — Find real-time answers at scale | Elastic
[3] Elasticsearch Platform — Find real-time answers at scale | Elastic

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.
For more options, visit https://groups.google.com/groups/opt_out.