Same query excluding different id returns different results when it should not

Hi there,

I have a problem where I'm doing the exact same query, or at least i think from what i can tell, and the only thing that im excluding is a custom id field that matches the id im currently visiting, so for example this query excluding id 83011 is this:

{
    "from": 0,
    "size": 4,
    "sort": [
        {
            "post_date": {
                "order": "desc"
            }
        }
    ],
    "query": {
        "match_all": {
            "boost": 1
        }
    },
    "post_filter": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "should": [
                            {
                                "terms": {
                                    "terms.post_tag.slug": [
                                        "all-keto-recipes"
                                    ]
                                }
                            }
                        ]
                    }
                },
                {
                    "bool": {
                        "must_not": {
                            "terms": {
                                "post_id": [
                                    83011
                                ]
                            }
                        }
                    }
                },
                {
                    "term": {
                        "post_type.raw": "post"
                    }
                },
                {
                    "term": {
                        "post_status": "publish"
                    }
                }
            ]
        }
    }
}

It returns 3 results.

But if i do this other one excluding other id, for example this:

{
    "from": 0,
    "size": 4,
    "sort": [
        {
            "post_date": {
                "order": "desc"
            }
        }
    ],
    "query": {
        "match_all": {
            "boost": 1
        }
    },
    "post_filter": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "should": [
                            {
                                "terms": {
                                    "terms.post_tag.slug": [
                                        "all-keto-recipes"
                                    ]
                                }
                            }
                        ]
                    }
                },
                {
                    "bool": {
                        "must_not": {
                            "terms": {
                                "post_id": [
                                    79070
                                ]
                            }
                        }
                    }
                },
                {
                    "term": {
                        "post_type.raw": "post"
                    }
                },
                {
                    "term": {
                        "post_status": "publish"
                    }
                }
            ]
        }
    }
}

It returns 4, though there's about 70 documents that match the condition "all-keto-recipes" in terms.post_tag.slug

Could you please advise why is this happening and where is my error?

Thanks a lot!

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