mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00

* Initial work on new search backend * Clean up search backends * Return only the most relevant result per object * Clear any pre-existing cached entries on cache() * #6003: Implement global search functionality for custom field values * Tweak field weights & document guidance * Extend search() to accept a lookup type * Move get_registry() out of SearchBackend * Enforce object permissions when returning search results * Add indexers for remaining models * Avoid calling remove() on non-cacheable objects * Use new search backend by default * Extend search backend to filter by object type * Clean up search view form * Enable specifying lookup logic * Add indexes for value field * Remove object type selector from search bar * Introduce SearchTable and enable HTMX for results * Enable pagination * Remove legacy search backend * Cleanup * Use a UUID for CachedValue primary key * Refactoring search methods * Define max search results limit * Extend reindex command to support specifying particular models * Add clear() and size to SearchBackend * Optimize bulk caching performance * Highlight matched portion of field value * Performance improvements for reindexing * Started on search tests * Cleanup & docs * Documentation updates * Clean up SearchIndex * Flatten search registry to register by app_label.model_name * Clean up search backend classes * Clean up RestrictedGenericForeignKey and RestrictedPrefetch * Resolve migrations conflict
29 lines
782 B
Markdown
29 lines
782 B
Markdown
# Search
|
|
|
|
Plugins can define and register their own models to extend NetBox's core search functionality. Typically, a plugin will include a file named `search.py`, which holds all search indexes for its models (see the example below).
|
|
|
|
```python
|
|
# search.py
|
|
from netbox.search import SearchIndex
|
|
from .models import MyModel
|
|
|
|
class MyModelIndex(SearchIndex):
|
|
model = MyModel
|
|
fields = (
|
|
('name', 100),
|
|
('description', 500),
|
|
('comments', 5000),
|
|
)
|
|
```
|
|
|
|
To register one or more indexes with NetBox, define a list named `indexes` at the end of this file:
|
|
|
|
```python
|
|
indexes = [MyModelIndex]
|
|
```
|
|
|
|
!!! tip
|
|
The path to the list of search indexes can be modified by setting `search_indexes` in the PluginConfig instance.
|
|
|
|
::: netbox.search.SearchIndex
|