[PR #10676] [MERGED] Closes #10560: New global search #13671

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/10676
Author: @jeremystretch
Created: 10/18/2022
Status: Merged
Merged: 10/21/2022
Merged by: @jeremystretch

Base: featureHead: 10560-search


📝 Commits (10+)

  • 80bf6e7 Initial work on new search backend
  • 89b9764 Clean up search backends
  • 607312a Return only the most relevant result per object
  • a237b2a Clear any pre-existing cached entries on cache()
  • 3dfec49 #6003: Implement global search functionality for custom field values
  • 14858dd Tweak field weights & document guidance
  • 7f86cff Extend search() to accept a lookup type
  • e23b4b5 Move get_registry() out of SearchBackend
  • a7cde92 Enforce object permissions when returning search results
  • 19c6f95 Add indexers for remaining models

📊 Changes

50 files changed (+1557 additions, -653 deletions)

View changed files

📝 docs/configuration/system.md (+8 -0)
docs/development/search.md (+37 -0)
📝 docs/plugins/development/search.md (+7 -8)
📝 docs/release-notes/version-3.4.md (+4 -0)
📝 mkdocs.yml (+1 -0)
📝 netbox/circuits/search.py (+46 -25)
📝 netbox/dcim/search.py (+266 -116)
📝 netbox/extras/api/serializers.py (+2 -2)
📝 netbox/extras/filtersets.py (+2 -2)
📝 netbox/extras/forms/bulk_import.py (+2 -2)
📝 netbox/extras/forms/models.py (+2 -2)
netbox/extras/management/commands/reindex.py (+77 -0)
netbox/extras/migrations/0079_change_jobresult_order.py (+0 -17)
📝 netbox/extras/migrations/0079_jobresult_scheduled_time.py (+5 -3)
netbox/extras/migrations/0080_search.py (+35 -0)
📝 netbox/extras/models/__init__.py (+2 -0)
📝 netbox/extras/models/customfields.py (+23 -2)
netbox/extras/models/search.py (+50 -0)
📝 netbox/extras/plugins/__init__.py (+1 -1)
📝 netbox/extras/registry.py (+1 -1)

...and 30 more files

📄 Description

Closes: #10560

  • Introduce CachedValue model to store cached model field values for search
  • Introduce an indexer class for all searchable models, specifying fields and their weights ($app/search.py)
  • Introduce the reindex management command to [re]build the cache
  • Implement table-based search results with HTMX
  • Add search_weight field to CustomField model
  • Remove legacy search backend
  • Remove object type selector from UI search bar
  • Replace search_options template tag with inclusion template (inc/searchbar.html)
  • Introduce RestrictedGenericForeignKey and RestrictedPrefetch to enable restricting pre-fetched GFK objects based on user permissions

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/10676 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 10/18/2022 **Status:** ✅ Merged **Merged:** 10/21/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `10560-search` --- ### 📝 Commits (10+) - [`80bf6e7`](https://github.com/netbox-community/netbox/commit/80bf6e7b2c6947b8e4c0265ed4d5a62dbf45b386) Initial work on new search backend - [`89b9764`](https://github.com/netbox-community/netbox/commit/89b97642adac3af4c4ff049595218e84b08c4fe0) Clean up search backends - [`607312a`](https://github.com/netbox-community/netbox/commit/607312a4567a345e724e93ae4122850af30660ed) Return only the most relevant result per object - [`a237b2a`](https://github.com/netbox-community/netbox/commit/a237b2a10b8250c16a9218e2130461b4f9b4b721) Clear any pre-existing cached entries on cache() - [`3dfec49`](https://github.com/netbox-community/netbox/commit/3dfec4925d749f1b5259cb9a3545c20bcb85d8a2) #6003: Implement global search functionality for custom field values - [`14858dd`](https://github.com/netbox-community/netbox/commit/14858dd79078d2d1d998217fb1abec5165fed0a6) Tweak field weights & document guidance - [`7f86cff`](https://github.com/netbox-community/netbox/commit/7f86cffff61b16e1aa6f7f08662d671936fa4282) Extend search() to accept a lookup type - [`e23b4b5`](https://github.com/netbox-community/netbox/commit/e23b4b53577ae33d910e0e86f1ea82311615dfec) Move get_registry() out of SearchBackend - [`a7cde92`](https://github.com/netbox-community/netbox/commit/a7cde92113cf25a65024daf26cec8c6a72a9ea84) Enforce object permissions when returning search results - [`19c6f95`](https://github.com/netbox-community/netbox/commit/19c6f95f625a13b2449fa680dd0887b557f88fba) Add indexers for remaining models ### 📊 Changes **50 files changed** (+1557 additions, -653 deletions) <details> <summary>View changed files</summary> 📝 `docs/configuration/system.md` (+8 -0) ➕ `docs/development/search.md` (+37 -0) 📝 `docs/plugins/development/search.md` (+7 -8) 📝 `docs/release-notes/version-3.4.md` (+4 -0) 📝 `mkdocs.yml` (+1 -0) 📝 `netbox/circuits/search.py` (+46 -25) 📝 `netbox/dcim/search.py` (+266 -116) 📝 `netbox/extras/api/serializers.py` (+2 -2) 📝 `netbox/extras/filtersets.py` (+2 -2) 📝 `netbox/extras/forms/bulk_import.py` (+2 -2) 📝 `netbox/extras/forms/models.py` (+2 -2) ➕ `netbox/extras/management/commands/reindex.py` (+77 -0) ➖ `netbox/extras/migrations/0079_change_jobresult_order.py` (+0 -17) 📝 `netbox/extras/migrations/0079_jobresult_scheduled_time.py` (+5 -3) ➕ `netbox/extras/migrations/0080_search.py` (+35 -0) 📝 `netbox/extras/models/__init__.py` (+2 -0) 📝 `netbox/extras/models/customfields.py` (+23 -2) ➕ `netbox/extras/models/search.py` (+50 -0) 📝 `netbox/extras/plugins/__init__.py` (+1 -1) 📝 `netbox/extras/registry.py` (+1 -1) _...and 30 more files_ </details> ### 📄 Description ### Closes: #10560 - Introduce CachedValue model to store cached model field values for search - Introduce an indexer class for _all_ searchable models, specifying fields and their weights (`$app/search.py`) - Introduce the `reindex` management command to [re]build the cache - Implement table-based search results with HTMX - Add `search_weight` field to CustomField model - Remove legacy search backend - Remove object type selector from UI search bar - Replace `search_options` template tag with inclusion template (`inc/searchbar.html`) - Introduce RestrictedGenericForeignKey and RestrictedPrefetch to enable restricting pre-fetched GFK objects based on user permissions --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 23:20:11 +01:00
adam closed this issue 2025-12-29 23:20:12 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13671