We are trying to figure out how to return the facets summary from a search

We are in the evaluation stage of using AppSearch for a web environment and are having trouble understanding the method of returning the facets summary.

We build our query and successfully get results but at no time do we get a summary of facet item counts. I know we are likely missing something simple but we cannot see to find it in the documentation.

Hello, David!

Thanks for trying out App Search. And welcome to the community!

We have two main pieces of documentation to help with the construction of faceted queries.

There is the API reference (https://swiftype.com/documentation/app-search/api/search/facets)...

It shows an example request, with a facet object alongside a query:

curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "park",
  "facets": {
    "states": [
      {
        "type": "value",
        "sort": { "count": "desc" },
        "size": 5
      }
    ]
  }
}' | jq

You can run this query within your own terminal, too -- the key and Engine are public.

The response shows how we would expect the results to appear, with the facets object at the bottom, containing a data array with a set of values and their respective counts.

...
 "facets": {
    "states": [
      {
        "type": "value",
        "data": [
          {
            "value": "California",
            "count": 8
          },
          {
            "value": "Alaska",
            "count": 5
          },
          {
            "value": "Utah",
            "count": 4
          },
          {
            "value": "Colorado",
            "count": 3
          },
          {
            "value": "Washington",
            "count": 3
          }
        ]
      }
    ]
  }

The other piece of documentation is more conceptual; it's written in guide format, as opposed to the mechanical summary within the reference. You can read it here: https://swiftype.com/documentation/app-search/guides/facets.

It might be helpful to share some queries that you are trying to assemble.

Hopefully we can get to the bottom of this. :smiley:

Enjoy the day,

Kellen

This helped! Thank you very much!

You're welcome!

Let me know if you have any feedback as you explore App Search.

Enjoy the weekend,

Kellen

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