Filtering Categories based on product properties

I have countries mapped to each product, but I wish filter out the Categories(which can be either on parent category level or child category level) Countries. We are not able to get the Parent Categories based on the product properties. We also tried listEntries API in catalog module with terms and keyword parameter but does not work. What can be the best possible solution for this?

HI @OlegoO
in this requirement, we pass the category ID we want the next hierarchy of that category and then we want to filter the category based on the country or any filter of products. it should check all the subcategory products so if any product has a country or filter of products, we want to get the categories. and we also want to count on the immediate categories which include the number of product using filters

Please check Full text search and aggregations (facets). It should resolve all you need.

Search - Overview - Developer Center (virtocommerce.org)

Thank you @OlegoO, will check it.