The Global Search module provides advanced search capabilities based on Lucene Search for your Mendix app. More specifically, this module allows you to search through multiple entities and attributes with just one query. Version 4 adds a bunch of new features and simplifications of the module:
- Advanced lucene search: search by using the Lucene Query language.
- Simple and advanced indexing: Simple indexing indexes the mendix entity. Advanced indexing used a json structure to index the entity. This way, you can fully customize what you want to index for each searchable object, including searching over association for example.
- Making entities searchable by creating specializations of GlobalSearch.SearchableObject. No more runtime configuration needed, everything can be set-up during development.
The Global Search module provides advanced search capabilities based on Lucene Search for your Mendix app. More specifically, this module allows you to search through multiple entities and attributes with just one query.
The module provides an extended Lucene search query, which allows you to search through text in several ways. Below you find an example of what you can expect when using the search. In this example, the string we want to return as a search result is “This is a search module”, due to the extended query implemented in this module, you can search the following, which will all return the mentioned string:
- Exact word match: e.g. “This”, “search”, “module”.
- Phrase match: e.g. “This is a”, “a search module”.
- Wildcard match: e.g. “sear”, “modul”
- Wildcard Phrase match: e.g. “his is a”, “a search mod”
Furthermore, you can also use the default Lucene query syntax to do a fielded search. For more details, see https://www.lucenetutorial.com/lucene-query-syntax.html.
Typical usage scenario
The Global Search module can be used when searching over multiple objects at once is required.
Features and limitations
- Faceted searching
- Fuzzy searching
- Fielded searching
- Simple indexing based on entity definition in the domain model
- Advanced indexing based on json structure
- Mendix 8.6.4 or higher
- Community Commons
- Required Jar files:
To make entities searchable, follow these steps:
0. Add the ASU_GlobalSearch to your after startup microflow.
1. Copy SUB_IndexObject and SUB_DeleteIndex into your own project.
2. Change BCO_SearchableObject and BDE_SearchableObject to use the copies you made in step 1.
3. Let each entity that you want to be searchable inherit from GlobalSearch.SearchableObject. After this, change the two SUB microflows from step 1 to accomodate for these specializations.
For indexing, you can use a simple index. This will index all attributes for an entity with the names you have in the domain model. Here, there is no support for searching over association. You can also index objects based on a JSON string. To do this, create an export mapping for the entity you want to index and add this json to the java action. Only the key/value pairs specified in the json will be indexed. This does support indexing over association, as you can include associated objects/list of objects in the json. For both methods, see the example implementation in SUB_IndexObject. Finally, during indexing, you can also add a list of Facets. These are key value pairs that are stored for that particular object, which can be used for filtering the search results later on.
The search java action returns a list of SearchableObjects that match the query. In the example snippet, a list view with specialization templates is used in order to display each specialization differently. Of course, your implementation can differ, but this might give a good example. For reference, you can refer to ACT_Searcher_Search.