Full-text search tree
Local searches
The ActionScript Foundry provides a full-text search feature to perform local searches on objects’ collections. Several options are available, such as index type (starts with, ends with, contains, exact match), character exclusions, and AND/OR Boolean operations.
The component does not use any remote connection because index building and searching are performed locally by the component.
As the example show below, you may use any of the words in all properties of the value objects to obtain the corresponding results.
Creating a search tree
How it works
The working of the search tree is quite simple and composed of two distinctive steps:
- First the data contained in the collection needs to be indexed. The search tree creates a graph of search patterns and links to the individual objects of the list, according to the index options.
- The search tree uses an input string to browse through the graph and find relevant objects.
This technique is much more efficient than a direct search into the collection because most of the work is done during the index building. The longer the input string is, the less the number of eligible branches on the graph will be.
First step: building the index
The index is created using the SearchTree and SearchProperty classes. For each property of the value objects to be indexed, a SearchProperty has to be created and a type of index to be defined. The properties are then used to create the index.
var property : SearchProperty = new SearchProperty( "firstName", SearchProperty.INDEX_TYPE_STARTS_WITH ); tree.index( originalDataProvider, [ property ] );
The type of index has more impact on performances than the number of objects to index and search for. Using the type INDEX_TYPE_CONTAINS will result in the most complex word graph.
Second step : performing the search
To perform the search, we simply use the search method using a string as the search criterion.
... // The second argument is the logical operator to use to combine single matches return tree.search( criterion, SearchTree.OPERATOR_AND ).values(); ...
Sub-Pages
- Introducing ActionScript Foundry
- Installation
- Basic types and structures
- The collection packages
- The MVC Framework
- Remote procedure call
- Building localized Flex Applications
- Using SmartForm
- Using the FlexBrowser
- Full-text search tree
- ActionScript Foundry: a beginner’s guide
- Accessing Remote Services
- Developping a contact manager application (CManager) – Part 1


