moqui / moqui-framework

Use Moqui Framework to build enterprise applications based on Java. It includes tools for databases (relational, graph, document), local and web services, web and other UI with screens and forms, security, file/resource access, scripts, templates, l10n, caching, logging, search, rules, workflow, multi-instance, and integration.
http://www.moqui.org
Other
279 stars 199 forks source link

Catalog/Search: ordering is broken #615

Open diegonc opened 11 months ago

diegonc commented 11 months ago

The following URL gives a 400 error when trying to search the catalog:

https://demo.moqui.org/qapps/PopcAdmin/Catalog/Search?orderByField=-pseudoId&pageSize=20&queryString=*

Apparently, the service org.moqui.search.SearchServices.search#DataDocuments does not take into account fields that have a keyword subfield to allow ordering.

The only place where .keyword is appended is here, in moqui-framework, but it seems it's not used by the search service.

diegonc commented 11 months ago

BTW I first found this issue in a custom product based DataDocument where pseudoId is a Sortable field. I checked that the keyword subfield is actually generated and the ordering doesn't work.

After posting this issue, I realized that, in MantleProduct, pseudoId is not sortable.

And a workaround I found is to populate the mappings of the index with a field of keyword type ({"properties":{"pseudoId":{"type": "keyword}}}) before running the feed index process. But I'd prefer if the search service could handle the keword subfield of sortable columns of the data document-