mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-15 19:52:52 -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
140 lines
2.4 KiB
Python
140 lines
2.4 KiB
Python
from . import models
|
|
from netbox.search import SearchIndex, register_search
|
|
|
|
|
|
@register_search
|
|
class AggregateIndex(SearchIndex):
|
|
model = models.Aggregate
|
|
fields = (
|
|
('prefix', 100),
|
|
('description', 500),
|
|
('date_added', 2000),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class ASNIndex(SearchIndex):
|
|
model = models.ASN
|
|
fields = (
|
|
('asn', 100),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class FHRPGroupIndex(SearchIndex):
|
|
model = models.FHRPGroup
|
|
fields = (
|
|
('name', 100),
|
|
('group_id', 2000),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class IPAddressIndex(SearchIndex):
|
|
model = models.IPAddress
|
|
fields = (
|
|
('address', 100),
|
|
('dns_name', 300),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class IPRangeIndex(SearchIndex):
|
|
model = models.IPRange
|
|
fields = (
|
|
('start_address', 100),
|
|
('end_address', 300),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class L2VPNIndex(SearchIndex):
|
|
model = models.L2VPN
|
|
fields = (
|
|
('name', 100),
|
|
('slug', 110),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class PrefixIndex(SearchIndex):
|
|
model = models.Prefix
|
|
fields = (
|
|
('prefix', 100),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class RIRIndex(SearchIndex):
|
|
model = models.RIR
|
|
fields = (
|
|
('name', 100),
|
|
('slug', 110),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class RoleIndex(SearchIndex):
|
|
model = models.Role
|
|
fields = (
|
|
('name', 100),
|
|
('slug', 110),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class RouteTargetIndex(SearchIndex):
|
|
model = models.RouteTarget
|
|
fields = (
|
|
('name', 100),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class ServiceIndex(SearchIndex):
|
|
model = models.Service
|
|
fields = (
|
|
('name', 100),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class VLANIndex(SearchIndex):
|
|
model = models.VLAN
|
|
fields = (
|
|
('name', 100),
|
|
('vid', 100),
|
|
('description', 500),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class VLANGroupIndex(SearchIndex):
|
|
model = models.VLANGroup
|
|
fields = (
|
|
('name', 100),
|
|
('slug', 110),
|
|
('description', 500),
|
|
('max_vid', 2000),
|
|
)
|
|
|
|
|
|
@register_search
|
|
class VRFIndex(SearchIndex):
|
|
model = models.VRF
|
|
fields = (
|
|
('name', 100),
|
|
('rd', 200),
|
|
('description', 500),
|
|
)
|