My index objects has a city field and I'd like to retrieve these with autocomplete, but documentation seems missing about how to perform a query (only basic search documentation is available), I found a prototype IndexCore.prototype.searchForFacetValues in the autocomplete.js but I have no idea to use it. 
You should be able to use the following source:
var client = algoliasearch("YourApplicationID", "YourSearchOnlyAPIKey");
var index = client.initIndex("YourIndex");
autocomplete("#search-input", { hint: false }, [
  {
    source: function(query, callback) {
      index
        .searchForFacetValues({
          facetName: "countries",
          facetQuery: query
        })
        .then(function(answer) {
          callback(answer.hits);
        })
        .catch(function() {
          callback([]);
        });
    },
    displayKey: "my_attribute",
    templates: {
      suggestion: function(suggestion) {
        return suggestion._highlightResult.my_attribute.value;
      }
    }
  }
]);
This uses the searchForFacetValues method to get the results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With