Search with list of facets from java api-reference

Hi there,
I am trying to make use of this API https://www.algolia.com/doc/api-reference/api-parameters/facets/?language=java#how-to-use .I declared beforehand list of attributes for faceting, as required. What i cannot figure out is this example -

“For this example, let’s consider that attributesForFaceting are set to: [“category”, “author”, “nb_views”, “nb_downloads”] but, for the current search, you want to retrieve facet values only for category and author.”

Using algoliasearch lib for java i am only allowed to search for ONE facet, not a list, using com.algolia.search.objects.Query#setFacets. I cannot get it how can i search for a list with java REST Client?

Any help is greatly appreciated!

Hi there! Can you give us an example call you tried to do, the API client version you have and what was the error?

You should be able to retrieve multiple facets by doing:

.setFacets(Arrays.asList(
  "brands",
  "artists"
))

If that’s not the case then provide us more details about what you tried and did not work. Thanks!

HI Algolia Team! Please find the details below:
I am using this maven dependency for Java client
>

      <groupId>com.algolia</groupId>
      <artifactId>algoliasearch</artifactId>
      <version>2.20.0</version>
    </dependency>

But the Query class from the com.algolia.search.objects.Query package has only this method

public Query setFacets(String facets) {
this.facets = facets;
return this;
}

My question is - how can i set a list of facets using this dependency? Am i missing something?
Thank you i advance!

Hello there,

You’re right the documentation is not correct regarding the facets feature. It’s a known issue. We will take care of it in the next days.

However, if you want to pass multiple facets, you can pass it the “old way”.

For example :
You can do query.setFacets("brands,artists") instead of query.setFacets(Arrays.asList("brands","artists"));

Happy coding with Algolia :slight_smile:

HI Algolia Team! Thank you for the response. I understand that fixing this limitation requires some time but can you at least reflect this mismatch in javadoc?
Thank you in advance!