Skip to content

Added lastUpdatedAt, Updated Condition in DSR, written tests, changed… - #806

Open
Rishav-Bagri wants to merge 1 commit into
meilisearch:mainfrom
Rishav-Bagri:feat/Add_filter_condition
Open

Added lastUpdatedAt, Updated Condition in DSR, written tests, changed…#806
Rishav-Bagri wants to merge 1 commit into
meilisearch:mainfrom
Rishav-Bagri:feat/Add_filter_condition

Conversation

@Rishav-Bagri

@Rishav-Bagri Rishav-Bagri commented Jul 29, 2026

Copy link
Copy Markdown

… the variable to precedence

Pull Request

Related issue

Fixes #805

What does this PR do?

  1. Added lastUpdatedAt
  2. Updated Condition in DSR, introduced 3 new struct QueryCondition, TimeCondition, FilterCondition
    a. Condition is now a pointer rather than a slice
  3. written test cases (AI generated, it updated the test cases function)
  4. changed variable name from Priority to Precedence
  • ...

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features
    • Updated search rule models to support precedence-based ordering.
    • Added support for query, time, and filter conditions with structured condition data.
    • Added LastUpdatedAt information to search rule responses.
  • Tests
    • Expanded coverage for filter conditions and updated search rule creation, listing, retrieval, and update scenarios.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The search rule models now support precedence, nested query/time/filter conditions, filter value maps, and lastUpdatedAt. Integration tests update CRUD requests and assertions to the revised API shape and verify filter conditions and timestamps.

Changes

Dynamic search rules

Layer / File(s) Summary
Search rule model contract
models_search.go
Renames priority to precedence, changes conditions to a nested pointer object, adds query/time/filter condition types, and exposes LastUpdatedAt.
Search rule integration coverage
integration/search_rules_test.go
Updates CRUD tests for the new request and response shapes, and verifies filter values, precedence, and timestamps.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • meilisearch/meilisearch-rust issue 800 — Covers the same dynamic search rule filter-condition and lastUpdatedAt support.
  • meilisearch/meilisearch-dotnet issue 750 — Updates a related SDK for filter conditions and lastUpdatedAt.
  • meilisearch/meilisearch-php issue 935 — Adds equivalent dynamic search rule response and condition support.
  • meilisearch/meilisearch-js issue 2211 — Implements the same dynamic search rule model changes.
  • meilisearch/meilisearch-python issue 1267 — Covers filter conditions and lastUpdatedAt in another SDK.
  • meilisearch/meilisearch-ruby issue 709 — Adds corresponding dynamic search rule filter support.

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: elyarsadig, iamadityafr

Poem

A rabbit found new filters bright,
With nested rules tucked just right.
Precedence hopped where priority lay,
Last-updated time joined the array.
Tests now nibble bugs away.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title mentions the main DSR changes, but it is truncated and vague, so it does not clearly summarize the PR. Replace it with a concise, complete title that names the key change, such as adding lastUpdatedAt and filter conditions to DSR.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The changes add filter conditions, lastUpdatedAt, and matching tests, which aligns with issue #805's requirements.
Out of Scope Changes check ✅ Passed The PR changes stay focused on the DSR API contract and its tests, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jul 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@integration/search_rules_test.go`:
- Line 158: The search-rules integration assertions incorrectly use assert.Len
on pointer-based Conditions objects. In the create-path test near line 158,
assert rule.Conditions, rule.Conditions.Query, and rule.Conditions.Time
directly; in the update-path test near line 201, assert updatedRule.Conditions
and updatedRule.Conditions.Query directly, preserving the expected presence
checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e9da6aea-c7e1-4c30-8dab-5996397a9bc1

📥 Commits

Reviewing files that changed from the base of the PR and between 31bba01 and 7eac94d.

📒 Files selected for processing (2)
  • integration/search_rules_test.go
  • models_search.go

assert.Equal(t, 10, rule.Priority)
assert.Equal(t, 10, rule.Precedence)
assert.True(t, rule.Active)
assert.Len(t, rule.Conditions, 2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does github.com/stretchr/testify/assert Len support a pointer to a Go struct in version v1.11.1?

💡 Result:

No, the assert.Len function in version v1.11.1 of the github.com/stretchr/testify/assert package does not natively support pointers to Go structs [1][2]. The implementation of assert.Len relies on a helper function named getLen, which uses the reflect package to determine the length of the provided object [1]: // getLen tries to get the length of an object. // It returns (0, false) if impossible. func getLen(x interface{}) (length int, ok bool) { v:= reflect.ValueOf(x) defer func { ok = recover == nil } return v.Len, true } In Go, the reflect.Value.Len method supports types such as Array, Chan, Map, Slice, and String. It does not support pointers to structs. If you pass a pointer to a struct to assert.Len, the function will determine that it is impossible to get the length and return a failure message indicating that the object could not be applied to the builtin len function [1].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)search_rules_test\.go$|go\.mod$|assertions\.go$' || true

echo "== search_rules_test relevant lines =="
if [ -f integration/search_rules_test.go ]; then
  nl -ba integration/search_rules_test.go | sed -n '130,215p'
fi

echo "== module testify version =="
if [ -f go.mod ]; then
  rg 'github.com/stretchr/testify' go.mod go.sum | sed -n '1,20p'
fi

echo "== Condition declarations =="
rg -n "type Condition|Conditions" -S . --glob '!vendor/**' --glob '!**/testdata/**' | sed -n '1,120p'

Repository: meilisearch/meilisearch-go

Length of output: 295


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== repository root =="
pwd

echo "== relevant files =="
git ls-files | grep -E '(^|/)search_rules_test\.go$|^go\.mod$|^go\.sum$' || true

echo "== search_rules_test.go relevant lines =="
sed -n '130,215p' integration/search_rules_test.go

echo "== module testify version =="
grep -n 'github.com/stretchr/testify' go.mod go.sum 2>/dev/null || true

echo "== Condition declarations/usages =="
grep -RInE 'type Condition|Conditions' . --exclude-dir=vendor --exclude-dir=testdata --exclude-dir=.git | head -120 || true

Repository: meilisearch/meilisearch-go

Length of output: 4276


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== models_search.go outline/contents =="
sed -n '1,90p' models_search.go

echo "== SearchRulesRequest/create/update API handling relevant symbols =="
grep -RInE 'SearchRulesRequest|update search rule|search rule|SearchRule|search_rules\|conditions' --exclude-dir=vendor --exclude-dir=testdata --exclude-dir=.git . | head -200

Repository: meilisearch/meilisearch-go

Length of output: 29642


Replace collection-length checks with nested-condition assertions.

Rules.Conditions is *meilisearch.Condition, so assert.Len checks object length rather than condition count. Assert rule.Conditions, .Query, and .Time for the create path, and updatedRule.Conditions and .Query for the update path instead.

📍 Affects 1 file
  • integration/search_rules_test.go#L158-L158 (this comment)
  • integration/search_rules_test.go#L201-L201
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@integration/search_rules_test.go` at line 158, The search-rules integration
assertions incorrectly use assert.Len on pointer-based Conditions objects. In
the create-path test near line 158, assert rule.Conditions,
rule.Conditions.Query, and rule.Conditions.Time directly; in the update-path
test near line 201, assert updatedRule.Conditions and
updatedRule.Conditions.Query directly, preserving the expected presence checks.

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

Successfully merging this pull request may close these issues.

[Meilisearch v1.51.0] Add filter condition to Dynamic Search Rules

1 participant