# Newbie question: mapping

**URL:** <https://discuss.elastic.co/t/newbie-question-mapping/4018>\
**Category:** Elasticsearch\
**Created:** [March 3, 2011, 3:22am UTC](https://discuss.elastic.co/t/newbie-question-mapping/4018 "2011-03-03T03:22:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![canal](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@canal](https://discuss.elastic.co/u/canal)\
**Post date:** [March 3, 2011, 3:22am UTC](https://discuss.elastic.co/t/newbie-question-mapping/4018/1 "2011-03-03T03:22:32Z")

</div>

Hi,  
Sorry if this has been already answered: sure this is a newbie question: is  
mapping required?

My understanding is, ES is scheme less, so mapping is not required - but I would  
like to verify if this is only true for text based, mapping is required for  
attachment. Is it correct?

if so, for the attachment mapping, do I need to specify all fields, or minimum  
one field with type "attachment" is enough, the additional fields can be added  
dynamically?  
thanks,  
canal

---

<div class="post-metadata">

**Author:** ![canal](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@canal](https://discuss.elastic.co/u/canal)\
**Post date:** [March 3, 2011, 3:58am UTC](https://discuss.elastic.co/t/newbie-question-mapping/4018/2 "2011-03-03T03:58:51Z")

</div>

got an error message when creating the index for the attachment:

Caused by: org.elasticsearch.index.mapper.MapperParsingException: No handler for  
type [attachment] declared on field [file]

My mapping:

private String mapping= "{ "document" : { "properties" : { "file" :  
{"type" : "attachment" } } } }";

Creating the index:

client.admin().indices().create(new  
CreateIndexRequest(indexName).mapping(indexType, mapping)).actionGet();

Something I miss out?  
thanks,  
canal

* * *

From: go canal [gocanal@yahoo.com](mailto:gocanal@yahoo.com)  
To: [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Sent: Thu, March 3, 2011 11:22:32 AM  
Subject: newbie question: mapping

Hi,  
Sorry if this has been already answered: sure this is a newbie question: is  
mapping required?

My understanding is, ES is scheme less, so mapping is not required - but I would  
like to verify if this is only true for text based, mapping is required for  
attachment. Is it correct?

if so, for the attachment mapping, do I need to specify all fields, or minimum  
one field with type "attachment" is enough, the additional fields can be added  
dynamically?  
thanks,  
canal

---

<div class="post-metadata">

**Author:** ![canal](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@canal](https://discuss.elastic.co/u/canal)\
**Post date:** [March 5, 2011, 12:53am UTC](https://discuss.elastic.co/t/newbie-question-mapping/4018/3 "2011-03-05T00:53:20Z")

</div>

Hello,  
Still have no idea why it failed - this is what I did and still getting the same  
error:

----- code to create the index and add mapping -----  
client.admin().indices().create(new CreateIndexRequest(indexName)).actionGet();  
File file = new File ("classpath:test-mapping.json");  
String mapping;  
try {  
mapping =  
IOUtils.toString(getClass().getResourceAsStream("/test-mapping.json"));  
client.admin().indices().putMapping(new  
PutMappingRequest(indexName).source(mapping)).actionGet();  
client.admin().cluster().health(new  
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();  
} catch (IOException e) {  
e.printStackTrace();  
}

----- the mapping file -----  
{  
document : {  
properties : {  
"file" : { type : "attachment" }  
}  
}  
}

----- the error message -----  
Caused by: org.elasticsearch.index.mapper.MapperParsingException: No handler for  
type [attachment] declared on field [file]  
at  
org.elasticsearch.index.mapper.xcontent.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:190)

at  
org.elasticsearch.index.mapper.xcontent.ObjectMapper$TypeParser.parse(ObjectMapper.java:158)

at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:135)

at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:54)

at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:206)  
at  
org.elasticsearch.cluster.metadata.MetaDataMappingService$3.execute(MetaDataMappingService.java:193)

at  
org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:175)

at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)

at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
at java.lang.Thread.run(Thread.java:619)

Really appreciate your help.  
thanks,  
canal

* * *

From: go canal [gocanal@yahoo.com](mailto:gocanal@yahoo.com)  
To: [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Sent: Thu, March 3, 2011 11:58:51 AM  
Subject: Re: newbie question: mapping

got an error message when creating the index for the attachment:

Caused by: org.elasticsearch.index.mapper.MapperParsingException: No handler for  
type [attachment] declared on field [file]

My mapping:

private String mapping= "{ "document" : { "properties" : { "file" :  
{"type" : "attachment" } } } }";

