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

Refactor the Search Engine & Filter Builder #17

Closed
wants to merge 3 commits into from

Conversation

jakubtobiasz
Copy link
Contributor

  • Filter Builder has been split into smaller, specific filter focused services
  • Search Engine has been refactored to use Multi Search to improve returned facet distribution

composer.json Outdated
@@ -88,6 +88,7 @@
},
"autoload-dev": {
"psr-4": {
"TestApp\\": "tests/Application/src/",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind a new namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a src inside the test app, as I wanted to skip putting it directly under the tests/Application. The namespace will look CurrentNamespace/src/FilterBuilder so I decided to create a shorter version, as it doesn't impact the project itself.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, maybe, to have it consistent with other namespaces name it Setono\\SyliusMeilisearchPlugin\\TestApp\\? I know it's long 💃 but who cares when we have autocomplete 🚀

Comment on lines 18 to 24
$brandQuery = [];
/** @var string $size */
foreach ($facets['brand'] as $size) {
$brandQuery[] = sprintf('brand = "%s"', $size);
}

return '(' . implode(' OR ', $brandQuery) . ')';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can simplify the implementations of these anonymous classes, they're not relevant in the scope of this test

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this class is much less readable after the refactor than before, which should not be the case 😅 Let's maybe introduce another layer of abstraction, so this class would only gather the query and parameters, pass them to query builder (main query builder and subsearch query builders) and then execute the call on Meilisearch API?

Let's start the discussion 🖖

@@ -6,5 +6,7 @@

interface FilterBuilderInterface
{
public function build(array $parameters): array;
public function build(array $facets): string|array;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially unify the return type, to always return array (no matter if with one or multiple elements)

@Zales0123
Copy link
Collaborator

Closing in favor of #22 - thank you @jakubtobiasz 🫡

@Zales0123 Zales0123 closed this Aug 30, 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

Successfully merging this pull request may close these issues.

3 participants