Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarifications regarding usage with Fluent #74

Closed
mkekit opened this issue Oct 22, 2024 · 3 comments
Closed

Clarifications regarding usage with Fluent #74

mkekit opened this issue Oct 22, 2024 · 3 comments

Comments

@mkekit
Copy link

mkekit commented Oct 22, 2024

Hello, and thank you for creating the module!

While using it with the Fluent module, some questions have come up regarding the configuration with multiple indexes per language (as this is also recommended as the preferred method in the README).

However, we have the following question:

  1. The 'includeClasses' parameter allows control over which classes are indexed. In our case, 'SiteTree'.
  2. The 'includeFilter' parameter allows further refinement of which records end up in the index in Algolia.

Since the Fluent module in SilverStripe stores the locale of objects in a separate table (SiteTree_Localised), and the 'includeFilter' parameter only allows for a simple 'WHERE' query, we are wondering how each individual index per language can now be specified in the YAML configuration through this setup.

Here is our current configuration, which of course doesn't work:

SilverStripe\Core\Injector\Injector:
  Wilr\SilverStripe\Algolia\Service\AlgoliaService:
    properties:
      adminApiKey: "`ALGOLIA_ADMIN_API_KEY`"
      searchApiKey: "`ALGOLIA_SEARCH_API_KEY`"
      applicationId: "`ALGOLIA_SEARCH_APP_ID`"
      indexes:
        index_en_gb:
          includeClasses:
            - SilverStripe\CMS\Model\SiteTree
          includeFilter:
            "SilverStripe\\CMS\\Model\\SiteTree": "'Locale' = 'en_GB'"
          indexSettings:
            distinct: true
            attributeForDistinct: "objectLink"
            searchableAttributes:
              - objectTitle
              - objectContent
              - objectLink
              - Summary
              - objectForTemplate
            attributesForFaceting:
              - "filterOnly(objectClassName)"

Could you perhaps post an example?

Many thanks and best regards!

@mkekit
Copy link
Author

mkekit commented Oct 31, 2024

No one can help or have any tipps? I would be very grateful for some suggestions!

@wilr, would extending the 'includeFilter' function be an option or a step in the right direction?
@knirb, I assume that this only worked in your example because you were also using the subsite module in parallel?

@wilr
Copy link
Owner

wilr commented Oct 31, 2024

Sorry @mkekit I can't say I use fluent or know how it's internal data is structured as to what the best way to do this would be. I wonder if it would work if you managed this in your _config.php file

if (isset($_ENV['locale'])) {
$locale = $_ENV['locale'];
FluentState::singleton()->setLocale($locale);
// update ALGOLIA_PREFIX_INDEX_NAME with the local
$prefix = Environment::getEnv('ALGOLIA_PREFIX_INDEX_NAME');
Environment::setVar($prefix . '_'. $locale);
}

@mkekit
Copy link
Author

mkekit commented Nov 6, 2024

Thanks for your help @wilr, but this does't work either :(

@mkekit mkekit closed this as completed Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants