Elasticsearch still scan all types in a index even if I specify a type


(潘飞) #1

First, put some sample data:

curl -XPUT 'localhost:9200/testindex/action1/1?pretty' -d '
{
"title": "jumping tom",
"val": 101
}'

curl -XPUT 'localhost:9200/testindex/action2/1?pretty' -d '
{
"title": "jumping jerry",
"val": "test"
}'

as you can see, and the mapping is :

{
"action1" : {
"properties" : {
"val" : {
"type" : "long"
},
"title" : {
"type" : "string"
}
}
},
"action2" : {
"properties" : {
"val" : {
"type" : "string"
},
"title" : {
"type" : "string"
}
}
}
}

But when do a aggs action:

curl 'http://192.168.2.245:9200/testindex/action1/_search' -d '
{
"aggs": {
"vals": {
"terms": {
"field": "val"
}
}
}
}'

{
"took" : 37,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [
{
"index" : "testindex",
"shard" : 2,
"status" : 500,
"reason" : "RemoteTransportException[[a00][inet[/192.168.2.246:9300]][search/phase/query]];
nested: ElasticsearchException[java.lang.NumberFormatException: Invalid
shift value (84) in prefixCoded bytes (is encoded value really an INT?)];
nested: UncheckedExecutionException[java.lang.NumberFormatException:
Invalid shift value (84) in prefixCoded bytes (is encoded value really an
INT?)]; nested: NumberFormatException[Invalid shift value (84) in
prefixCoded bytes (is encoded value really an INT?)]; "
}
]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [
]
},
"aggregations" : {
"vals" : {
"buckets" : [
]
}
}
}

The val field in action1 type is mapped to long, but it seems that ES still
scan the action2 type even if I specify the action1 type.

any advice to resolve this issue ? thanks.

不学习,不知道

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Ivan Brusic) #2

All types eventually belong to the same Lucene index and Lucene cannot
handle different types for the same field name. Avoid using the same name
across types if the field type is different.

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#_avoiding_type_gotchas

--
Ivan

On Wed, Jul 30, 2014 at 8:58 PM, panfei cnweike@gmail.com wrote:

First, put some sample data:

curl -XPUT 'localhost:9200/testindex/action1/1?pretty' -d '
{
"title": "jumping tom",
"val": 101
}'

curl -XPUT 'localhost:9200/testindex/action2/1?pretty' -d '
{
"title": "jumping jerry",
"val": "test"
}'

as you can see, and the mapping is :

{
"action1" : {
"properties" : {
"val" : {
"type" : "long"
},
"title" : {
"type" : "string"
}
}
},
"action2" : {
"properties" : {
"val" : {
"type" : "string"
},
"title" : {
"type" : "string"
}
}
}
}

But when do a aggs action:

curl 'http://192.168.2.245:9200/testindex/action1/_search' -d '
{
"aggs": {
"vals": {
"terms": {
"field": "val"
}
}
}
}'

{
"took" : 37,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [
{
"index" : "testindex",
"shard" : 2,
"status" : 500,
"reason" : "RemoteTransportException[[a00][inet[/192.168.2.246:9300]][search/phase/query]];
nested: ElasticsearchException[java.lang.NumberFormatException: Invalid
shift value (84) in prefixCoded bytes (is encoded value really an INT?)];
nested: UncheckedExecutionException[java.lang.NumberFormatException:
Invalid shift value (84) in prefixCoded bytes (is encoded value really an
INT?)]; nested: NumberFormatException[Invalid shift value (84) in
prefixCoded bytes (is encoded value really an INT?)]; "
}
]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [
]
},
"aggregations" : {
"vals" : {
"buckets" : [
]
}
}
}

The val field in action1 type is mapped to long, but it seems that ES
still scan the action2 type even if I specify the action1 type.

any advice to resolve this issue ? thanks.

不学习,不知道

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com
https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8_zgBGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(潘飞) #3

Thanks for the information

2014-08-01 0:55 GMT+08:00 Ivan Brusic ivan@brusic.com:

All types eventually belong to the same Lucene index and Lucene cannot
handle different types for the same field name. Avoid using the same name
across types if the field type is different.

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#_avoiding_type_gotchas

--
Ivan

On Wed, Jul 30, 2014 at 8:58 PM, panfei cnweike@gmail.com wrote:

First, put some sample data:

curl -XPUT 'localhost:9200/testindex/action1/1?pretty' -d '
{
"title": "jumping tom",
"val": 101
}'

curl -XPUT 'localhost:9200/testindex/action2/1?pretty' -d '
{
"title": "jumping jerry",
"val": "test"
}'

as you can see, and the mapping is :

{
"action1" : {
"properties" : {
"val" : {
"type" : "long"
},
"title" : {
"type" : "string"
}
}
},
"action2" : {
"properties" : {
"val" : {
"type" : "string"
},
"title" : {
"type" : "string"
}
}
}
}

But when do a aggs action:

curl 'http://192.168.2.245:9200/testindex/action1/_search' -d '
{
"aggs": {
"vals": {
"terms": {
"field": "val"
}
}
}
}'

{
"took" : 37,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [
{
"index" : "testindex",
"shard" : 2,
"status" : 500,
"reason" : "RemoteTransportException[[a00][inet[/192.168.2.246:9300]][search/phase/query]];
nested: ElasticsearchException[java.lang.NumberFormatException: Invalid
shift value (84) in prefixCoded bytes (is encoded value really an INT?)];
nested: UncheckedExecutionException[java.lang.NumberFormatException:
Invalid shift value (84) in prefixCoded bytes (is encoded value really an
INT?)]; nested: NumberFormatException[Invalid shift value (84) in
prefixCoded bytes (is encoded value really an INT?)]; "
}
]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [
]
},
"aggregations" : {
"vals" : {
"buckets" : [
]
}
}
}

The val field in action1 type is mapped to long, but it seems that ES
still scan the action2 type even if I specify the action1 type.

any advice to resolve this issue ? thanks.

不学习,不知道

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com
https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8_zgBGA%40mail.gmail.com
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8_zgBGA%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
不学习,不知道

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLBGD1c2vd%3DYzrw4fCf-0BvXFTfqWmNOJ8bf6wQRHDVaRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4