studioespresso / craft-scout

Craft Scout provides a simple solution for adding full-text search to your entries. Scout will automatically keep your search indexes in sync with your entries.
MIT License
81 stars 55 forks source link

IndexSettings not applied #282

Closed russback closed 10 months ago

russback commented 11 months ago

First time using this plugin, so apologies if I am missing something basic here.

I have a simple index set up and am looking at using IndexSettings, however I have found that the following does not seem to update what I see in the Algolia index configuration. I initially thought it was only being applied when the index is first created (i.e. thinking that changes to the index settings is not supported by the plugin) but when deleting the index in Algolia and running the import CLI task again, the values for my settings are not showing up in Alogia.

Here's my configL

ScoutIndex::create('ARTWORK')
   ->elementType(Entry::class)
   ->criteria(function (EntryQuery $query) {
       return $query->section('artwork');
   })
   ->transformer(function (Entry $entry) {
       return [
           'title' => $entry->title,
           'slug' => $entry->slug,
           'entryType' => $entry->type->handle,
           'description' => $entry->text,
           'artworkDate' => $entry->artworkDate,
           'artists' => $entry->artists->collect()->pluck('fullName'),
           'artforms' => $entry->artforms->collect()->pluck('title'),
           'tags' => $entry->tags->collect()->pluck('title'),
       ];
   })
   ->indexSettings(IndexSettings::create()
       ->minWordSizefor1Typo(2)
       ->attributesForFaceting(['searchable(artists)', 'artforms', 'tags'])
   );

And here's what shows up in Algolia config - both are showing the default and not the values in the plugin's index config.

minWordSizefor1Typo:

Screenshot 2023-10-30 at 11 06 16

attributesForFaceting:

Screenshot 2023-10-30 at 11 06 27

This is with Craft 4.5.9 and Scout 3.2.1.

janhenckens commented 11 months ago

Index settings aren't applied automatically when items get added to the index, you'll need to run php craft scout/settings/update from the command line, or click "Update settings" in the Scout utility page

Screenshot 20231108-134710-sUxny3y6@2x

I see this is only briefly mentioned in the docsblock in this example so it could probably be made clearer in the docs. Leaving this issue open until I've added it there.

janhenckens commented 10 months ago

Added a note for this!