How can I implement Lucene search in my app?

0
I'm trying to understand how to implement Lucene Search I downloaded through the App Store but the documentation's explanation is beyond my skill level. I have a basic understanding of how Mendix works and made a small app that does some basic things. I've completed the basic training to a certain extent. What I'm trying to achieve is a search box that can search through the names (and description) of two or three different entities. Below is my domain model. I'm trying to search through Servicepakket and Dienstenpakket's name and description.  
asked
3 answers
3

Hi Jim,

I have used Lucene search in a project and it is very capable, but also takes some work to implement.  

For the search you described, you can accomplish that with native Mendix capabilities in the following way:

  • Create a ListView that points to Dienstenpakket entity
  • In this ListView, you can put a layoutgrid to display the attributes you are interested in, including attributes from entity Servicepakket
  • Now open the Search options for this ListView, as highlighted in an example below:
  • In the dialog box that appears, you can specifiy many attributes to search on, including attributes from associated entities.
  • Now when you start your app, there will be a search box above the Listview, which performs a unified search across all of the attributes you specified.  In my experience, this unified search happens very quickly.

 

Hope that helps,

Mike

answered
3

Mike is right, you can use a listview for that. In case you want to use the free lucene version (which is not only free, but also easier to deploy)

  1. You can create an after commit event microflow for "dienstenpakket" and one for "servicepakket". In that microflow you call the java-action updateIindex with parameters indexId: 0,   anyObject: dienstenpakket or servicepakket and searchText: $dienstenpakket/naam or $servicepakket/naam.
  2. Create an assocation from searchResult to "dienstenpakket" and "servicepakket".
  3. In a search microflow create searchCommand with indexId 0, Query: Text to search.  Call SearchIndex with that parameter and the referenceSet searchCommand_searchResult is a list of results. Voila.
  4. In case of existing you can update the index data just loop over dienstenpakket in batches (limit/offset) and call ACo_DienstenPakket from point 1.
  5. BTW: read the installation guidelines for the after startup/before shutdown stuff.

 

 

answered
0

Please have a look at https://appstore.home.mendix.com/link/app/29220/Appronto/Appronto-Search-Engine This is a Lucene implementation that will let you configure the entities and associations 1 layer deep with the help of the Model Reflection. It's a complete solution including a searchinput field presenting the first 10 results.

In the configuration you have control which attributes are more important containing the data.

answered