Is it possible for my search request to return the...
# community-help
l
Is it possible for my search request to return the number of documents that match a specific category? For example, I have a cluster that contains a collection called 'products'. In my request to this collection, I need to create a filter on my front-end for the products that correspond to a specific category. For instance, I have a field called 'product_type_code', and I want to be able to create a menu among the documents it found, filtering the results based on the quantity of 'product_type_code' found, similar to the Algolia example I will attach below.
j
If you set
facet_by: product_type_code
that should return the number of documents that are found for each value of product_type_code
l
Thank you very much! I was having difficulty understanding that part.
👍 1
This returns
Copy code
The request failed with HTTP code 404 | The server said: Could not find a facet field called product_type_code in the schema.
But I have a field called 'product_type_code' in all documents. When I try to change its facet property to true I also get an error.
Copy code
Error: SyntaxError: Expected double-quoted property name in JSON at position 8876
Here is my procedure: I copy all my fields and paste them again after clicking on the "update schema" option, and then I only modify the "faced" property of the "product_type_code" field.
j
You’d need to drop and add the field as described here after turning on faceting: https://typesense.org/docs/0.24.1/api/collections.html#modifying-an-existing-field
1