How to make a scripted field with list of keynames from index

I'm using Kibana to report on my test pass results. And I created a doc type that represents the testng-results.xml I get after a test pass finishes. My doctype description looks like this:

                "results": {
                "passed": {
                    "type": "integer"
                },
                "failed": {
                    "type": "integer",
                },
                "skipped": {
                    "type": "integer"
                },
                "start_time": {
                    "type": "date"
                },
                "duration_ms": {
                    "type": "long"
                },
                "test_classes": {
                    "name": {
                        "type": "string"
                    },
                    "test_methods": {
                        "name": {
                            "type": "string"
                        },
                        "status": {
                            "type": "string"
                        },
                        "signature": {
                            "type": "string"
                        },
                        "duration_ms": {
                            "type": "long"
                        },
                        "started_at": {
                            "type": "date"
                        }
                    }
                }
            }

(note: there's a bit of metadata at the top of this doctype that's a bit too identifying for the internet, so I left that part out)

The problem is that I'd like to get a list of all the tests that were run on a particular test pass. However, instead of giving me a list of those, the test name ends up as part of the index instead.
So, when looking at the index, you see a lot of things like this:
results.test_classes.com.blah.foo.doo.duu.TestClassName1.keyword
results.test_classes.com.blah.foo.doo.duu.TestClassName2.keyword
results.test_classes.com.blah.foo.doo.duu.TestClassName3.keyword
where the "com.blah.foo.doo.duu" is the package name of my test code.

I was expecting to be able to create a data table with all of the tests that were executed in that test pass, but I can't figure out a query to make this happen. Then I sat down to learn painless, because I thought I could just create a scripted field that iterated through all the test classes and added them all to the field. But for some reason, I'm having a really difficult time even doing that. Can someone guide me towards a viable solution for this?

Now I'm getting somewhere!!!!

What I needed to use was the right form of data in the right context. I've been trying all of this using the doc form like so:
doc['my.field.name']
however, I could never get that into a hashmap form where I could call ".keySet()" on it. Then I found the other form you can use to access data:
params['_source']['my']['field']['name'].keySet()
And then, viola', it works!!!!

1 Like

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