Full Text Index in AX 2012


Today I will demonstrate you that How to use full text index with AOT tables  in AX 2012.


This section describes how to create a full text index on a table by using the AOT.
  1. Create a table named FtiTable with two string fields named Field1 and Field2
  2. For better testing, increase the StringSize property from its default value to 64 on both fields.
  3. Set the TableGroup property to Main on the FriTable table.
Note:-
A table can have a full text index only if the TableGroup property is set to Main or Group on the table.
  1. Expand the FtiTable node, right-click the Full Text Indexes node, and then click New Full Text Index. This creates a node named FullTextIndex1.
  2. Right-click the FullTextIndex1 node, and then click New Field.
  3. Click the new index field node so that you can see its properties in the Properties window.
  4. In the Properties window for the new index field, set the DataField property to Field1.
  5. Insert some values in your table.  
  6. Save and compile the table

NoteNote:-
The code line that mentions QueryRangeType::FullText is what makes this example use the full text index.

static void GmFTIndexQueryJob6(Args _args)
{
    FtiTable recFtiTable; // Specified in the prerequisite topic.

    Query query2;
    QueryBuildDataSource queryBDSource3;
    QueryBuildRange queryBRange4;
    QueryRun queryRun5;

    print "Start the job.";
     query2 = new Query();
    queryBDSource3 = query2.addDataSource(tableNum(FtiTable));
    queryBRange4 = queryBDSource3.addRange(fieldNum(FtiTable, Field1));

    queryBRange4.rangeType(QueryRangeType::FullText);

    // The space character is treated as a Boolean OR.
    queryBRange4.value("diamond unfounded");

    // Loop through the records that are returned by the query.
    queryRun5 = new QueryRun(query2);
    while (queryRun5.next())
    {
        recFtiTable = queryRun5.get(tableNum(FtiTable));
        print "--------";
        print "Field1 == " + recFtiTable.Field1;
        print "Field2 == " + recFtiTable.Field2;
    }
    print "End the job.";
    pause;
}



Comments