Full Text Index in Dynamics AX 2012 – X++

Friends,

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.

I have added some dummy records/data for testing purpose as shown 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                   query;

    QueryBuildDataSource    qbds;

   

    QueryBuildRange         queryBuildRange;

    QueryRun                queryRun;

    SR_FullTextExample      sr_FullTextExample;

 

   

    query = new Query();

    qbds = query.addDataSource(tableNum(SR_FullTextExample));

    queryBuildRange = qbds.addRange(fieldNum(SR_FullTextExample, Name));

 

    queryBuildRange.rangeType(QueryRangeType::FullText);

 

    // The space character is treated as a Boolean OR.

    queryBuildRange.value(“Sreenath Kumar”);

 

    queryRun = new QueryRun(query);

    while (queryRun.next())

    {

        sr_FullTextExample = queryRun.get(tableNum(SR_FullTextExample));

        info(sr_FullTextExample.Name);

    }

 

}

 

 


As you can see, the results displayed is purely based on the search using ‘OR’ condition.

Happy Dax6ng,
Sreenath

Advertisements

3 Responses to “Full Text Index in Dynamics AX 2012 – X++”

  1. Mashook Says:

    thanks

  2. Santosh.Ramamurthy Says:

    Good explanation Sreenath….

  3. srinivas Says:

    Hi sreenath.can i hav the full tutorial of AX 2012 please.Its very urgent.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: