Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global search on homepage #159

Closed
ghost opened this issue Jul 1, 2016 · 14 comments · May be fixed by devcode1981/netbox#12 or MarcelRaschke/netbox#26
Closed

Global search on homepage #159

ghost opened this issue Jul 1, 2016 · 14 comments · May be fixed by devcode1981/netbox#12 or MarcelRaschke/netbox#26
Milestone

Comments

@ghost
Copy link

ghost commented Jul 1, 2016

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.

@ryanmerolle
Copy link
Contributor

This looks like it relates to #132.

@ghost
Copy link
Author

ghost commented Jul 1, 2016

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

@jeremystretch
Copy link
Member

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

@ghost
Copy link
Author

ghost commented Jul 1, 2016

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.

@rekeds
Copy link

rekeds commented Jul 6, 2016

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

@jeremystretch
Copy link
Member

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

@rekeds
Copy link

rekeds commented Jul 7, 2016

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

@alexjhart
Copy link
Contributor

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 #358

@jeremystretch
Copy link
Member

#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.

@hawko2600
Copy link

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.

@jeremystretch
Copy link
Member

@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.

@hawko2600
Copy link

@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?

@candlerb
Copy link
Contributor

candlerb commented Feb 6, 2017

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.

@jeremystretch
Copy link
Member

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

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants