Netbox: Global search on homepage

Created on 1 Jul 2016  路  14Comments  路  Source: netbox-community/netbox

A search across all sections and all fields. e.g. search for "customerX" and the results page shows Racks, Devices, Circuits etc. that contain any matched field content.

Most helpful comment

This has been implemented on the v2-develop branch and will be available in NetBox v2.0.

All 14 comments

This looks like it relates to #132.

132 specifically mentions 'devices', but if that can be expanded to ALL sections, then yes.

@paradoxni In your example you use a customer name. I think that specific function would be provided by #16 (multitenancy support).

I had used the search term as an example, but I think it would be useful to be able to search across all fields (including comments) across all sections. Another example would be a circuit, where you could search not just using circuitID. A global search, if you will.

imported stuff from phpIPAM, "Search Within" doesn't search the "Description" field?

@rekeds "Search within" limits searches to a scope. For example, finding all prefixes within 192.168.0.0/16.

@jeremystretch thank you. Netbox is great.
+1 for ability to search "all fields".

I would want to see this global search field on every page, not just the homepage. I don't see a problem with contextual search as well, but like having a lazy global search too. Hopefully this includes all types of fields, as addressed in https://github.com/digitalocean/netbox/issues/358

358 was merely an expansion to the existing direct database querying. Implementing global search will require a dedicated search engine and indexing e.g. using Haystack.

Adding an enterprise search engine seems a bit overkill for simply federating search across the existing models. Since we're tied to PostgreSQL anyway, you should be able to use

https://docs.djangoproject.com/en/1.10/_modules/django/contrib/postgres/search/#SearchVector

to pull results across all the models.

@darthmdh I could be missing something but I think that's still limited to searching one table (model) at a time. What we want is to search for an instance of a string across many models.

@jeremystretch The docs claim you can combine SearchVectors with + syntax but looking at the examples its unclear to me if that then makes logical sense when it comes to filter() the results. Unfortunately other than for deployment purposes I haven't yet dived into Django 1.10 to get familiar with this new API.

Maybe something like https://github.com/etianen/django-watson is more immediately useful?

Or, to state the obvious:

~
devices = Device.objects.filter(Q(name__icontains=q) | Q(comments__icontains=q) |
Q(serial__icontains=q) | Q(asset_tag__icontains=q) | ... )
prefixes = Prefix.objects.filter(...)
addresses = IPAddress.objects.filter(...)
# etc
~

The results page has a subsection for devices, a subsection for prefixes, a subsection for addresses etc. Each section is skipped if there are no matches. Each section can be limited to (say) 10 hits, and if you hit the More... link then it does a regular search for that object type only.

If the query looks like an IP address then parse it as such, and add the relevant IP address field searches.

This has been implemented on the v2-develop branch and will be available in NetBox v2.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoalex picture hoalex  路  3Comments

billyzoellers picture billyzoellers  路  3Comments

VictorJ76 picture VictorJ76  路  3Comments

tyler-8 picture tyler-8  路  3Comments

bellwood picture bellwood  路  3Comments