Search code examples
phpalgolia

searching in a specific attribute (column) with Algolia


I am trying to utilise Algolia's Natural Language search to search amongst my already populated indices, but I only need to search in the "name" column.

I am having a difficult time figuring how to do it. I am using the PHP SDK, and I've managed to facet it, but that only returns facetHits, with the value of the hit, but I still need the data from the model.


Solution

  • You have to change searchableAttributes.

    $index->setSettings([
      'searchableAttributes' => [
        'name',
      ]
    ]);
    

    see also the api reference and the guide for searchable attributes