Search Extractors
Search Extractors allow you to add useful indexes to Confluence’s search in order to find pages that meet a specific criteria. Some examples are:
Find all home pages
Find pages with large attachments
Search all pages that contain a specific label
Find pages last modified by a specific user
Search for pages created in a specific year
Read more about extractors in the Confluence Extractor Module documentation.
Browse Search Extractor Functionality
After you click Create Search Extractor, a search bar appears that allows you to Search ScriptRunner Functionality. Use this search bar to search the available search extractors.
For example, if you’re looking for a search extractor that works with attachments you could type "Attachments" and press Enter. Then, the list of search extractors is narrowed down to only those containing the word "attachments" in their title or description.
Example Extractors
All the examples are available under Admin → Search Extractors → Custom search extractor → Expand examples section.
Search Page By Year Extractor
The extractor helps to return all the pages created in a year.
Line 7: Create an instance of Calendar
.
Line 8: Set the time of our calendar to match the page’s creation date.
Line 9: Get the year the page was created.
Line 10: Store the year as a field in the Lucene document.
The following screen shot shows an example search result for year : 2017
:
Pages With Label Extractor
This extractor returns all the pages that contain the "finance" Label
Line 9: Create a new Label, "finance".
Line 12: If the page has the "finance" label, store that as a field in the Lucene document.
The search string for this extractor is label : finance
.
Pages With Attachments Size Extractor
This extractor helps to search all the pages with attachment more than 20 meg in size.
Line 9: Calculate 20 megabytes as bytes.
Line 10: Get all attachments for a page and get total size in bytes.
Line 13: If the total attachment size is large enough, store attachment with value 20 for the page.
The search string for this extractor is attachment : 20
.
Page Last Modified By Extractor
This extractor finds all the pages that were last modified by a specific user.
Line 7: Get the name of the last modifier.
Line 8: Store the modifier field with user name as its value.
Use the Confluence username to do a search. For an example if user name is "rfranco" then the search string will be modifier : rfranco
.