Thank you, Radu. It looks better know. I don't see any exceptions in the
log any more. But a range search on the date field doesn't work.
This is what my mapping looks like now:
{
"template_1" : {
"template" : "*",
"access-log" : {
"properties" : {
"date" : {
"index" : "not_analyzed",
"type" : "date",
"format" : "dd/MMM/yyyy:HH:mm:ss Z"
}
}
}
}
}
I indexed one document with field that has the date "12/Sep/2012:11:24:02
+0200"
But the following range search has 0 hits:
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '{
"query":{
"bool":{
"must":[
{
"range":{
"accessdate":{
"from":"12/Sep/2012:11:24:00 +0200",
"to":"12/Sep/2012:11:24:05 +0200"
}
}
}
]
}
}
}'
But this search finds the document:
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '{
"query":{
"bool":{
"must":[
{
"range":{
"accessdate":{
"from":"10/Sep/2012:23:59:59 +0200",
"to":"11/Sep/2012:00:00:00 +0200"
}
}
}
]
}
}
}'
It seems that search is successful when the dates have different days
regardless of what is indexed. I tried to find out the 'real' date in the
index is:
curl'http://localhost:9200/_all0/_search?pretty=true' -d '{
"query" : {
"match_all" : { }
},
"script_fields": {
"terms" : {
"script": "doc[field].values",
"params": {
"field": "accessdate"
}
}
}
}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "logstash-2013.02.18",
"_type" : "access-log",
"_id" : "apV2kN7pT8yFmmFnT_W_Mg",
"_score" : 1.0,
"fields" : {
"terms" : [ "02", "0200", "11", "12", "2012", "24", "sep" ]
}
} ]
}
}
I don't know if this is something I can rely on. The date in the index
should be stored as milliseconds since epoche, right? Does this output
means my date is not stored as a date?
Am Samstag, 16. Februar 2013 14:24:01 UTC+1 schrieb Radu Gheorghe:
Hello Ulli,
Elasticsearch expects a mapping type there where you put "date", not a
field name.
So like when you store a document in
http://localhost:9200/test_index/test_type/test_document_ID, "test_type"
is your mapping type.
So your template has to be something like this:
[...]
"mappings": {
"type1": {
"properties": {
"date": {
"type": "date"
}
}
}
}
Best regards,
Radu
http://sematext.com/ -- Elasticsearch -- Solr -- Lucene
On Fri, Feb 15, 2013 at 12:52 PM, Ulli <ulli....@gmx.de <javascript:>>wrote:
Does anybody knows what exactly 'Trying to parse an object but has a
different type [date] for [date]' mean?
So far I've found out that the second '[date]' is the date I configured
in the mapping and try to index as a field. If that means that my input
field has not the type 'date' is there a way to find out what elasticsearch
'thinks' the type of my field is?
Am Donnerstag, 14. Februar 2013 17:14:32 UTC+1 schrieb Ulli:
The configuration of path.conf was wrong but now I see an exception in
the log:
org.elasticsearch.index.**mapper.MapperParsingException: mapping [date]
at org.elasticsearch.cluster.metadata.
MetaDataCreateIndexService$1.**execute(MetaDataCreateIndexService.
java:262)
at org.elasticsearch.cluster.service.
InternalClusterService$2.run(**InternalClusterService.java:**208)
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:679)
Caused by: org.elasticsearch.index.**mapper.MapperParsingException:
Trying to parse an object but has a different type [date] for [date]
at org.elasticsearch.index.mapper.object.ObjectMapper$
TypeParser.parse(ObjectMapper.**java:206)
at org.elasticsearch.index.mapper.DocumentMapperParser.
parse(DocumentMapperParser.**java:161)
at org.elasticsearch.index.mapper.MapperService.parse(
MapperService.java:364)
at org.elasticsearch.index.mapper.MapperService.add(
MapperService.java:186)
at org.elasticsearch.cluster.metadata.
MetaDataCreateIndexService$1.**execute(MetaDataCreateIndexService.
java:259)
Am Donnerstag, 14. Februar 2013 16:57:56 UTC+1 schrieb Ulli:
Hi,
I'm trying to create an index mapping via template file as descirbed
here: Elasticsearch Platform — Find real-time answers at scale | Elastic**
indices-templates.htmlhttp://www.elasticsearch.org/guide/reference/api/admin-indices-templates.html
So I created the following template file in config/templates/template_1.
**json:
{
"template_1" : {
"template" : "*",
"mappings" : {
"date" : {
"index" : "not_analyzed",
"type" : "date",
"format" : "dd/MMM/yyyy:HH:mm:ss Z"
}
}
}
}
with no effect:
curl -XGET localhost:9200/_template/**template_1
{}
When I put the mapping via curl request:
curl -XPUT localhost:9200/_template/**template_1 -d '
{
"template" : "*",
"mappings" : {
"date" : {
"index" : "not_analyzed",
"type" : "date",
"format" : "dd/MMM/yyyy:HH:mm:ss Z"
}
}
}
'
it works:
curl -XGET localhost:9200/_template/**template_1?pretty=true
{
"template_1" : {
"template" : "*",
"order" : 0,
"settings" : { },
"mappings" : {
"date" : {
"index" : "not_analyzed",
"format" : "dd/MMM/yyyy:HH:mm:ss Z",
"type" : "date"
}
}
}
}
So, what do I have to do to make it working via template file?
Thanks in advance
Ulli
--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.
--
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.