Issue in applying date-filter in OpenSearch

I have one get service where I am using entity-find on an entity and getting the result. This entity find has one date filter applied like the below:


Now, I want to convert this entity find service to OpenSearch. I am able to write the search service but I am facing an issue in applying the above same <date-filter/> in Search API. Can somebody please guide me in resolving this issue? I am not sure how I can apply this same filter in an open search service. For OpenSearch, I am calling this Moqui inbuilt service:

Thank you in advance!

1 Like

You should be able to use the range filter like I did here: PopRestStore/service/popstore/PrestashopServices.xml at febafdf58f598d6d55d7362e7e4ec113174410ad · acetousk/PopRestStore · GitHub.

Here’s the Open Search Documentation: Range field types - OpenSearch Documentation

You’ve got the right idea for calling the:

service. You can see more information about it here: moqui-framework/framework/service/org/moqui/search/SearchServices.xml at 2e08c17a8e90ef2d2f96f1ab5950f30aa1e7f496 · moqui/moqui-framework · GitHub

Hope that helps!

Hey, Thanks for sharing these details. This is helpful. One issue I am facing is that the ‘’ is applied on the field fromDate,thruDate if no date filter field is provided.

In my case, I am using an elastic search on the MantleTask index. You can find references at the below link. The issue is that this index has no date field on which I can apply this filter.

In my get service, I am applying date filter on WorkEffortAndParty view which has fromDate,thruDate which is working fine but how can I replicate the same filter in Open Search? on MantleTask index?

Any help would be greatly appreciated. Thank you!

We are mixing some topics so I will attempt to clarify.

  • There are two different approaches to find data, 1) entity find and 2) opensearch
  • Using entity find we can use date-filter to automatically filter out records that are no longer active and only return the active record. Examples where this is used are PartyRelationship and WorkEffortParty.
  • When using open search the behavior seems to be different. Specifically, if a record is no longer active (has a thru date in the past), then it is removed from the document when the record is reindexed.
  • This approach is fine and will work for our use case, but it seems as though reindexing is not automatically triggered.

We are specifically working with tasks and using the MantleTask index. When we remove someone from a task (thruDate on WorkEffortParty record) the “parties” section in the json still contains the party that was removed.

So the most basic question is this: How is reindexing triggered when a database record changes?

1 Like

How are you removing the Work Effort? Is it a direct database query or are you using a CUDs service call?

By “remove” I simply mean that we are taking someone off of a task by putting an end date on the WorkEffortParty record.

We figured out what we needed to do to emulate the functionality of entity-find and date-filter using an opensearch query. We added from and thru date fields to the parties section of MantleTask data document definition so they are available to include in the query.