Order global search results by value of matched fields #8745

Closed
opened 2025-12-29 20:40:41 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Oct 13, 2023).

Originally assigned to: @jeremystretch on GitHub.

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

Originally created by @jeremystretch on GitHub (Oct 13, 2023). Originally assigned to: @jeremystretch on GitHub. ### 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: ```python class CachedValue: class Meta: ordering = ('weight', 'object_type', 'object_id') ``` This FR would modify the above to: ```python 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
adam added the status: acceptedtype: feature labels 2025-12-29 20:40:41 +01:00
adam closed this issue 2025-12-29 20:40:41 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8745