Reading ttl setting from a file


(emj11) #1

Hi, I am currently reading a mapping from a file, my call to create the
index and mapping is this:

client.admin().indices().create(new
CreateIndexRequest(INDEX).settings(settingsBuilder).mapping(CHAT_TYPE,
chat).mapping(MUC_TYPE, muc)).actionGet();

my 'chat' string (mapping) has the following:
{
"chat" : {
"properties":{
"_timestamp" : {
"enabled" : true
},

"from_jid":{"index":"not_analyzed","type":"string"},

"to_jid":{"index":"not_analyzed","type":"string"},
"_ttl" : { "enabled" : "true", "default" : "2m" },
......

this fails on the ttl line stating:
org.elasticsearch.index.mapper.MapperParsingException: mapping [chat]
at
org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:262)
at
org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:211)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.elasticsearch.index.mapper.MapperParsingException: No type
specified for property [_ttl]

at
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:253)
at
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)
at
org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:161)
at
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:271)
at org.elasticsearch.index.mapper.MapperService.add(MapperService.java:174)
at
org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:259)
... 4 more

It seems the _ttl is not being recognized as an internal field.....

Also, if i enable ttl for a mapping, does ttl need to be enabled on the
cluster level as well? I'm not sure if this is even possible. I would
like to set ttl on the index level rather than a cluster or doc level.

Thanks.

--


(emj11) #2

Additional info...I am running ES v0.19.8 and I am trying to set ttl from a
transport client.

On Thursday, August 30, 2012 10:16:07 AM UTC-4, emj11 wrote:

Hi, I am currently reading a mapping from a file, my call to create the
index and mapping is this:

client.admin().indices().create(new
CreateIndexRequest(INDEX).settings(settingsBuilder).mapping(CHAT_TYPE,
chat).mapping(MUC_TYPE, muc)).actionGet();

my 'chat' string (mapping) has the following:
{
"chat" : {
"properties":{
"_timestamp" : {
"enabled" : true
},

"from_jid":{"index":"not_analyzed","type":"string"},

"to_jid":{"index":"not_analyzed","type":"string"},
"_ttl" : { "enabled" : "true", "default" : "2m" },
......

this fails on the ttl line stating:
org.elasticsearch.index.mapper.MapperParsingException: mapping [chat]
at
org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:262)
at
org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:211)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.elasticsearch.index.mapper.MapperParsingException: No
type specified for property [_ttl]

at
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:253)
at
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)
at
org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:161)
at
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:271)
at org.elasticsearch.index.mapper.MapperService.add(MapperService.java:174)
at
org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:259)
... 4 more

It seems the _ttl is not being recognized as an internal field.....

Also, if i enable ttl for a mapping, does ttl need to be enabled on the
cluster level as well? I'm not sure if this is even possible. I would
like to set ttl on the index level rather than a cluster or doc level.

Thanks.

--


(emj11) #3

bump....

how is the community assigning ttl for documents? Are you setting it at
the mapping level or the document level?

--


(system) #4