Wrong values returned by script_field for array.values

I've tried to retrieve array values from my data by using script_fields,
but I received inconsistent results.

My mapping:

{

"user": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
},
"other_ids": {
"type": "string",
"index": "not_analyzed"
}
}
}
}

Some test data:

{
"id": "id1",
"other_ids": [
"id2",
"id3"
]
}

{
"id": "id2",
"other_ids": [
"id1"
]
}

{
"id": "id3",
"other_ids": [
"id1",
"id2"
]
}

The "simplified" query:

{
"fields": [
"_source"
],
"query": {
"match_all": {}
},
"script_fields": {
"other_id_script": {
"lang": "groovy",
"script": "doc["other_ids"].values"
}
}
}

The relevant parts from the answer:

"hits" : {
"total" : 3,
"max_score" : 1.0,
"hits" : [ {
"_source":{"id":"id1","other_ids":["id2","id3"]},
"fields" : {
"other_id_script" : [ [ "id1", "id2" ] ]
}
}, {
"_source":{"id":"id2","other_ids":["id1"]},
"fields" : {
"other_id_script" : [ [ "id1", "id2" ] ]
}
}, {
"_source":{"id":"id3","other_ids":["id1","id2"]},
"fields" : {
"other_id_script" : [ [ "id1", "id2" ] ]
}
} ]
}

As we can see the values of other_id_script are differ from the current
doc's other_ids values in the first two cases.

Is it an error, or am I missed something? Any help would be appreciated!

(The whole script can be found here:
https://gist.github.com/baloghz/c27e39ad419a6f4684ab)

Regards!
Zoltan

--
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/7eeec9a3-9675-4744-ac5a-1081273abccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

(My ES version is 1.3.0)

On Thursday, November 6, 2014 4:10:17 PM UTC+1, Zoltan Balogh wrote:

I've tried to retrieve array values from my data by using script_fields,
but I received inconsistent results.

My mapping:

{

"user": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
},
"other_ids": {
"type": "string",
"index": "not_analyzed"
}
}
}
}

Some test data:

{
"id": "id1",
"other_ids": [
"id2",
"id3"
]
}

{
"id": "id2",
"other_ids": [
"id1"
]
}

{
"id": "id3",
"other_ids": [
"id1",
"id2"
]
}

The "simplified" query:

{
"fields": [
"_source"
],
"query": {
"match_all": {}
},
"script_fields": {
"other_id_script": {
"lang": "groovy",
"script": "doc["other_ids"].values"
}
}
}

The relevant parts from the answer:

"hits" : {
"total" : 3,
"max_score" : 1.0,
"hits" : [ {
"_source":{"id":"id1","other_ids":["id2","id3"]},
"fields" : {
"other_id_script" : [ [ "id1", "id2" ] ]
}
}, {
"_source":{"id":"id2","other_ids":["id1"]},
"fields" : {
"other_id_script" : [ [ "id1", "id2" ] ]
}
}, {
"_source":{"id":"id3","other_ids":["id1","id2"]},
"fields" : {
"other_id_script" : [ [ "id1", "id2" ] ]
}
} ]
}

As we can see the values of other_id_script are differ from the current
doc's other_ids values in the first two cases.

Is it an error, or am I missed something? Any help would be appreciated!

(The whole script can be found here:
https://gist.github.com/baloghz/c27e39ad419a6f4684ab)

Regards!
Zoltan

--
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/98508b1b-a3e6-49b6-b49c-0dd10c8bd16c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.