opentargets / issues

Issue tracker for Open Targets Platform and Open Targets Genetics Portal
https://platform.opentargets.org https://genetics.opentargets.org
Apache License 2.0
12 stars 2 forks source link

`facetFilter` in associations endpoint still operating with OR instead of AND #3356

Closed d0choa closed 3 months ago

d0choa commented 3 months ago

Describe the bug When selecting two facet categories in the new PPP functionality, they still behave with an OR operator instead of an AND. We agreed to move to an AND and thought we had implemented it but something didn't work as expected.

Observed behaviour When associations with 1 entity are filtered with specific filter, 1 record is returned

query DiseaseAssociationsQuery {
  disease(efoId: "EFO_0001421") {
    id
    name
    associatedTargets(
      page: {index: 0, size: 50}
      orderByScore: "score"
      enableIndirect: true
      facetFilters: ["hScOK5ABRHpy-SjeK0qR"]
    ) {
      count
    }
  }
}
{
  "data": {
    "disease": {
      "id": "EFO_0001421",
      "name": "liver disease",
      "associatedTargets": {
        "count": 1
      }
    }
  }
}

When adding a second filter, we would never expect more than one record (0 in this case) in and AND scenario...

query DiseaseAssociationsQuery {
  disease(efoId: "EFO_0001421") {
    id
    name
    associatedTargets(
      page: {index: 0, size: 50}
      orderByScore: "score"
      enableIndirect: true
      facetFilters: ["hScOK5ABRHpy-SjeK0qR", "zNAfK5ABRHpy-SjeepSg"]
    ) {
      count
    }
  }
}

We instead get 877 + 1 records:

{
  "data": {
    "disease": {
      "id": "EFO_0001421",
      "name": "liver disease",
      "associatedTargets": {
        "count": 878
      }
    }
  }
}

Expected behaviour The same scenario above should return 0 records as the 2 sets 877 and 1 do not overlap.

Additional context @mbdebian has pinpointed the one line in the API code that might require a change. He can provide additional detail

jdhayhurst commented 3 months ago

This has now been completed with this PR https://github.com/opentargets/platform-api/pull/177 and released.