Custom Search Fields

SEARCH EXTRACTORS

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, but we have feature parity with the new Extractor2 implementation. 

To migrate your existing search extractors, you can retrieve your configurations by running this script in the Script Console:

groovy
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))

Using your old configurations as a reference, you'll need to manually create new custom search fields. It is likely your scripts can be vastly simplified in the new implementation. 

Use custom search fields to add useful indexes to Confluence's search to find content that meets specific criteria. Custom search fields expand the capabilities of your CQL search. You can expand 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 amount 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: 

  1. Navigate to Administration > Custom Search Fields > Create Custom Search Field
  2. Select Custom Search Fields.

    Once you have some created, you can select them here if they need to be modified. 

  3. Optional: Enter a Note for your reference. 
    This note can be anything that helps you identify or use the custom search field. 
  4. Enter a Field Name for your custom search field.  
    This field is required. If you choose to use capital letters, note 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. 
  5. 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.
  6. 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.
  7. Enter a script for Field Value
    This is how the field collects the value to store.
  8. Select Add to save the new custom search field

Use a custom search fields

Once you've created custom search fields, you can use them anywhere that you can search in Confluence, including Enhanced Search

If you want the search result to return all the pages that exist in Confluence, including those created before the custom search field, then the Confluence search index has to be rebuilt. For more information on rebuilding the index, read up on Content Index Administration.

Rebuilding the search index is a time-consuming, resource-intensive operation and should not be triggered during busy hours.

  1. Determine which custom search field you need and note the name. 

    You can see all of your custom search fields on Administration > Custom Search Fields. 

  2. Navigate to where you want to search. 
  3. Type the name of your custom search field and the value you want to search for, and then perform the search. 

    The search doesn't accept empty values. The custom search field has to be part of a CQL statement. For help with CQL, check out Using CQL 

    • Enhanced Search results: 
    • Confluence search results
      Confluence Search Results

Examples

For more information about using custom search fields, check out the following page:

On this page