Query inner object without knowing parent key path

I have a items with below structure

{
    "user_id" : "unique id for the user",
    "minutes": {
        "2019-1-11T14:41:00.000Z": {
            "interest_1" : {
                    "count" : 2,
                    "obs" : [
                            "req_id_1","req_id_2"
                    ]
            },
            "date" : "2019-1-11T14:41:00.000Z"
        },
        "2019-1-15T12:18:00.000Z": {
            "interest_1" : {
                    "count" : 1,
                    "obs" : [
                            "req_id_3"
                    ]
            },
            "interest_2" : {
                    "count" : 1,
                    "obs" : [
                            "req_id_4"
                    ]
            },
            "date" : "2019-1-15T12:18:00.000Z"
        },
        "2019-1-15T13:27:00.000Z": {
            "interest_1" : {
                    "count" : 3,
                    "obs" : [
                            "req_id_5","req_id_6","req_id_7"
                    ]
            },
            "date" : "2019-1-15T13:27:00.000Z"
        },
        "2019-1-15T20:30:00.000Z": {
            "interest_2" : {
                    "count" : 1,
                    "obs" : [
                            "req_id_8"
                    ]
            },
            "date" : "2019-1-15T20:30:00.000Z"
        }
    }
}

I want to get all users with interest count and observations from a list of interests between a time interval.

For example, i want all users with interest interest_1 between time 2019-1-15T12:00:00.000Z and 2019-1-15T14:00:00.000Z

I am using this structure to track time series event of the user. I know elasticsearch allow inner objects query but we have to know the whole path to inner object from root object. But in my case, i cannot say the parent object key.

What will be the query to get my result or is there any other good method to track time series?

That is a very bad document structure to use as the number of fields in your mappings will just grow and grow over time as you get a new one every minute. I would recommend changing how you structure your data, which will also change how you query it.

Ok. I will figure out the structure.
I need to know how to query on nested key without knowing the parent key path. Is it possible in ElasticSearch?

I have just recommended that you do not use dynamically generated field names like in your example, which means that you would know the key paths.

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