1

We have some data with parent child relationship. But as we search through two scenarios the scores are different.

For this case we have only one record and only one child record in the index.

a) Search with Direct Query on the child IndexType

Direct Query :

{
    "from": 0,
    "size": 20,
    "sort": [
        {
            "_score": {
                "order": "desc"
            }
        }
    ],
    "query": {
        "filtered": {
            "query": {
                "bool": {
                    "must": [
                        {
                            "bool": {
                                "should": [
                                    {
                                        "query_string": {
                                            "query": "search\\ text",
                                            "fields": [
                                                "TYPECHILD.MAINTITLE.edgengramanalyzed^4"
                                            ],
                                            "default_operator": "and",
                                            "boost": 10
                                        }
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        }
    }
}

We get the child record with some score.

b) Search with HasChild for the same record [has_child : score_mode-max].

HasChild Query :

{
    "from": 0,
    "size": 20,
    "sort": [
        {
            "_score": {
                "order": "desc"
            }
        }
    ],
    "query": {
        "filtered": {
            "query": {
                "bool": {
                    "must": [
                        {
                            "has_child": {
                                "type": "TYPE",
                                "score_mode": "max",
                                "query": {
                                    "bool": {
                                        "must": [
                                            {
                                                "bool": {
                                                    "should": [
                                                        {
                                                            "query_string": {
                                                                "query": "search\\ text",
                                                                "fields": [
                                                                    "MAINTITLE.edgengramanalyzed^4"
                                                                ],
                                                                "default_operator": "and",
                                                                "boost": 10
                                                            }
                                                        }
                                                    ]
                                                }
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
}

Here we get the parent record for the child but the score for the same is different.

0 Answers0