Custom Search Fields
Use custom search fields to add useful indexes to Confluence's search, enabling you to find content that meets specific criteria.
Beginning in ScriptRunner for Confluence 8.0.0, Custom Search Extractors no longer function. We moved to the Extractor2 implementation to maintain cross-compatibility with Confluence 7 and Confluence 8. Existing Search Extractors cannot be automatically migrated; however, we have achieved feature parity with the new Extractor2 implementation.
import groovy.json.JsonOutput
import com.onresolve.scriptrunner.runner.util.AOPropertyPersister
def AO_PROPERTY_KEY = "confluence_extractors"
def oldExtractors = AOPropertyPersister.loadList(AO_PROPERTY_KEY) as List<Map>
JsonOutput.prettyPrint(JsonOutput.toJson(oldExtractors))You'll need to create new custom search fields manually using your old configurations as a reference. Your scripts can be vastly simplified in the new implementation.
Custom search fields expand the capabilities of your CQL search. You can extend your CQL search capabilities outside of Confluence's standard CQL fields by creating custom search fields. You can search for specific criteria in spaces, attachments, comments, and pages.
For example, you can use custom search fields to:
- Search for pages that were last modified by a specific user.
- Search for comments on pages that were added before a certain date.
- Search for spaces that have fewer than a certain number of pages.
- Search for pages that have an attachment larger than a specified file size.
Create a Custom Search Field
To create a custom search field, follow these steps:
- Navigate to Administration > Custom Search Fields > Create Custom Search Field.
Select Custom Search Fields.
Note: Once you have some created, you can select them here if they need to be modified.- Optional: Enter a Note for your reference. This note can be anything that helps you identify or use the custom search field.
- Enter a FieldName for your custom search field. This field is required. If you choose to use capital letters, please keep in mind that the fields are case-sensitive, and you will need to use capitals to search with the fields. Spaces and special characters are not accepted.
- Select a Value Type. You can select Text or Number here. This determines what kind of value the field stores. For example, a field storing a username would use Text.
- Choose an option for Assign Field To.Your choices are Space, Attachment, Comment, or Pages.This determines the type of content that the field will be associated with. For example, select Pages if you want to search for pages edited by a specific user.
- Enter a script for Field Value. This is how the field collects the value to store.
- Select Add to save the new custom search field.
Use Custom Search Fields
Once you've created custom search fields, you can use them anywhere that you can search in Confluence, including Enhanced Search.
Determine which custom search field you need and note the name.
Note: You can see all of your custom search fields on Administration > Custom Search Fields.- Navigate to where you want to search.
Type the name of your custom search field and the value you want to search for, and then perform the search.
Tip: The search doesn't accept empty values. The custom search field has to be part of a CQL statement.- Enhanced Search results:
- Confluence search results
Examples
For more information about using custom search fields, check out the following page: