-
Notifications
You must be signed in to change notification settings - Fork 124
Support filter conditions in dynamic search rules #936
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,13 +25,18 @@ | |||||||||||||||||
| * start?: non-empty-string|null, | ||||||||||||||||||
| * end?: non-empty-string|null | ||||||||||||||||||
| * } | ||||||||||||||||||
| * @phpstan-type FilterCondition array{ | ||||||||||||||||||
| * values: array<string, mixed> | ||||||||||||||||||
| * } | ||||||||||||||||||
| * @phpstan-type SearchRuleConditions array{ | ||||||||||||||||||
| * query?: QueryCondition|null, | ||||||||||||||||||
| * time?: TimeCondition|null | ||||||||||||||||||
| * time?: TimeCondition|null, | ||||||||||||||||||
| * filter?: FilterCondition|null | ||||||||||||||||||
| * } | ||||||||||||||||||
| * @phpstan-type RawDynamicSearchRule array{ | ||||||||||||||||||
| * uid: non-empty-string, | ||||||||||||||||||
| * description?: string|null, | ||||||||||||||||||
| * lastUpdatedAt?: non-empty-string, | ||||||||||||||||||
|
Comment on lines
36
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Locate target and related files =="
fd -a 'DynamicSearchRule\.php$|dynamic.*search.*rule|search_rules' . | sed 's#^\./##'
echo
echo "== Inspect DynamicSearchRule target =="
if [ -f src/Contracts/DynamicSearchRule.php ]; then
wc -l src/Contracts/DynamicSearchRule.php
cat -n src/Contracts/DynamicSearchRule.php
fi
echo
echo "== Search for fixture/usages =="
rg -n "lastUpdatedAt|DynamicSearchRule|RawDynamicSearchRule" tests src -S
echo
echo "== Composer/phpstan references =="
rg -n '"phpstan/phpstan"|phpstan' composer.json composer.lock || trueRepository: meilisearch/meilisearch-php Length of output: 17060 🌐 Web query:
💡 Result: In Meilisearch, the file Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Fetch exact v1.51 dynamic_search_rules.rs =="
curl -fsSL https://raw.githubusercontent.com/meilisearch/meilisearch/v1.51.0/crates/meilisearch-types/src/dynamic_search_rules.rs \
| sed -n '250,330p'
echo
echo "== Fetch raw line context for lastUpdatedAt =="
curl -fsSL https://raw.githubusercontent.com/meilisearch/meilisearch/v1.51.0/crates/meilisearch-types/src/dynamic_search_rules.rs \
| rg -n "lastUpdatedAt|lastUpdated|updatedAt|skip_serializing_if|serde\\(.*default" || trueRepository: meilisearch/meilisearch-php Length of output: 6246 🌐 Web query:
💡 Result: The file dynamic_search_rules.rs is a component of the Meilisearch codebase that manages the definition, structure, and processing of dynamic search rules [1][2][3]. While there are multiple instances of files named dynamic_search_rules.rs within the repository (notably in crates/index-scheduler/src/, crates/meilisearch-types/src/, and crates/milli/src/ [3][4]), none of the public or standard definitions for the dynamic search rule structures in these files include a field explicitly named lastUpdatedAt [1][2]. The Meilisearch dynamic search rules feature underwent significant architectural changes around the v1.50.0 release [5][6]. The rules now handle fields such as precedence, active, conditions, and actions [1][2]. Changes to dynamic search rules are processed asynchronously via tasks, and responses for operations like PATCH or DELETE now return the associated task rather than the rule object itself [5][6]. If you are encountering a reference to lastUpdatedAt, it is likely part of an internal state management system, a specific database schema representation, or a custom implementation detail not present in the standard public API or primary rule definitions [1][7]. {confidence: 0.9} Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Fetch upstream structs around DynamicSearchRule definitions =="
curl -fsSL https://raw.githubusercontent.com/meilisearch/meilisearch/v1.51.0/crates/meilisearch-types/src/dynamic_search_rules.rs \
| sed -n '1,140p'
echo
echo "== Fetch all lastUpdatedAt occurrences in v1.51 source =="
curl -fsSL https://raw.githubusercontent.com/meilisearch/meilisearch/v1.51.0/crates/meilisearch-types/src/dynamic_search_rules.rs \
| rg -n "lastUpdatedAt|lastUpdatedAt|lastUpdated" || true
echo
echo "== Check if v1.51 is latest or contains newer dynamic search rules in another file =="
curl -fsSL https://api.github.com/repos/meilisearch/meilisearch/git/matches/data?sha=v1.51.0&path=crates/meilisearch-types/src/dynamic_search_rules.rs \
| jq -r '.patch_url // empty' 2>/dev/null || true
git ls-data --tree v1.51.0 crates/meilisearch-types/src/dynamic_search_rules.rs || true
git ls-tree -r v1.51.0 --name-only crates/meilisearch-types/src/ | rg dynamic_search_rules || trueRepository: meilisearch/meilisearch-php Length of output: 6134 Allow explicit In the server model, - * lastUpdatedAt?: non-empty-string,
+ * lastUpdatedAt?: non-empty-string|null,📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: MCP tools |
||||||||||||||||||
| * precedence?: non-negative-int|null, | ||||||||||||||||||
| * active?: bool, | ||||||||||||||||||
| * conditions?: SearchRuleConditions|null, | ||||||||||||||||||
|
|
@@ -52,6 +57,8 @@ final class DynamicSearchRule | |||||||||||||||||
|
|
||||||||||||||||||
| private readonly ?string $description; | ||||||||||||||||||
|
|
||||||||||||||||||
| private readonly ?\DateTimeImmutable $lastUpdatedAt; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @var non-negative-int|null | ||||||||||||||||||
| */ | ||||||||||||||||||
|
|
@@ -73,6 +80,7 @@ public function __construct( | |||||||||||||||||
| $this->uid = $raw['uid']; | ||||||||||||||||||
| $this->actions = $raw['actions']; | ||||||||||||||||||
| $this->description = $raw['description'] ?? null; | ||||||||||||||||||
| $this->lastUpdatedAt = isset($raw['lastUpdatedAt']) ? new \DateTimeImmutable($raw['lastUpdatedAt']) : null; | ||||||||||||||||||
| $this->precedence = $raw['precedence'] ?? null; | ||||||||||||||||||
| $this->active = $raw['active'] ?? null; | ||||||||||||||||||
| $this->conditions = $raw['conditions'] ?? null; | ||||||||||||||||||
|
|
@@ -96,6 +104,11 @@ public function getDescription(): ?string | |||||||||||||||||
| return $this->description; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public function getLastUpdatedAt(): ?\DateTimeImmutable | ||||||||||||||||||
| { | ||||||||||||||||||
| return $this->lastUpdatedAt; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public function getPrecedence(): ?int | ||||||||||||||||||
| { | ||||||||||||||||||
| return $this->precedence; | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: meilisearch/meilisearch-php
Length of output: 30500
🏁 Script executed:
Repository: meilisearch/meilisearch-php
Length of output: 4344
🏁 Script executed:
Repository: meilisearch/meilisearch-php
Length of output: 852
Replace
array<string, mixed>with a bounded filter-value type.FilterCondition.valuescurrently widens PHPStan analysis. Since dynamic search filter entries can be scalar JSON values, add a namedFilterValuealias and use it here sotoArray()/fromArray()stay precisely typed under thesrc/Contracts/**/*.phpguideline.Proposed shape
📝 Committable suggestion
🤖 Prompt for AI Agents
Sources: Coding guidelines, MCP tools