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

Add a `category` filter and match all query to the facet search API #3442

Open jdhayhurst opened 2 months ago

jdhayhurst commented 2 months ago

As a user I want to be able to filter facets by category and return all facet labels for a given category.

Background

Use the category field as filter field and the matchAll query when a "*" query is given.

Tasks

Acceptance tests

How do we know the task is complete?

  1. When I pass a category filter to the facets API, I only receive facets belonging to that category
  2. When I pass "*" as the query in the facets API, I receive all facets belonging to that category/all categories
jdhayhurst commented 2 months ago

New functionality is demonstrated below:

query AllTractabilityAntibodyFacets{
    facets(entityNames: ["target"], queryString: "*", category: "Tractability Antibody") {
    total
    hits {
      label
    }
  }  
}

returns:

{
  "data": {
    "facets": {
      "total": 9,
      "hits": [
        {
          "label": "Approved Drug"
        },
        {
          "label": "Advanced Clinical"
        },
        {
          "label": "GO CC high conf"
        },
        {
          "label": "UniProt loc med conf"
        },
        {
          "label": "GO CC med conf"
        },
        {
          "label": "UniProt loc high conf"
        },
        {
          "label": "Human Protein Atlas loc"
        },
        {
          "label": "Phase 1 Clinical"
        },
        {
          "label": "UniProt SigP or TMHMM"
        }
      ]
    }
  }
}
query QueryTractabilityAntibodyFacets{
    facets(entityNames: ["target"], queryString: "clin", category: "Tractability Antibody") {
    total
    hits {
      label
    }
  }  
}

returns:

{
  "data": {
    "facets": {
      "total": 2,
      "hits": [
        {
          "label": "Advanced Clinical"
        },
        {
          "label": "Phase 1 Clinical"
        }
      ]
    }
  }
}
jdhayhurst commented 2 months ago

here's an example showing how, for example, you can get 3 facets for 3 categories in one request:

query FacetQuery{
  allCategories: facets(queryString: "*", entityNames: ["target"], page: {size:3, index:0}){
    hits {
      label
    }
  }
  tractabilityOther: facets(queryString: "*", entityNames: ["target"], category: "Tractability Other Modalities", page: {size:3, index:0}){
    hits {
      label
    }
  }
  tractabilityPROTAC: facets(queryString: "*", entityNames: ["target"], category: "Tractability PROTAC", page: {size:3, index:0}){
    hits {
      label
    }
  }
}