GraphQL sample for facet aggregation
Faceted search lets you aggregate facets to execute a rich, multifaceted search.
A facet aggregation consists of the following parts:
- A definition of which facets to include
- A specification of how to present the facets
- A list of fields from the results that should be included
First, define which facets to include. For example:
facets: {
concepts: [
# Define the Concept Scheme(s) to get Concepts (facets) from, in which language, and how many.
{ connectorId: "poolpartyInstance1", language: "english", first: "10" },
{ connectorId: "poolpartyInstance2", language: "english", first: "10" }
]
}
Next, specify how the results should be presented:
facets {
__typename
... on ConceptFacet {
connectorId # The identifier of the Connector namespace
uri # The URI of the Content Scheme
title # The name of the Content Scheme
concepts {
uri
label
count
}
}
}
Finally, actually specify what to display in the results:
results {
edges {
node {
totalCount
search {
id
title
uri
updatedDate
conceptSchemes {
connectorId # The identifier of the Connector namespace
uri # The URI of the Concept Scheme
title # The name of the Concept Scheme
concepts {
uri
label
}
}
}
broker {
itemId
}
}
}
}
Here's one example of what the results of such a query might looks like:
{
"data": {
"facets": [
{
"__typename": "ConceptFacet",
"conceptSchemeId": "https://myorg.com/MYORG2/271",
"title": "Pasta shapes",
"language": "english",
"concepts": [
{
"conceptId": "https://myorg.com/MYORG2/274",
"label": "spaghetti"
"count": 20
},
{
"conceptId": "https://myorg.com/MYORG2/275",
"label": "linguini"
"count": 15
},
{
"conceptId": "https://myorg.com/MYORG2/276",
"label": "farfalle"
"count": 10
}
]
}
]
}
}