Exact match when searching for custom field #1389

Closed
opened 2025-12-29 16:31:58 +01:00 by adam · 4 comments
Owner

Originally created by @cimnine on GitHub (Nov 7, 2017).

Issue type

[X] Feature request
[ ] Bug report
[ ] Documentation

Environment

  • Python version: 2.7
  • NetBox version: 2.2.4

Description

  • Create a custom field:
    • Objects: dcim > rack
    • Type: Text
    • Name: test1
    • Is filterable: ✔️
  • Take two racks and set the value of the custom field as follows:
    • Rack 1: urn:bla:1
    • Rack 2: urn:bla:100
  • Go to the rack overview and put a urn:bla:1 into the filter for the custom field

Expectation: I get one result.
Current behaviour: I get two results.

Suggestions

I suggest that all filtering on fields become exact and at the same time introducing a wildcard character for fuzzy searches, e.g. *. (E.g. urn:bla:1 would only match the one rack, whereas urn:bla:1* would still match both racks.)

An alternative suggestion is to add an option to the custom field's definition: Shall that field match exactly or not. (Similar to the "Is filterable" checkbox.)

Another alternative suggestion is to support the Google syntax for exact matches, i.e. everything that's wrapped in " must be an exact match. (E.g. "urn:bla:1" would only match the one rack, whereas urn:bla:1 would still match both racks.)

Originally created by @cimnine on GitHub (Nov 7, 2017). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. For assistance with installation issues, or for any other issues other than those listed below, please raise your topic for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. Due to an excessive backlog of feature requests, we are not currently accepting any proposals which extend NetBox's feature scope. Do not prepend any sort of tag to your issue's title. An administrator will review your issue and assign labels as appropriate. ---> ### Issue type [X] Feature request <!-- An enhancement of existing functionality --> [ ] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) If you are submitting a bug report and have made any changes to the code base, please first validate that your bug can be recreated while running an official release. --> ### Environment * Python version: 2.7 * NetBox version: 2.2.4 <!-- BUG REPORTS must include: * A list of the steps needed for someone else to reproduce the bug * A description of the expected and observed behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description * Create a custom field: * Objects: dcim > rack * Type: Text * Name: test1 * Is filterable: ✔️ * Take two racks and set the value of the custom field as follows: * Rack 1: `urn:bla:1` * Rack 2: `urn:bla:100` * Go to the rack overview and put a `urn:bla:1` into the filter for the custom field **Expectation:** I get one result. **Current behaviour:** I get two results. #### Suggestions I suggest that all filtering on fields become exact and at the same time introducing a wildcard character for fuzzy searches, e.g. `*`. (E.g. `urn:bla:1` would only match the one rack, whereas `urn:bla:1*` would still match both racks.) An alternative suggestion is to add an option to the custom field's definition: Shall that field match exactly or not. (Similar to the "Is filterable" checkbox.) Another alternative suggestion is to support the Google syntax for exact matches, i.e. everything that's wrapped in `"` must be an exact match. (E.g. `"urn:bla:1"` would only match the one rack, whereas `urn:bla:1` would still match both racks.)
adam added the status: acceptedtype: feature labels 2025-12-29 16:31:58 +01:00
adam closed this issue 2025-12-29 16:31:58 +01:00
Author
Owner

@cimnine commented on GitHub (Nov 7, 2017):

Some context

We're using custom fields to represent the IDs of our legacy system, which happen to be URNs. (These are all over the place, so we have to stick with them for a long time.) Currently, I'm writing a tool that copies any rack from the legacy system to Netbox and updates all racks already existing in Netbox based on the custom field. Hence I would appreciate if I could have a way to do exact-match lookups on custom fields.

@cimnine commented on GitHub (Nov 7, 2017): **Some context** We're using custom fields to represent the IDs of our legacy system, which happen to be URNs. (These are all over the place, so we have to stick with them for a long time.) Currently, I'm writing a tool that copies any rack from the legacy system to Netbox and updates all racks already existing in Netbox based on the custom field. Hence I would appreciate if I could have a way to do exact-match lookups on custom fields.
Author
Owner

@troxil commented on GitHub (Nov 9, 2017):

@cimnine Isn't this how all existing filtering works? It's not exact at all. Prefixes, devices etc.

@troxil commented on GitHub (Nov 9, 2017): @cimnine Isn't this how all existing filtering works? It's not exact at all. Prefixes, devices etc.
Author
Owner

@cimnine commented on GitHub (Nov 10, 2017):

Thanks for pointing this out, @troxil. I've changed it from a bug report to feature request.

@cimnine commented on GitHub (Nov 10, 2017): Thanks for pointing this out, @troxil. I've changed it from a bug report to feature request.
Author
Owner

@jeremystretch commented on GitHub (Feb 21, 2018):

An alternative suggestion is to add an option to the custom field's definition: Shall that field match exactly or not. (Similar to the "Is filterable" checkbox.)

This seems like a favorable approach over introducing a potentially ambiguous wildcard approach.

@jeremystretch commented on GitHub (Feb 21, 2018): > An alternative suggestion is to add an option to the custom field's definition: Shall that field match exactly or not. (Similar to the "Is filterable" checkbox.) This seems like a favorable approach over introducing a potentially ambiguous wildcard approach.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1389