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

API key search bug #58

Open
josephlewisnz opened this issue Mar 21, 2023 · 1 comment
Open

API key search bug #58

josephlewisnz opened this issue Mar 21, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@josephlewisnz
Copy link
Contributor

Hey I've set up the module as normal including:

---
Name: algolia
After: silverstripe-algolia
---
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`"

I've noticed that when using search sever side eg.
$results = Injector::inst()->get(AlgoliaQuerier::class)->fetchResults(...)

I am getting an error with the fact that this method seems to use the adminApiKey rather than the expected searchApiKey

I am unsure if this is my misunderstanding of the setup or a bug.
My workaround was just to create a new "master" key on Algolia with all permissions enabled for both indexing and searching.

@wilr
Copy link
Owner

wilr commented Apr 4, 2023

@josephlewisnz you're correct - it looks like fetchResult calls AlgoliaService::getClient() which uses the Admin API key by default. An enhancement would be to have AlgoliaService::getSearchClient() which uses the right key.

@wilr wilr added the enhancement New feature or request label Apr 4, 2023
@wilr wilr added this to the 1.6.0 milestone Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants