Accessing Arrays inside ElasticSearch Script with Painless

Hello there,

actually i am trying to compare bounding boxes and score them. For that i am using a painless script which helps me with the math. Unfortunately in some cases my documents doesn't contain only one coordinate for a bounding box side. So it is saved as

"BB_North" : [
            54.5,
            53.964153
          ],

Not really a problem if i would know how to access the indexes or even if that isn't the case, elastic search would serve me everytime the last coordinate. Both isn't really the case XD. So first i don't really know how to acces a specific index of the array (doc['BB_North'].value only gives one coordinate). And second, because doc['BB_North'].value obviously gives me a coordinate it is not everytime the same coordinate of the same Place. So in my case Elastic search gives me everytime the last coordinate except for the South coordinate. There Elastic search returns the first one. And i don't even know why he is doing this :D.
I maybe could use a little help here XD.

Is there a way to acces a specific index of the array, or maybe the hole array to iterate through it?

That's it,
Cheers.

Oh and sorry for the mistakes, i am not a native english speaker.

What is your mapping for field BB_North?

Sorry, i already bypass the problem by only accessing the first Element of the XML.
My mapping now looks like:

xpath => ["//identificationInfo/*/*/*/EX_Extent/geographicElement[1]/EX_GeographicBoundingBox/northBoundLatitude/Decimal/text()", "BB_North"]

But another question of a problem that lately occured:
Sometimes the EX_Extend keyword isn't three nodes ( ///* ) after identificatioInfo. Sometimes the keyword is only two nodes after the first node. Is there a way to ask if the mapping was correct? I tried already something like

if ["BB_North"] {} else{}

But it didn't seem to work properly. I alway get either the mapping with 3 nodes or the mapping with 2 nodes. But not both.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.