Request on How to change Mapping for all Indices and types at once?


(shannu) #1

Hello All,

I am trying to change the mapping for the below 3 indices/types I have:

Index/Type

twitter/tweet
facebook/post
rss/feeds

I am trying to follow the info given in the link:
http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html

$ curl -XPUT 'http://localhost:9200/rss/feeds/_mapping' -d '{"feeds" :
{"properties" : {"_all" : {"type" : "string", "store" : "yes"}}}}'
Result : {"ok":true,"acknowledged":true} - (I am able to change the mapping
for the index rss of type feeds)

but If I want to change all of the indices and types at once and tried:
$ curl -XPUT 'http://localhost:9200/_all/_mapping' -d '{"_all" :
{"properties" : {"_all" : {"type" : "string", "store" : "yes"}}}}'

{"error":"ActionRequestValidationException[Validation Failed: 1: mapping
type is missing;]","status":500}

curl -XPUT 'http://localhost:9200/_all/_mapping' -d '{"TYPE??????" :
{"properties" : {"_all" : {"type" : "string", "store" : "yes"}}}}'
so How to make this work ? What will be type ??

*The reson why I wanted to change the Mapping: *

I am Using NEST(.NET API)

I am able to index the objects pretty well, but now when I tried to
serialize the object using Json converter and index the string object(c#
code excutes fine but... I get the following error in ElasticSearch Server:)
*
Failed to excute [index { so n so..., Source so n so...]
org.elasticsearch.index.mapper.MapperParsingException: Malformed content,
must start with an object*

Any help will be much appreciated.

Regards,
Shannu.

--


(Radu Gheorghe) #2

Hi,

I'm not aware of a way to change all your index settings at once. But if
you want to apply a mapping to all your existing indices, you can use the
Cluster State API[0] to get a list of indices and loop through them to
apply your mapping.

If you want to apply the mapping to every new index, you can use index
templates[1] or config mappings[2].

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

[0]
http://www.elasticsearch.org/guide/reference/api/admin-cluster-state.html
[1]
http://www.elasticsearch.org/guide/reference/api/admin-indices-templates.html
[2] http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html

On Mon, Oct 15, 2012 at 12:43 PM, shannu shanmukhaveeranki@gmail.comwrote:

Hello All,

I am trying to change the mapping for the below 3 indices/types I have:

Index/Type

twitter/tweet
facebook/post
rss/feeds

I am trying to follow the info given in the link:
http://www.elasticsearch.org/guide/reference/api/admin-
indices-put-mapping.htmlhttp://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html

$ curl -XPUT 'http://localhost:9200/rss/**feeds/_mappinghttp://localhost:9200/rss/feeds/_mapping'
-d '{"feeds" : {"properties" : {"_all" : {"type" : "string", "store" :
"yes"}}}}'
Result : {"ok":true,"acknowledged":**true} - (I am able to change the
mapping for the index rss of type feeds)

but If I want to change all of the indices and types at once and tried:
$ curl -XPUT 'http://localhost:9200/all/**mappinghttp://localhost:9200/_all/_mapping'
-d '{"_all" : {"properties" : {"_all" : {"type" : "string", "store" :
"yes"}}}}'

{"error":"ActionRequestValidationException[Validation Failed: 1:
mapping type is missing;]","status":500}

curl -XPUT 'http://localhost:9200/all/**mappinghttp://localhost:9200/_all/_mapping'
-d '{"TYPE??????" : {"properties" : {"_all" : {"type" : "string", "store" :
"yes"}}}}'
so How to make this work ? What will be type ??

*The reson why I wanted to change the Mapping: *

I am Using NEST(.NET API)

I am able to index the objects pretty well, but now when I tried to
serialize the object using Json converter and index the string object(c#
code excutes fine but... I get the following error in ElasticSearch Server:)
*
Failed to excute [index { so n so..., Source so n so...]
org.elasticsearch.index.mapper.MapperParsingException: Malformed content,
must start with an object*

Any help will be much appreciated.

Regards,
Shannu.

--


(shannu) #3

Thanks for the reply Radu.

On Monday, October 15, 2012 12:04:45 PM UTC+1, Radu Gheorghe wrote:

Hi,

I'm not aware of a way to change all your index settings at once. But if
you want to apply a mapping to all your existing indices, you can use the
Cluster State API[0] to get a list of indices and loop through them to
apply your mapping.

If you want to apply the mapping to every new index, you can use index
templates[1] or config mappings[2].

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

[0]
http://www.elasticsearch.org/guide/reference/api/admin-cluster-state.html
[1]
http://www.elasticsearch.org/guide/reference/api/admin-indices-templates.html
[2]
http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html

On Mon, Oct 15, 2012 at 12:43 PM, shannu <shanmukh...@gmail.com<javascript:>

wrote:

Hello All,

I am trying to change the mapping for the below 3 indices/types I have:

Index/Type

twitter/tweet
facebook/post
rss/feeds

I am trying to follow the info given in the link:
http://www.elasticsearch.org/guide/reference/api/admin-
indices-put-mapping.htmlhttp://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html

$ curl -XPUT 'http://localhost:9200/rss/**feeds/_mappinghttp://localhost:9200/rss/feeds/_mapping'
-d '{"feeds" : {"properties" : {"_all" : {"type" : "string", "store" :
"yes"}}}}'
Result : {"ok":true,"acknowledged":**true} - (I am able to change the
mapping for the index rss of type feeds)

but If I want to change all of the indices and types at once and tried:
$ curl -XPUT 'http://localhost:9200/all/**mappinghttp://localhost:9200/_all/_mapping'
-d '{"_all" : {"properties" : {"_all" : {"type" : "string", "store" :
"yes"}}}}'

{"error":"ActionRequestValidationException[Validation Failed: 1:
mapping type is missing;]","status":500}

curl -XPUT 'http://localhost:9200/all/**mappinghttp://localhost:9200/_all/_mapping'
-d '{"TYPE??????" : {"properties" : {"_all" : {"type" : "string", "store" :
"yes"}}}}'
so How to make this work ? What will be type ??

*The reson why I wanted to change the Mapping: *

I am Using NEST(.NET API)

I am able to index the objects pretty well, but now when I tried to
serialize the object using Json converter and index the string object(c#
code excutes fine but... I get the following error in ElasticSearch Server:)
*
Failed to excute [index { so n so..., Source so n so...]
org.elasticsearch.index.mapper.MapperParsingException: Malformed
content, must start with an object*

Any help will be much appreciated.

Regards,
Shannu.

--


(system) #4