Documentation Center

Faceted search result count query 3: a minimal faceted search using AND

The third query adds a concept to the query using an AND operator. Because of this, the total number of hits is fewer than in queries 1 and 2: the number of hits is now not 284 but 2, because there are aggregations for 2 items.

Query

{
  search(
    criteria: {
      concept:{connectorId:"ingredients",  conceptIds:["e-learning-poolparty-biz_cocktails_3c94f5fc_4664_4177_a880_88643c0be9c1"]}
      and: {
        field: {key: "namespace", value: "tcm"}
      }
    }
    facets: {
      concepts: [
        {first: 20, connectorId: "ingredients"},
        {first: 20, connectorId: "glassware"},
      ]
    }
  )
  {
    facets (language: "english") {
      __typename
      ... on ConceptFacet {
        connectorId
        title
        concepts {
          label
          count
          id
        }
        uri
      }
    }
    results (first: 1) {
      hits
      edges {
        node {
          search {
            id
            locale
            conceptSchemes {
              connectorId
              concepts {
                label
                id
              }
            }
          }
        }
      }
    } 
  }
}

Response

{
  "data": {
    "search": {
      "facets": [
        {
          "__typeName": "ConceptFacet",
          "connectorId": "glassware",
          "title": "Glassware",
          "concepts": [],
          "uri": "e-learning-poolparty-biz_cocktails_f09732a9-a0e6-494a-8ce9-299ef036aaaf"
        },
        {
          "__typeName": "ConceptFacet",
          "connectorId": "ingredients",
          "title": "Ingredients",
          "concepts": [
            {
              "label": "",
              "count": 2,
              "id": "e-learning-poolparty-biz_cocktails_3c94f5fc_4664_4177_a880_88643c0be9c1"
            }
          ],
          "uri": "e-learning-poolparty-biz_cocktails_eff672ac-6601-42c6-a3e9-0adda3b45df8"
        }
      ],
      "results": {
        "hits": 2,
        "edges": [
          {
            "node": {
              "search": {
                "id": "tcm_5-485",
                "locale": "",
                "conceptSchemes": [
                  {
                    "connectorId": "cocktails",
                    "concepts": [
                      {
                        "label": null,
                        "id": "e-learning-poolparty-biz_cocktails_bab016bd_2fd5_4809_bfe7_3225d25f116d"
                      }
                    ]
                  },
                  {
                    "connectorId": "ingredients",
                    "concepts": [
                      {
                        "label": null,
                        "id": "e-learning-poolparty-biz_cocktails_3c94f5fc_4664_4177_a880_88643c0be9c1"
                      }
                    ]
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}