Content Level Scripts and Functions
Access and Use the Metadata Generation Scripts
The Metadata Generation Script is used to override automatic metadata generation for the selected content source.
This script is available only for the SQL Connector.
- On the Connectivity Hub page, click the content source name under Content. Click the Advanced tab.
- Scroll down to see Metadata Generation Script.
- Use the following HOST functions to generate the list of metadata properties that you require.
SQL Connector: Metadata Generation Parameters
Sub-type | Function (HOST object) | Input Parameters (Type) | Return Type | Description |
---|---|---|---|---|
Data Access | GetDataSet()
|
|
DataSet | Provides direct access to the items data set. |
Specific to the Unstructured Field |
AddStringMetadata()
|
ByVal name (String) |
|
Adds the string metadata to the columns. |
AddBooleanMetadata()
|
ByVal desc (String) |
Adds the metadata as a Boolean value to the columns. | ||
AddNumberMetadata()
|
ByVal scriptEnabled (Boolean) |
Adds the metadata as a number value to the columns. | ||
AddIntegerMetadata()
|
ByVal columns (String) |
Adds the metadata as an integer value to the columns. | ||
AddDateMetadata()
|
ByVal metascript (String) | Adds the metadata as a date value to the columns. |
Add/Edit metadata to control values for the search index
When you specify the your custom metadata fields, you can write a VB.NET script to control the value that goes into the search index.
-
Content Sources: Click the Content Sources link to see the Content Management page.
-
Actions: Click > Metadata for the content that you want to modify.
- The Content Metadata page appears.
-
New: Click New to select the type of metadata that you will use.
-
The Edit Metadata Property dialog appears.
-
Click Define by script in the Value field to access the scripting pane.
-
Pick column: Select a property in the drop-down.
- Click the Compile link above the field to validate the script.
-
Click Save to save your settings and return to the Metadata page.
-
The global variable
HOST
is accessible for any of your scripts
-
-
You can choose to return a string for a single value or a string array for multiple values.
-
See the following example to replace the value of the client code script:
-
if HOST.GetStringValue("ClientCode") = "D" then return "Deleted" else return HOST.GetStringValue("ClientCode") end if
To learn more about the text and metadata functions, see the table below:
Subtype |
Function (HOST object) |
Input Parameters (Type) | Return Type |
Description |
---|---|---|---|---|
Data Access - All connectors |
|
DataSet |
Provides direct access to the items dataset. |
|
|
ByVal title (String) | DataSet |
Provides direct access to any additional datasets that might have been returned. |
|
|
ByVal colname (String) | Boolean |
|
|
|
ByVal colname (String) |
Object |
|
|
|
ByVal colname (String) | Object |
Returns an array of values from the primary dataset's first row. |
|
|
ByVal tableIndx (Integer) ByVal colname (String) |
Object |
Returns the Object array result of the specified column in the specified table of the current dataset. |
|
|
ByVal colname (String) |
String |
|
|
|
ByVal colname (String) | String |
If the underlying data has linked multi-columns, the column names are returned. |
|
|
ByVal tableIndx (Integer) ByVal colname (String) |
String |
Returns the string array result of the specified column in the specified table of the current dataset. |
|
|
ByVal colname (String) | String |
|
|
Connectivity Hub - All connectors
|
|
|
String |
Gets the primary ID of an item. |
Connectivity Hub - All connectors |
|
String |
Gets the secondary ID of an item. |
|
|
String |
Gets the folder IDs. |
||
|
String |
Gets the folder sub IDs. |
||
Specific to the Unstructured Field - SQL connector |
|
ByVal fullpath (String) ByVal name (String) |
Boolean |
Note: To add more than one file to a zip archive, multiple entries, one file path per line, can be entered
|
Specific to the Unstructured Field - SQL connector |
|
ByVal data() (byte) ByVal name (String) |
Boolean |
|
Specific to the Unstructured Field - SQL connector |
|
ByVal extension (String) |
If the type is File System, overrides the file extension of the returned file path. |
|
|
|
String |
Gets the file extension. |
|
|
ByVal extension (String) | String |
Gets the temp file name. Use this method for copying the file for indexing purposes. |
Filter Scripts and Functions
This script is available for most content sources and is used after you add and test your content.
-
For example, for
WebService Content
andTemplate Content
. -
You can also access this field when you select Exchange Mailbox Content > Private Mailboxes.
-
This script is used to filter individual items from a crawl. In other words, the script is applied after enumeration and before indexing.
This script must return a Boolean value.
If the script is active and returns the value True then the global variable HOST
is accessible throughout the script:
True
: The item is indexed.False
: The item is rejected.
Choose to return a string for a single value or to return a string array for multiple values.
See the following example:
if HOST.GetStringValue("ClientCode") = "D" then return false
return true
To choose from a list of the existing filter functions, see the table below:
WARNING! Make sure that your script returns the correct data type and watch for any arrays that might be returned.
Subtype | Function (HOST object) | Input Parameter (Type) | Return Type | Description |
---|---|---|---|---|
Data Access |
|
|
DataSet | Provides direct access to the item's dataset containing all of the metadata for the dataset. |
GetSubDataSet()
|
ByVal title (String) | DataSet |
Provides direct access to any additional datasets that might be returned. |
|
GetValueFromDataset()
|
DataSet, colname | DataSet |
Example:
|
|
|
ByVal colname (String) |
String |
|
|
|
ByVal colname (String) | Object |
|
|
|
ByVal colname (String) | String |
|
|
|
ByVal colname (String) | Object | Returns an array of values from the first row of the primary dataset. | |
|
ByVal colname (String) | Boolean |
If the underlying data has a linked multi-column, the column name is returned. |
|
|
ByVal colname (String) | String |
If the underlying data has a linked multi-column value, the column name is returned as a string value. |
|
Connectivity Hub-Related |
|
String |
Gets the primary ID of the item. |
|
|
String | Gets the secondary ID of the item. | ||
GetFolderID()
|
String | Gets the folder ID of the item. | ||
GetFolderSubID()
|
String | Gets the folder sub ID of the item. |
Index Item Scripts and Functions
After you add and test content such as SQL Server Content
, and WebService Content
, you can write scripts to determine how items are indexed.
- Go to Content and click on a content type under Content.
- The
<type of>
Content page appears. - Click the Item Definition tab and scroll down to see the required Item Extension box.
- Reference DS Columns with brackets(required): Make a selection such as
SPW_EXTENSION
. - Advanced (required): Click the Advanced tab.
- Enter your script using the information provided above in this section.
- Compile: Click the Compile link above the field to validate and use your script.