Creating the index:

client.admin().indices().create(new  
CreateIndexRequest(indexName).mapping(indexType, mapping)).actionGet();

Something I miss out?  
thanks,  
canal

* * *

From: go canal [gocanal@yahoo.com](mailto:gocanal@yahoo.com)  
To: [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Sent: Thu, March 3, 2011 11:22:32 AM  
Subject: newbie question: mapping

Hi,  
Sorry if this has been already answered: sure this is a newbie question: is  
mapping required?

My understanding is, ES is scheme less, so mapping is not required - but I would  
like to verify if this is only true for text based, mapping is required for  
attachment. Is it correct?

if so, for the attachment mapping, do I need to specify all fields, or minimum  
one field with type "attachment" is enough, the additional fields can be added  
dynamically?  
thanks,  
canal

---

<div class="post-metadata">

**Author:** ![canal](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@canal](https://discuss.elastic.co/u/canal)\
**Post date:** [March 5, 2011, 1:17am UTC](https://discuss.elastic.co/t/newbie-question-mapping/4018/4 "2011-03-05T01:17:17Z")

</div>

problem solved finally:I did not unzip the downloaded file.  
thanks,  
canal

* * *

From: go canal [gocanal@yahoo.com](mailto:gocanal@yahoo.com)  
To: [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Sent: Sat, March 5, 2011 8:53:20 AM  
Subject: [HELP] Re: newbie question: attachment mapping exception in Java

Hello,  
Still have no idea why it failed - this is what I did and still getting the same  
error:

----- code to create the index and add mapping -----  
client.admin().indices().create(new CreateIndexRequest(indexName)).actionGet();  
File file = new File ("classpath:test-mapping.json");  
String mapping;  
try {  
mapping =  
IOUtils.toString(getClass().getResourceAsStream("/test-mapping.json"));  
client.admin().indices().putMapping(new  
PutMappingRequest(indexName).source(mapping)).actionGet();  
client.admin().cluster().health(new  
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();  
} catch (IOException e) {  
e.printStackTrace();  
}

----- the mapping file -----  
{  
document : {  
properties : {  
"file" : { type : "attachment" }  
}  
}  
}

----- the error message -----  
Caused by: org.elasticsearch.index.mapper.MapperParsingException: No handler for  
type [attachment] declared on field [file]  
at  
org.elasticsearch.index.mapper.xcontent.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:190)

at  
org.elasticsearch.index.mapper.xcontent.ObjectMapper$TypeParser.parse(ObjectMapper.java:158)

at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:135)

at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:54)

at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:206)  
at  
org.elasticsearch.cluster.metadata.MetaDataMappingService$3.execute(MetaDataMappingService.java:193)

at  
org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:175)

at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)

at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
at java.lang.Thread.run(Thread.java:619)

Really appreciate your help.  
thanks,  
canal

* * *

From: go canal [gocanal@yahoo.com](mailto:gocanal@yahoo.com)  
To: [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Sent: Thu, March 3, 2011 11:58:51 AM  
Subject: Re: newbie question: mapping

got an error message when creating the index for the attachment:

Caused by: org.elasticsearch.index.mapper.MapperParsingException: No handler for  
type [attachment] declared on field [file]

My mapping:

private String mapping= "{ "document" : { "properties" : { "file" :  
{"type" : "attachment" } } } }";

Creating the index:

client.admin().indices().create(new  
CreateIndexRequest(indexName).mapping(indexType, mapping)).actionGet();

Something I miss out?  
thanks,  
canal

* * *

From: go canal [gocanal@yahoo.com](mailto:gocanal@yahoo.com)  
To: [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Sent: Thu, March 3, 2011 11:22:32 AM  
Subject: newbie question: mapping

Hi,  
Sorry if this has been already answered: sure this is a newbie question: is  
mapping required?

My understanding is, ES is scheme less, so mapping is not required - but I would  
like to verify if this is only true for text based, mapping is required for  
attachment. Is it correct?

if so, for the attachment mapping, do I need to specify all fields, or minimum  
one field with type "attachment" is enough, the additional fields can be added  
dynamically?  
thanks,  
canal

---

<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, 4:10am UTC](https://discuss.elastic.co/t/newbie-question-mapping/4018/5 "2017-07-06T04:10:50Z")

</div>


