Custom Fields results in main Object search #4676

Closed
opened 2025-12-29 19:19:23 +01:00 by adam · 7 comments
Owner

Originally created by @akballow on GitHub (Mar 17, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

2.9.10

Feature type

Change to existing functionality

Proposed functionality

Right now I add custom fields like Device Owner Email in Devices or IP address Owner Email in IPAM. When you search in the custom field search box specifically it works, but If i wanted to search an email across all objects in the main search bar it does not find the emails in the custom fields. It would be nice to have the option for custom fields to return results from the main object search. It could be a check box to enable it.

Use case

Having common custom fields entries searchable across objects for a single search result instead of having to go into each object to search for it.

Database changes

No response

External dependencies

No response

Originally created by @akballow on GitHub (Mar 17, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version 2.9.10 ### Feature type Change to existing functionality ### Proposed functionality Right now I add custom fields like Device Owner Email in Devices or IP address Owner Email in IPAM. When you search in the custom field search box specifically it works, but If i wanted to search an email across all objects in the main search bar it does not find the emails in the custom fields. It would be nice to have the option for custom fields to return results from the main object search. It could be a check box to enable it. ### Use case Having common custom fields entries searchable across objects for a single search result instead of having to go into each object to search for it. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:19:23 +01:00
adam closed this issue 2025-12-29 19:19:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 21, 2021):

This would be possible to implement in a primitive way by appending Q(custom_field_data__icontains=value) to the queryset for the search() method on custom field model filtersets. However, it would not behave the same as the individual custom field filters, which look at each individual custom field and apply the specified filtering logic (loose versus strict).

For example, suppose you have a custom field which stores phone numbers, which you intend to match only when a complete number matches. Taking the shotgun approach here would mean that objects would match on any matching set of digits, such as an AS number. This will likely result in frequent irrelevant search results, and dilutes the value of the global search function.

The alternative approach would be to retrieve the applicable custom fields for each model, and carefully extend the queryset filter to apply each one as intended, however this would introduce a substantial amount of overhead, especially considering that the global search currently defaults to querying for 19 different models. We might be better off deferring this feature until we can come up with a more robust search solution.

@jeremystretch commented on GitHub (Apr 21, 2021): This would be possible to implement in a primitive way by appending `Q(custom_field_data__icontains=value)` to the queryset for the `search()` method on custom field model filtersets. However, it would not behave the same as the individual custom field filters, which look at each individual custom field and apply the specified filtering logic (loose versus strict). For example, suppose you have a custom field which stores phone numbers, which you intend to match only when a complete number matches. Taking the shotgun approach here would mean that objects would match on any matching set of digits, such as an AS number. This will likely result in frequent irrelevant search results, and dilutes the value of the global search function. The alternative approach would be to retrieve the applicable custom fields for each model, and carefully extend the queryset filter to apply each one as intended, however this would introduce a substantial amount of overhead, especially considering that the global search currently defaults to querying for 19 different models. We might be better off deferring this feature until we can come up with a more robust search solution.
Author
Owner

@candlerb commented on GitHub (May 12, 2021):

Some approaches in https://github.com/netbox-community/netbox/issues/1190#issuecomment-754606462

@candlerb commented on GitHub (May 12, 2021): Some approaches in https://github.com/netbox-community/netbox/issues/1190#issuecomment-754606462
Author
Owner

@jeremystretch commented on GitHub (Sep 9, 2021):

Blocked by #7016

@jeremystretch commented on GitHub (Sep 9, 2021): Blocked by #7016
Author
Owner

@emil-nasso commented on GitHub (Mar 17, 2022):

@jeremystretch Does #7016 make this issue "obsolete", as in this not being a problem anymore?

About the approach of retrieving the applicable custom fields for each model and extending the query, perhaps that would be easier if the user could choose whether or not a custom field should be "searchable" or not. A "simple" checkbox when configuring/creating a custom field. :)

That way the query could be extended with only those fields and it would be up to the user to choose how much overhead to add to searching. Some fields might be relevant for searching, some might make zero sense to search for. A custom field containing an external reference number would be great to be able to search for in the global search. A field containing the number of network interfaces on a device, maybe doesn't make sense to query in the global search (maybe a bad example...).

@emil-nasso commented on GitHub (Mar 17, 2022): @jeremystretch Does #7016 make this issue "obsolete", as in this not being a problem anymore? About the approach of retrieving the applicable custom fields for each model and extending the query, perhaps that would be easier if the user could choose whether or not a custom field should be "searchable" or not. A "simple" checkbox when configuring/creating a custom field. :) That way the query could be extended with only those fields and it would be up to the user to choose how much overhead to add to searching. Some fields might be relevant for searching, some might make zero sense to search for. A custom field containing an external reference number would be great to be able to search for in the global search. A field containing the number of network interfaces on a device, maybe doesn't make sense to query in the global search (maybe a bad example...).
Author
Owner

@tea-zup commented on GitHub (Jul 26, 2022):

I have a similar problem. I have a custom field 'administrator' in IPAM -> IP Addresses. If I use the 'all object' search the administrator is not found. If I use the 'quick search' in the IPAM -> IP Addresses page the administrator is also not found. The only way to find the administrator is to go to IPAM -> IP Addresses -> Filters -> Administrator.

I saw that similar problems have been mentioned in #1190. Have there been any updates on solving this issue?

Finding custom fields through the main (all object) search would be very helpful to me. Thank you.

@tea-zup commented on GitHub (Jul 26, 2022): I have a similar problem. I have a custom field 'administrator' in IPAM -> IP Addresses. If I use the 'all object' search the administrator is not found. If I use the 'quick search' in the IPAM -> IP Addresses page the administrator is also not found. The only way to find the administrator is to go to IPAM -> IP Addresses -> Filters -> Administrator. I saw that similar problems have been mentioned in [#1190](https://github.com/netbox-community/netbox/issues/1190). Have there been any updates on solving this issue? Finding custom fields through the main (all object) search would be very helpful to me. Thank you.
Author
Owner

@jeremystretch commented on GitHub (Oct 11, 2022):

I recently opened #10560 to capture work being done on a new search engine for NetBox v3.4. This FR will likely get wrapped up in that initiative, but I'll keep this issue open for now.

@jeremystretch commented on GitHub (Oct 11, 2022): I recently opened #10560 to capture work being done on a new search engine for NetBox v3.4. This FR will likely get wrapped up in that initiative, but I'll keep this issue open for now.
Author
Owner

@jeremystretch commented on GitHub (Oct 12, 2022):

Preliminary work for this has been completed in 31c246327, but will be folded into #10560 as mentioned above.

@jeremystretch commented on GitHub (Oct 12, 2022): Preliminary work for this has been completed in 31c246327, but will be folded into #10560 as mentioned above.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4676