Full text index supports to quickly query words that are embedded in the middle of a string field of a table. Well, this is a very nice enhancement to query on Database table fields for the developers who work with the latest vesion [Microsoft Dynamics AX 2012]
Good thing is we can use this Index on Memo fields and also Extended data type.
Let me explain with an example. Create a new table as shown below and add a new field of type string “Name” to it – On the field use EDT – Name. In the below example, my table Name is SR_FullTextExample.
Once you are done with your table, Go to FullTextIndex Node >> Right click and create a new FullTextIndex.
Rename it to NameFullTextIndex. Drag and drop Name field from the fields to the newly created index.
The table with index should look like below.
Now, let us see how to use this FullTextIndex for searching a field with the words.
Please Note: X++ select statements cannot use a full text index
A full text index can improve the speed of queries that search for words that are embedded in string and memo fields on tables. [MS help]
The QueryRange class has a rangeType method. You can direct a QueryRange object to use the full text index by passing the QueryRangeType::FullText enum value to the rangeType method. [MS help]
If the value you are searching for is a two word phrase with a space between the words, the system treats the space as a Boolean OR [MS Help]
Below job will help to search the strings with in a full string in the fields.
static void SR_FullTextQuery(Args _args)
query = new Query();
qbds = query.addDataSource(tableNum(SR_FullTextExample));
queryBuildRange = qbds.addRange(fieldNum(SR_FullTextExample, Name));
// The space character is treated as a Boolean OR.
queryRun = new QueryRun(query);
sr_FullTextExample = queryRun.get(tableNum(SR_FullTextExample));