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

feat: search driver backend extension API #3902

Merged
merged 15 commits into from
Oct 18, 2023

Conversation

SychO9
Copy link
Member

@SychO9 SychO9 commented Oct 18, 2023

Part of #3884 (#3884 (comment))

Changes proposed in this pull request:
Introduces a search driver API. (Checkout the POC here: https://github.com/SychO9/flarum-ext-search/blob/main/extend.php#L40-L48).

    (new Flarum\SearchDriver(Search\ElasticSearchDriver::class))
        ->addSearcher(FlarumDiscussion::class, Discussion\DiscussionSearcher::class)
        ->addFilter(Discussion\DiscussionSearcher::class, Discussion\PrivateFilterMutator::class)
        ->addMutator(Discussion\DiscussionSearcher::class, Discussion\PrivateFilterMutator::mutate(...))
        ->setFulltext(Discussion\DiscussionSearcher::class, Discussion\FulltextFilter::class),

    (new Flarum\SearchIndex())
        ->indexer(FlarumDiscussion::class, Discussion\DiscussionIndexer::class)
        ->indexer(FlarumPost::class, Post\CommentPostIndexer::class),
  • Search drivers declare their own DriverInterface.
  • Search drivers declare their own Searcher per model.
  • Search drivers can optionally declare a model indexer (IndexerInterface).
  • Search drivers may use their own SearchState implementation. (use of phpstan template for generics helps with typings here).

Follow up PRs
The follow up PR will include

  • Adding an advanced admin page where drivers can be configured per model.

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

@SychO9 SychO9 merged commit 1f235a2 into dev-search-drivers Oct 18, 2023
22 checks passed
@SychO9 SychO9 deleted the sm/dev-search-drivers--drivers branch October 18, 2023 17:20
@SychO9
Copy link
Member Author

SychO9 commented Oct 21, 2023

#3893

@SychO9 SychO9 mentioned this pull request Oct 21, 2023
9 tasks
SychO9 added a commit that referenced this pull request Nov 11, 2023
* refactor: move gambits to frontend (#3885)
* refactor: move gambits to frontend
* test: GambitManager
* refactor: merge filterer and searcher concepts (#3892)
* chore: drop remaining backend regex gambits
* refactor: merge filterer & searcher concept
* refactor: adapt extenders
* refactor: no longer need to push gambits to `q`
* refactor: filters to gambits
* refactor: drop shred `Query` namespace
* chore: cleanup
* chore: leftover gambit references on the backend (#3894)
* chore: leftover gambit references on the backend
* chore: namespace
* feat: search driver backend extension API (#3902)
* feat: first iteration of search drivers
* feat: indexer API & tweaks
* feat: changes after POC driver
* fix: properly fire custom observables
* chore: remove debugging code
* fix: phpstan
* fix: custom eloquent events
* chore: drop POC usage
* test: indexer extender API
* fix: extension searcher fails without filters
* fix: phpstan
* fix: frontend created gambit
* feat: advanced page and localized driver settings (#3905)
* feat: allow getting total search results and replacing filters (#3906)
* feat: allow accessing total search results
* feat: allow replacing filters
* chore: phpstan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants