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

Order global search results by value of matched fields #14035

Closed
jeremystretch opened this issue Oct 13, 2023 · 0 comments
Closed

Order global search results by value of matched fields #14035

jeremystretch opened this issue Oct 13, 2023 · 0 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@jeremystretch
Copy link
Member

NetBox version

v3.6.3

Feature type

Change to existing functionality

Proposed functionality

When returning global search results, order results of equal precedence and object type by value. This should ensure that otherwise equally-relevant results appear in a human-friendly order.

The current ordering for cached search result objects is:

class CachedValue:
    class Meta:
        ordering = ('weight', 'object_type', 'object_id')

This FR would modify the above to:

class CachedValue:
    class Meta:
        ordering = ('weight', 'object_type', 'value', 'object_id')

(object_id is retained as a tie-breaker for results having the same matched value, to ensure deterministic ordering.)

Use case

This adjustment serves to ensure otherwise equally-relevant search results are listed in a human-friendly order. (This was first raised as a bug report under #13940.)

Database changes

This will require a model migration to effect the new default ordering for CachedValue.

External dependencies

None

@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Oct 13, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Oct 28, 2023
@jeremystretch jeremystretch added this to the v3.7 milestone Oct 28, 2023
@jeremystretch jeremystretch self-assigned this Oct 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

1 participant