By default, one blocking query is predefined in the Candidate Select file. If the default query does not meet your requirements, you can define new queries for the master index application. You can either use an existing query builder class or create a custom query builder by creating a custom plug-in (for more information, see Implementing Master Index Custom Plug-ins (Repository) in Developing Sun Master Indexes (Repository)). Blocking queries contain block definitions, which define the groups of fields used for each query pass and how those groups are processed. Each block definition contains one or more set of query blocks. Each query block defines the query rules for one of the groups of fields that make up the block definition.
The changes you make on the Query page of the Configuration Editor are reflected in the Candidate Select file. For more information about this file and the configurable query options, see Candidate Select Configuration (Repository) in Understanding Sun Master Index Configuration Options (Repository). If you create a new query to use from the EDM, make sure to add that query to one of the search definitions in the Enterprise Data Manager file.
You can create blocking queries either through the Configuration Editor or by modifying the XML file directly. Both methods are described here.
In the Projects window, right-click the master index application you want to modify, and then click Open.
If the Configuration Editor dialog box appears, click Edit to check out the listed files.
The Configuration Editor appears.
Click the Query tab.
The Query page appears.
In the Blocking Queries section, click Add.
The Blocking Query Builder dialog box appears.
In the Query Builder section, enter the fields described in Master Index Query Builder Dialog Box Fields and XML Elements (Repository).
Do the following for each query block you want to include in the query:
In the Block Definitions section, click Add.
The Block Definition dialog box appears.
In the Block Name field, enter a unique name for the query block.
(Optional) In the Hint field, define an Oracle or SQL Server hint for the query block.
For SQL Server, you can only use OPTION hints.
In the Block By section, click Add.
The Block Rule dialog box appears, where you can specify a field to include in the query block.
Enter values for the fields on the dialog box as described in Master Index Query Block Fields and XML Elements (Repository), and then click OK.
For each field to include in the query block, repeat the previous two steps.
When you are done specifying fields for the rule, click OK on the Block Definition dialog box.
For each query block you want to create for this query, repeat the previous step.
When you are done defining the query blocks, click OK.
On the Configuration Editor toolbar, click Save.
In the Projects window, expand the Configuration node in the project you want to modify, and then double-click the Candidate Select file.
The file opens in the NetBeans XML editor.
Create a new query-builder element in the QueryBuilderConfig element.
Make sure the new element is created outside of any existing query-builder elements.
For the new query-builder element, define the attributes listed in Master Index Query Builder Dialog Box Fields and XML Elements (Repository).
For example:
<query-builder name="PHONETIC-SEARCH" class= "com.stc.eindex.user.CustomQueryBuilder" parser-class= "com.stc.eindex.configurator.impl.querybuilder.KeyValueConfiguration" standardize="false" phoneticize="true"> </query-builder> |
Create a new config element between the query-builder tags.
To create a query block, do the following:
In the new config element, create a new block-definition element with a number attribute and assign a unique ID code to the number attribute.
For example:
<query-builder name="BLOCKING-SEARCH" class= "com.stc.eindex.querybuilder.BlockingQueryBuilder" parser-class= "com.stc.eindex.configurator.impl.querybuilder. KeyValueConfiguration" standardize="true" phoneticize="true"> <config> <block-definition number="ID1"> </block-definition> </config> </query-builder> |
To add a database hint, create and define a new hint element in the new block-definition element.
The following example illustrates an Oracle hint.
<config> <block-definition number="ID1"> <hint>FIRST_ROWS_100</hint> </block-definition> <config> |
Hints are especially useful when a blocking query uses only child object fields; the hint can specify to scan the child object table first. For SQL Server, only OPTION hints are supported.
In the new block-definition element, create a block-rule element.
For each field in the data block, create the elements and attributes listed in Master Index Query Block Fields and XML Elements (Repository).
The following example illustrates the use of both range and equals elements, as well as upper and lower bounds.
<config> <block-definition number="ID1"> <hint>FIRST_ROWS_100</hint> <block-rule> <equals> <field>Enterprise.SystemSBR.Person.FirstNamePh</field> <source>Person.FirstNamePh</source> </equals> <equals> <field>Enterprise.SystemSBR.Person.LastNamePh</field> <source>Person.LastNamePh</source> </equals> <range> <field>Enterprise.SystemSBR.Person.DateOfBirth</field> <source>Person.DateOfBirth</source> <default> <lower-bound type=”offset”>-5</lower-bound> <upper-bound type=”constant”>2009-01-01 </upper-bound> </default> </range> </block-rule> </block-definition> <config> |
Repeat the previous step for each data block you need to define for the query.
All data blocks for one query must be defined within one config element.
Save and close the file.
The following table lists and describes the fields on the Block Rule dialog box of the Configuration Editor, along with the corresponding elements and attributes in the Candidate Select file. To see how the XML elements are organized, see the sample in Adding a Query Block to a Master Index Query (Repository). For more information about the structure of a query block, see Candidate Select Configuration (Repository) in Understanding Sun Master Index Configuration Options (Repository).