algoliasearch/src/main/java/com/algolia/search/saas/Index.java
@Override
    public Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @Nullable final RequestOptions requestOptions, @NonNull final CompletionHandler handler) {
        try {
            final String path = "/1/indexes/" + getEncodedIndexName() + "/facets/" + URLEncoder.encode(facetName, "UTF-8") + "/query";
            final Query params = (query != null ? new Query(query) : new Query());
            params.set("facetQuery", facetText);
            final JSONObject requestBody = new JSONObject().put("params", params.build());

            final Client client = getClient();
            return client.new AsyncTaskRequest(handler) {
                @NonNull
                @Override
                protected JSONObject run() throws AlgoliaException {
                    return client.postRequest(path, /* urlParameters: */ null, requestBody.toString(), true, requestOptions);
                }
            }.start();
        } catch (UnsupportedEncodingException | JSONException e) {
            throw new RuntimeException(e); // should never happen
        }
    }
@Override
    public Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @Nullable final RequestOptions requestOptions, @NonNull final CompletionHandler handler) {
        try {
            final String path = "/1/indexes/" + getEncodedIndexName() + "/facets/" + URLEncoder.encode(facetName, "UTF-8") + "/query";
            final Query params = (query != null ? new Query(query) : new Query());
            params.set("facetQuery", facetText);
            final JSONObject requestBody = new JSONObject().put("params", params.build());

            final Client client = getClient();
            return client.new AsyncTaskRequest(handler) {
                @NonNull
                @Override
                protected JSONObject run() throws AlgoliaException {
                    return client.postRequest(path, /* urlParameters: */ null, requestBody.toString(), true, requestOptions);
                }
            }.start();
        } catch (UnsupportedEncodingException | JSONException e) {
            throw new RuntimeException(e); // should never happen
        }
    }
@ Override public Request searchForFacetValuesAsync ( @ NonNull String facetName , @ NonNull String facetText , @ Nullable Query query , @ Nullable final RequestOptions requestOptions , @ NonNull final CompletionHandler handler ) { try { final String path = "/1/indexes/" + getEncodedIndexName ( ) + "/facets/" + URLEncoder . encode ( facetName , "UTF-8" ) + "/query" ; final Query params = ( query != null ? new Query ( query ) : new Query ( ) ) ; params . set ( "facetQuery" , facetText ) ; final JSONObject requestBody = new JSONObject ( ) . put ( "params" , params . build ( ) ) ; final Client client = getClient ( ) ; return client . new AsyncTaskRequest ( handler ) { @ NonNull @ Override protected JSONObject run ( ) throws AlgoliaException { return client . postRequest ( path , /* urlParameters: */ null , requestBody . toString ( ) , true , requestOptions ) ; } } . start ( ) ; } catch ( UnsupportedEncodingException | JSONException e ) { throw new RuntimeException ( e ) ; // should never happen } }
Searches for some text in a facet values, optionally restricting the returned values to those contained in objects matching other (regular) search criteria.

@param facetName      The name of the facet to search. It must have been declared in the index's `attributesForFaceting` setting with the `searchable()` modifier.
@param facetText      The text to search for in the facet's values.
@param query          An optional query to take extra search parameters into account. There parameters apply to index objects like in a regular search query. Only facet values contained in the matched objects will be returned
@param requestOptions Request-specific options.
@param handler        A Completion handler that will be notified of the request's outcome.
@return A cancellable request.
Searches for some text in a facet values optionally restricting the returned values to those contained in objects matching other ( regular ) search criteria .