mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 00:36:11 -06:00
Tweak field weights & document guidance
This commit is contained in:
parent
3dfec4925d
commit
14858dd790
16
docs/development/search.md
Normal file
16
docs/development/search.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Search
|
||||
|
||||
## Field Weight Guidance
|
||||
|
||||
| Weight | Field Role | Examples |
|
||||
|--------|--------------------------------------------------|----------------------------------------------------|
|
||||
| 50 | Unique serialized attribute | Device.asset_tag |
|
||||
| 60 | Unique serialized attribute (per related object) | Device.serial |
|
||||
| 100 | Primary human identifier | Device.name, Circuit.cid, Cable.label |
|
||||
| 110 | Slug | Site.slug |
|
||||
| 200 | Secondary identifier | Provider.account, DeviceType.part_number |
|
||||
| 300 | Highly unique descriptive attribute | CircuitTermination.xconnect_id, IPAddress.dns_name |
|
||||
| 500 | Description | Site.description |
|
||||
| 1000 | Custom field default | - |
|
||||
| 2000 | Other discrete attribute | CircuitTermination.port_speed |
|
||||
| 5000 | Comment field | Site.comments |
|
@ -245,6 +245,7 @@ nav:
|
||||
- Adding Models: 'development/adding-models.md'
|
||||
- Extending Models: 'development/extending-models.md'
|
||||
- Signals: 'development/signals.md'
|
||||
- Search: 'development/search.md'
|
||||
- Application Registry: 'development/application-registry.md'
|
||||
- User Preferences: 'development/user-preferences.md'
|
||||
- Web UI: 'development/web-ui.md'
|
||||
|
@ -9,7 +9,7 @@ class CircuitIndex(SearchIndex):
|
||||
fields = (
|
||||
('cid', 100),
|
||||
('description', 500),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.Circuit.objects.prefetch_related(
|
||||
'type', 'provider', 'tenant', 'tenant__group', 'terminations__site'
|
||||
@ -34,7 +34,7 @@ class CircuitTypeIndex(SearchIndex):
|
||||
model = models.CircuitType
|
||||
fields = (
|
||||
('name', 100),
|
||||
('slug', 100),
|
||||
('slug', 110),
|
||||
('description', 500),
|
||||
)
|
||||
|
||||
@ -45,7 +45,7 @@ class ProviderIndex(SearchIndex):
|
||||
fields = (
|
||||
('name', 100),
|
||||
('account', 200),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.Provider.objects.annotate(
|
||||
count_circuits=count_related(models.Circuit, 'provider')
|
||||
@ -60,7 +60,7 @@ class ProviderNetworkIndex(SearchIndex):
|
||||
('name', 100),
|
||||
('service_id', 200),
|
||||
('description', 500),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.ProviderNetwork.objects.prefetch_related('provider')
|
||||
filterset = filtersets.ProviderNetworkFilterSet
|
||||
|
@ -20,7 +20,7 @@ class DeviceIndex(SearchIndex):
|
||||
('asset_tag', 50),
|
||||
('serial', 60),
|
||||
('name', 100),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.Device.objects.prefetch_related(
|
||||
'device_type__manufacturer',
|
||||
@ -40,7 +40,7 @@ class DeviceRoleIndex(SearchIndex):
|
||||
model = models.DeviceRole
|
||||
fields = (
|
||||
('name', 100),
|
||||
('slug', 100),
|
||||
('slug', 110),
|
||||
('description', 500),
|
||||
)
|
||||
|
||||
@ -51,7 +51,7 @@ class DeviceTypeIndex(SearchIndex):
|
||||
fields = (
|
||||
('model', 100),
|
||||
('part_number', 200),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.DeviceType.objects.prefetch_related('manufacturer').annotate(
|
||||
instance_count=count_related(models.Device, 'device_type')
|
||||
@ -64,7 +64,7 @@ class LocationIndex(SearchIndex):
|
||||
model = models.Location
|
||||
fields = (
|
||||
('name', 100),
|
||||
('slug', 100),
|
||||
('slug', 110),
|
||||
('description', 500),
|
||||
)
|
||||
queryset = models.Location.objects.add_related_count(
|
||||
@ -85,7 +85,7 @@ class ModuleIndex(SearchIndex):
|
||||
fields = (
|
||||
('asset_tag', 50),
|
||||
('serial', 60),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.Module.objects.prefetch_related(
|
||||
'module_type__manufacturer',
|
||||
@ -101,7 +101,7 @@ class ModuleTypeIndex(SearchIndex):
|
||||
fields = (
|
||||
('model', 100),
|
||||
('part_number', 200),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.ModuleType.objects.prefetch_related('manufacturer').annotate(
|
||||
instance_count=count_related(models.Module, 'module_type')
|
||||
@ -114,7 +114,7 @@ class PowerFeedIndex(SearchIndex):
|
||||
model = models.PowerFeed
|
||||
fields = (
|
||||
('name', 100),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.PowerFeed.objects.all()
|
||||
filterset = filtersets.PowerFeedFilterSet
|
||||
@ -127,8 +127,8 @@ class RackIndex(SearchIndex):
|
||||
('asset_tag', 50),
|
||||
('serial', 60),
|
||||
('name', 100),
|
||||
('facility_id', 100),
|
||||
('comments', 1000),
|
||||
('facility_id', 200),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = models.Rack.objects.prefetch_related('site', 'location', 'tenant', 'tenant__group', 'role').annotate(
|
||||
device_count=count_related(models.Device, 'rack')
|
||||
@ -151,7 +151,7 @@ class RegionIndex(SearchIndex):
|
||||
model = models.Region
|
||||
fields = (
|
||||
('name', 100),
|
||||
('slug', 100),
|
||||
('slug', 110),
|
||||
('description', 500)
|
||||
)
|
||||
|
||||
@ -163,8 +163,8 @@ class SiteIndex(SearchIndex):
|
||||
('name', 100),
|
||||
('facility', 100),
|
||||
('description', 500),
|
||||
('physical_address', 1000),
|
||||
('shipping_address', 1000),
|
||||
('physical_address', 2000),
|
||||
('shipping_address', 2000),
|
||||
)
|
||||
queryset = models.Site.objects.prefetch_related('region', 'tenant', 'tenant__group')
|
||||
filterset = filtersets.SiteFilterSet
|
||||
@ -175,7 +175,7 @@ class SiteGroupIndex(SearchIndex):
|
||||
model = models.SiteGroup
|
||||
fields = (
|
||||
('name', 100),
|
||||
('slug', 100),
|
||||
('slug', 110),
|
||||
('description', 500)
|
||||
)
|
||||
|
||||
|
@ -8,7 +8,7 @@ from netbox.search import SearchIndex, register_search
|
||||
class JournalEntryIndex(SearchIndex):
|
||||
model = JournalEntry
|
||||
fields = (
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = JournalEntry.objects.prefetch_related('assigned_object', 'created_by')
|
||||
filterset = extras.filtersets.JournalEntryFilterSet
|
||||
|
@ -10,12 +10,12 @@ class ContactIndex(SearchIndex):
|
||||
model = Contact
|
||||
fields = (
|
||||
('name', 100),
|
||||
('title', 200),
|
||||
('phone', 200),
|
||||
('email', 200),
|
||||
('address', 200),
|
||||
('title', 300),
|
||||
('phone', 300),
|
||||
('email', 300),
|
||||
('address', 300),
|
||||
('link', 300),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = Contact.objects.prefetch_related('group', 'assignments').annotate(
|
||||
assignment_count=count_related(ContactAssignment, 'contact')
|
||||
@ -28,9 +28,9 @@ class TenantIndex(SearchIndex):
|
||||
model = Tenant
|
||||
fields = (
|
||||
('name', 100),
|
||||
('slug', 100),
|
||||
('slug', 110),
|
||||
('description', 500),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = Tenant.objects.prefetch_related('group')
|
||||
filterset = tenancy.filtersets.TenantFilterSet
|
||||
|
@ -11,7 +11,7 @@ class ClusterIndex(SearchIndex):
|
||||
model = Cluster
|
||||
fields = (
|
||||
('name', 100),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = Cluster.objects.prefetch_related('type', 'group').annotate(
|
||||
device_count=count_related(Device, 'cluster'), vm_count=count_related(VirtualMachine, 'cluster')
|
||||
@ -24,7 +24,7 @@ class VirtualMachineIndex(SearchIndex):
|
||||
model = VirtualMachine
|
||||
fields = (
|
||||
('name', 100),
|
||||
('comments', 1000),
|
||||
('comments', 5000),
|
||||
)
|
||||
queryset = VirtualMachine.objects.prefetch_related(
|
||||
'cluster',
|
||||
|
@ -12,7 +12,7 @@ class WirelessLANIndex(SearchIndex):
|
||||
fields = (
|
||||
('ssid', 100),
|
||||
('description', 500),
|
||||
('auth_psk', 1000),
|
||||
('auth_psk', 2000),
|
||||
)
|
||||
queryset = WirelessLAN.objects.prefetch_related('group', 'vlan').annotate(
|
||||
interface_count=count_related(Interface, 'wireless_lans')
|
||||
@ -26,7 +26,7 @@ class WirelessLinkIndex(SearchIndex):
|
||||
fields = (
|
||||
('ssid', 100),
|
||||
('description', 500),
|
||||
('auth_psk', 1000),
|
||||
('auth_psk', 2000),
|
||||
)
|
||||
queryset = WirelessLink.objects.prefetch_related('interface_a__device', 'interface_b__device')
|
||||
filterset = wireless.filtersets.WirelessLinkFilterSet
|
||||
|
Loading…
Reference in New Issue
Block a user