Range query requires mapping type in field spec?


(Zaar Hai) #1

Hello,

I have index with numerous mapping types. I'm invoking a search with range
query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "timestamp":
{"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less
then 1383467660. Specifying the field as "events.timestamp". Does the trick
:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0, "id": 1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range query, it
works both ways. The only difference I can spot that id is of type long and
timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.


(Zaar Hai) #2

Anyone please?

On Sunday, November 17, 2013 10:08:11 AM UTC+2, Zaar Hai wrote:

Hello,

I have index with numerous mapping types. I'm invoking a search with range
query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "timestamp":
{"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less
then 1383467660. Specifying the field as "events.timestamp". Does the trick
:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0, "id":
1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range query,
it works both ways. The only difference I can spot that id is of type long
and timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.


(Jun Ohtani) #3

Hi Zaar,

Could you send the following command to ES.
I think that timestamp field is nested.

curl -XGET localhost:9200/restful/events/_mapping?pretty

Regards,
Jun

2013/11/17 Zaar Hai haizaar@gmail.com

Hello,

I have index with numerous mapping types. I'm invoking a search with range
query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "timestamp":
{"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less
then 1383467660. Specifying the field as "events.timestamp". Does the trick
:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0, "id":
1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range query,
it works both ways. The only difference I can spot that id is of type long
and timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.


(Zaar Hai) #4

Thanks Jun,
The output is below. I use dynamic mapping templates heavily since I have a
lot of mapping types.

curl -XGET localhost:9200/restful/events/_mapping?pretty

{
"events" : {
"dynamic_templates" : [ {
"template_string" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"index_analyzer" : "verbatim",
"type" : "string"
}
}
},
"match" : "",
"match_mapping_type" : "string"
}
}, {
"template_integer" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "integer"
}
}, {
"template_long" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "long"
}
}, {
"template_double" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "double"
}
}, {
"template_date" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "date"
}
}, {
"template_boolean" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "boolean"
}
} ],
"properties" : {
"id" : {
"type" : "multi_field",
"fields" : {
"id" : {
"type" : "long"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
},
"timestamp" : {
"type" : "multi_field",
"fields" : {
"timestamp" : {
"type" : "double"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
}
}
}
}

On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:

Hi Zaar,

Could you send the following command to ES.
I think that timestamp field is nested.

curl -XGET localhost:9200/restful/events/_mapping?pretty

Regards,
Jun

2013/11/17 Zaar Hai <hai...@gmail.com <javascript:>>

Hello,

I have index with numerous mapping types. I'm invoking a search with
range query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "timestamp":
{"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less
then 1383467660. Specifying the field as "events.timestamp". Does the trick
:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query":
{"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0, "id":
1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range query,
it works both ways. The only difference I can spot that id is of type long
and timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.


(Jun Ohtani) #5

Hi,

I try to execute the following gist procedure.
But I have results both your search request: no prefix and exist prefix.
Sorry, I don't know why your query to fail...

2013/11/18 Zaar Hai haizaar@gmail.com

Thanks Jun,
The output is below. I use dynamic mapping templates heavily since I have
a lot of mapping types.

curl -XGET localhost:9200/restful/events/_mapping?pretty

{
"events" : {
"dynamic_templates" : [ {
"template_string" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"index_analyzer" : "verbatim",
"type" : "string"
}
}
},
"match" : "",
"match_mapping_type" : "string"
}
}, {
"template_integer" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "integer"
}
}, {
"template_long" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "long"
}
}, {
"template_double" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "double"
}
}, {
"template_date" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "date"
}
}, {
"template_boolean" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "boolean"
}
} ],
"properties" : {
"id" : {
"type" : "multi_field",
"fields" : {
"id" : {
"type" : "long"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
},
"timestamp" : {
"type" : "multi_field",
"fields" : {
"timestamp" : {
"type" : "double"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
}
}
}
}

On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:

Hi Zaar,

Could you send the following command to ES.
I think that timestamp field is nested.

curl -XGET localhost:9200/restful/events/_mapping?pretty

Regards,
Jun

2013/11/17 Zaar Hai hai...@gmail.com

Hello,

I have index with numerous mapping types. I'm invoking a search with
range query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{
"query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less
then 1383467660. Specifying the field as "events.timestamp". Does the trick
:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{
"query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0,
"id": 1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range query,
it works both ways. The only difference I can spot that id is of type long
and timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.

For more options, visit https://groups.google.com/groups/opt_out.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.


(Zaar Hai) #6

Thanks for an attempt Jun,

I've dug it further and the problem is that I have another mapping type
that also has a timestamp field with type long. However I still did not
succeed reproducing it in a small isolated code.

On Monday, November 18, 2013 9:45:02 AM UTC+2, Jun Ohtani wrote:

Hi,

I try to execute the following gist procedure.
But I have results both your search request: no prefix and exist prefix.
Sorry, I don't know why your query to fail...

https://gist.github.com/johtani/7524077

2013/11/18 Zaar Hai <hai...@gmail.com <javascript:>>

Thanks Jun,
The output is below. I use dynamic mapping templates heavily since I have
a lot of mapping types.

curl -XGET localhost:9200/restful/events/_mapping?pretty

{
"events" : {
"dynamic_templates" : [ {
"template_string" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"index_analyzer" : "verbatim",
"type" : "string"
}
}
},
"match" : "",
"match_mapping_type" : "string"
}
}, {
"template_integer" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "integer"
}
}, {
"template_long" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "long"
}
}, {
"template_double" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "double"
}
}, {
"template_date" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "date"
}
}, {
"template_boolean" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "boolean"
}
} ],
"properties" : {
"id" : {
"type" : "multi_field",
"fields" : {
"id" : {
"type" : "long"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
},
"timestamp" : {
"type" : "multi_field",
"fields" : {
"timestamp" : {
"type" : "double"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
}
}
}
}

On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:

Hi Zaar,

Could you send the following command to ES.
I think that timestamp field is nested.

curl -XGET localhost:9200/restful/events/_mapping?pretty

Regards,
Jun

2013/11/17 Zaar Hai hai...@gmail.com

Hello,

I have index with numerous mapping types. I'm invoking a search with
range query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{
"query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less
then 1383467660. Specifying the field as "events.timestamp". Does the trick
:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{
"query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0,
"id": 1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range
query, it works both ways. The only difference I can spot that id is of
type long and timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.

For more options, visit https://groups.google.com/groups/opt_out.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.


(Jun Ohtani) #7

Hi Zaar,

I think that your problem is related this section.
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping.html#all-mapping-types

Maybe you should use different field name each “mapping type" in the same index.

Regards


Jun Ohtani
johtani@gmail.com
blog : http://blog.johtani.info
twitter : http://twitter.com/johtani

2013/11/19 18:18、Zaar Hai haizaar@gmail.com のメール:

Thanks for an attempt Jun,

I've dug it further and the problem is that I have another mapping type that also has a timestamp field with type long. However I still did not succeed reproducing it in a small isolated code.

On Monday, November 18, 2013 9:45:02 AM UTC+2, Jun Ohtani wrote:
Hi,

I try to execute the following gist procedure.
But I have results both your search request: no prefix and exist prefix.
Sorry, I don't know why your query to fail...

https://gist.github.com/johtani/7524077

2013/11/18 Zaar Hai hai...@gmail.com
Thanks Jun,
The output is below. I use dynamic mapping templates heavily since I have a lot of mapping types.

curl -XGET localhost:9200/restful/events/_mapping?pretty

{
"events" : {
"dynamic_templates" : [ {
"template_string" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"index_analyzer" : "verbatim",
"type" : "string"
}
}
},
"match" : "",
"match_mapping_type" : "string"
}
}, {
"template_integer" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "integer"
}
}, {
"template_long" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "long"
}
}, {
"template_double" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "double"
}
}, {
"template_date" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "date"
}
}, {
"template_boolean" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "boolean"
}
} ],
"properties" : {
"id" : {
"type" : "multi_field",
"fields" : {
"id" : {
"type" : "long"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
},
"timestamp" : {
"type" : "multi_field",
"fields" : {
"timestamp" : {
"type" : "double"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
}
}
}
}

On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:
Hi Zaar,

Could you send the following command to ES.
I think that timestamp field is nested.

curl -XGET localhost:9200/restful/events/_mapping?pretty

Regards,
Jun

2013/11/17 Zaar Hai hai...@gmail.com
Hello,

I have index with numerous mapping types. I'm invoking a search with range query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less then 1383467660. Specifying the field as "events.timestamp". Does the trick :

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{ "query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": { "events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0, "id": 1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range query, it works both ways. The only difference I can spot that id is of type long and timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.

For more options, visit https://groups.google.com/groups/opt_out.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.

--
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.


(Zaar Hai) #8

Yeap, that's my case!
Funny, I remember reading it back in a while...

Thanks for your help Jun!

Zaar

On Tuesday, November 19, 2013 11:29:21 AM UTC+2, Jun Ohtani wrote:

Hi Zaar,

I think that your problem is related this section.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping.html#all-mapping-types

Maybe you should use different field name each “mapping type" in the same
index.

Regards


Jun Ohtani
joh...@gmail.com <javascript:>
blog : http://blog.johtani.info
twitter : http://twitter.com/johtani

2013/11/19 18:18、Zaar Hai <hai...@gmail.com <javascript:>> のメール:

Thanks for an attempt Jun,

I've dug it further and the problem is that I have another mapping type
that also has a timestamp field with type long. However I still did not
succeed reproducing it in a small isolated code.

On Monday, November 18, 2013 9:45:02 AM UTC+2, Jun Ohtani wrote:
Hi,

I try to execute the following gist procedure.
But I have results both your search request: no prefix and exist prefix.
Sorry, I don't know why your query to fail...

https://gist.github.com/johtani/7524077

2013/11/18 Zaar Hai hai...@gmail.com
Thanks Jun,
The output is below. I use dynamic mapping templates heavily since I
have a lot of mapping types.

curl -XGET localhost:9200/restful/events/_mapping?pretty

{
"events" : {
"dynamic_templates" : [ {
"template_string" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"index_analyzer" : "verbatim",
"type" : "string"
}
}
},
"match" : "",
"match_mapping_type" : "string"
}
}, {
"template_integer" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "integer"
}
}, {
"template_long" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "long"
}
}, {
"template_double" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "double"
}
}, {
"template_date" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "",
"match_mapping_type" : "date"
}
}, {
"template_boolean" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"str" : {
"index_analyzer" : "substrings",
"type" : "string"
},
"{name}" : {
"type" : "{dynamic_type}"
}
}
},
"match" : "
",
"match_mapping_type" : "boolean"
}
} ],
"properties" : {
"id" : {
"type" : "multi_field",
"fields" : {
"id" : {
"type" : "long"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
},
"timestamp" : {
"type" : "multi_field",
"fields" : {
"timestamp" : {
"type" : "double"
},
"str" : {
"type" : "string",
"index_analyzer" : "substrings",
"include_in_all" : false
}
}
}
}
}
}

On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:
Hi Zaar,

Could you send the following command to ES.
I think that timestamp field is nested.

curl -XGET localhost:9200/restful/events/_mapping?pretty

Regards,
Jun

2013/11/17 Zaar Hai hai...@gmail.com
Hello,

I have index with numerous mapping types. I'm invoking a search with
range query and type restriction like this:

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{
"query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

It yields zero results although there events with timestamp less then
1383467660. Specifying the field as "events.timestamp". Does the trick :

$ curl -XGET http://localhost:9200/restful/_search?pretty -d '{
"query": {"bool": {"must": [{"term": {"_type": "events"}}, {"range": {
"events.timestamp": {"to": 1383467660, "include_upper": false }}}]}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4142135,
"hits" : [ {
"_index" : "restful_copy2",
"_type" : "events",
"_id" : "1",
"_score" : 1.4142135, "_source" : {"timestamp": 1383467425.0,
"id": 1}
} ]
}
}

However I wonder why does it happen? If I use "id" field in range query,
it works both ways. The only difference I can spot that id is of type long
and timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,
Zaar

--
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.

For more options, visit https://groups.google.com/groups/opt_out.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--

Jun Ohtani
blog : http://blog.johtani.info

--
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.


(system) #9