Nested Query Does Not Return Data Correctly

I'm doing a query on nested data and the results that should return do not appear in the results.

Query example:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "account": 15620
                    }
                },
                {
                    "nested": {
                        "path": "replies.content",
                        "query": {
                            "bool": {
                                "must": [
                                    {
                                        "term": {
                                            "replies.content.operator": 38228
                                        }
                                    }
                                ]
                            }
                        },
                        "inner_hits": {
                            "_source": false,
                            "docvalue_fields": [
                                "replies.content.historyid"
                            ]
                        }
                    }
                }
            ]
        }
    },
    "aggs": {
        "sum_worktime": {
            "sum": {
                "field": "worktime"
            }
        }
    },
    "_source": [],
    "script_fields": {
        "deadline_ok": {
            "script": {
                "id": "deadline",
                "params": {
                    "current_timestamp": 1527611998216
                }
            }
        },
        "start_deadline_ok": {
            "script": {
                "id": "start_deadline",
                "params": {
                    "current_timestamp": 1527611998216
                }
            }
        }
    },
    "size": 10000,
    "sort": {
        "item": {
            "order": "asc"
        }
    }
}

I have this object inside my return JSON

],
                    "replies": [
                        {
                            "content": [
                                {
                                    "historyid": 6279537,
                                    "message": "Message",
                                    "timestamp": "2018-05-26T17:31:33-03",
                                    "situation": 2,
                                    "operator": 38228,
                                    "start": "2018-05-23T14:40:00-03",
                                    "end": "2018-05-23T15:30:00-03",
                                    "worktime": 3000,
                                    "temp_worktime": 0,
                                    "reopen": null,
                                    "customerid": 0,
                                    "mimetype": "text\/html"
                                }, ...

Note that the id 38228 operator and 6279537 historyid is inside it, but this record does not appear inside inner_hits> replies.content> hits> hits> fields.

Am I doing something wrong on the search?

This is the inner_hits:

"inner_hits": {
    "replies.content": {
        "hits": {
            "total": 4,
            "max_score": 1.0,
            "hits": [
                {
                    "_index": "tickets",
                    "_type": "ticket",
                    "_id": "3915372-15620",
                    "_nested": {
                        "field": "replies.content",
                        "offset": 5
                    },
                    "_score": 1.0,
                    "fields": {
                        "replies.content.historyid": [
                            6119051
                        ]
                    }
                },
                {
                    "_index": "tickets",
                    "_type": "ticket",
                    "_id": "3915372-15620",
                    "_nested": {
                        "field": "replies.content",
                        "offset": 2
                    },
                    "_score": 1.0,
                    "fields": {
                        "replies.content.historyid": [
                            6083419
                        ]
                    }
                },
                {
                    "_index": "tickets",
                    "_type": "ticket",
                    "_id": "3915372-15620",
                    "_nested": {
                        "field": "replies.content",
                        "offset": 1
                    },
                    "_score": 1.0,
                    "fields": {
                        "replies.content.historyid": [
                            6080493
                        ]
                    }
                }
            ]
        }
    }
}

I think I found the problem:

size
The maximum number of hits to return per inner_hits. By default the top three matching hits are returned.

Where do I change this option in my query?

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