Newbie question: mapping


(canal) #1

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


(canal) #2

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
To: 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


(canal) #3

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
To: 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
To: 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


(canal) #4

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


From: go canal gocanal@yahoo.com
To: 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
To: 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
To: 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


(system) #5