NEST vs Elastic query inconsistency

I'm updating an application that used Elastic 1.6 to version 7.15. I've gotten indexing to work and some searching but for some reason filters aren't working. The queries are built dynamically and I think I've managed to translate the classes used to the new ones as needed.

When I inspect the elements in the SearchRequest object before executing the search it looks alright and looking at the reply (DebugInformation) the filter query looks alright, but the filter section logged by Elastic is missing field names. The query part is still correct.

Filter section as Nest/DebugInformation reports it:

"filter": [{
                    "bool": {
                        "must": [{
                                "bool": {
                                    "must_not": [{
                                            "range": {
                                                "startPublish": {
                                                    "gte": "2021-11-26T11:28:41"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }, {
                                "bool": {
                                    "must_not": [{
                                            "range": {
                                                "stopPublish": {
                                                    "lte": "2021-11-26T11:28:41"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }, {
                                "bool": {
                                    "should": [{
                                            "bool": {
                                                "must_not": [{
                                                        "terms": {
                                                            "_type": ["EventPageIndexEntity"]
                                                        }
                                                    }
                                                ]
                                            }
                                        }, {
                                            "range": {
                                                "to": {
                                                    "gte": "2021-11-26T11:28:00",
                                                    "lt": "9999-12-31T23:59:59"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }, {
                                "terms": {
                                    "acl": ["Intranet", "Everyone"]
                                }
                            }
                        ]
                    }
                }
            ]

Same section as Elastic logs it:

"filter": [{
                    "bool": {
                        "must": [{
                                "bool": {
                                    "must_not": [{
                                            "match_none": {
                                                "boost": 1.0
                                            }
                                        }
                                    ],
                                    "adjust_pure_negative": true,
                                    "boost": 1.0
                                }
                            }, {
                                "bool": {
                                    "must_not": [{
                                            "match_none": {
                                                "boost": 1.0
                                            }
                                        }
                                    ],
                                    "adjust_pure_negative": true,
                                    "boost": 1.0
                                }
                            }, {
                                "bool": {
                                    "should": [{
                                            "bool": {
                                                "must_not": [{
                                                        "match_none": {
                                                            "boost": 1.0
                                                        }
                                                    }
                                                ],
                                                "adjust_pure_negative": true,
                                                "boost": 1.0
                                            }
                                        }, {
                                            "match_none": {
                                                "boost": 1.0
                                            }
                                        }
                                    ],
                                    "adjust_pure_negative": true,
                                    "boost": 1.0
                                }
                            }, {
                                "terms": {
                                    "acl": ["Intranet", "Everyone"],
                                    "boost": 1.0
                                }
                            }
                        ],
                        "adjust_pure_negative": true,
                        "boost": 1.0
                    }
                }
            ]

The field names are gone, where does adjust_pure_negative and match_none come from and how can I make it work?

Ok, so new developments.

  1. Upgraded Newtonsoft.Json which was a few major versions behind but no change. Think I've read somewhere that the latest Nest versions uses a built in Json converter but thought I'd try this anyway.

  2. Posted the Nest/DebugInformation reported Json to Elastic using Postman which worked, no issues, no rewrite of the query in the Elastic logs. I'm now guessing that the query in DebugInformation isnt't what's actually sent to the server.

Still no clue how to fix though.

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