I wrote this a while back to do what you are asking with a Microflow: https://modelshare.mendix.com/models/fa101212-5b7c-4546-ae28-ec0ad891b473/sub_twostringpatternrecognizer. I also wrote a blog explaining it at http://www.nolanramsey.com/blog/2016/8/11/pattern-recognition-and-optimization-in-mendix. Good luck!
Monique,
I am not sure, but it seems to me that Like in OQL and Contains in XPath yield the same result. From the documentation, Like does the following
And the docs for XPath Contains:
So if I have a string I am looking for, lets say 'Mendix', using like '%Mendix%' with OQL will return the same results as contains('Mendix') in XPath. Do you see different results than this? Or are you trying to search with wildcards in the middle of the search term?
Also, as Ronald mentioned, I have implemented the Lucene search engine, which is very powerful and includes more Like searching capabilities than either OQL or XPath and offers additional capabitilities like fuzzy search. In addition, it can index entities and attributes from your domain model but can also index the contents of documents in your Mendix app.
Hope that helps,
Mike
OQL is very fast and very powerful because it is directly translated into a SQL statement.
You can create a java action with input OQL and result : List of MyEntity. The OQL must return the id's of MyEntity. For example
FROM MYMODULE/MYENTITY AS ME
SELECT ME/ID
WHERE ME/Name like '%search%' OR MA/Group like '%search%'
You can use powerful options like NOT IN to compare tables without associations.
FROM Contracten.Contract AS CT
LEFT JOIN Integratie.ImportContract AS IC ON (CT/Nummer = IC/Nummer)
WHERE (IC/ID = NULL) AND (CT/Actief = ''true'')
SELECT CT/ID AS _ID
LIMIT 500
The implementation of the java action is this (for all entities)
List<IMendixIdentifier> ids = new ArrayList<IMendixIdentifier>();
IDataTable dataTable = Core.retrieveOQLDataTable(getContext(), oql);
for (IDataRow row : dataTable.getRows()) {
Object value = row.getValue(getContext(), 0);
if (value instanceof IMendixIdentifier) {
ids.add((IMendixIdentifier) value);
}
}
List<IMendixObject> objectlist = Core.retrieveIdList(getContext(), ids);
return objectlist;
By default it's not possible to use OQL query's in the modeler in for instance Microflows. There is a module for that: https://appstore.home.mendix.com/link/app/1528/Appronto/Reporting-4-Mendix
You could also look at this module: https://appstore.home.mendix.com/link/app/3099/FlowFabric-BV/Lucene-text-search
Might give you also the sollution you are looking for.
Regards,
Ronald