<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Exception when querying business data with sorting</title><link>https://answers.axonivy.com/questions/2763/exception-when-querying-business-data-with-sorting</link><description>&lt;p&gt;Hi ivyTeam&lt;/p&gt;
&lt;p&gt;Querying data from business data &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;repo().search(getType()).orderBy().textField("processName").ascending().execute().getAll();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It throws the exception:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Caused by: ch.ivyteam.ivy.business.data.store.search.internal.elasticsearch.ElasticsearchException: Elasticsearch search documents failed because of: {"root_cause":[{"type":"search_parse_exception","reason":"No mapping found for [processName.ascii] in order to sort on"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"ivy.businessdata","node":"swxYYakvQMCJMMyVDyQhfA","reason":{"type":"search_parse_exception","reason":"No mapping found for [processName.ascii] in order to sort on"}}]}
    at ch.ivyteam.ivy.business.data.store.search.internal.elasticsearch.JestOperation.checkStatusAndThrow(JestOperation.java:62)
    at ch.ivyteam.ivy.business.data.store.search.internal.elasticsearch.JestOperation.execute(JestOperation.java:40)
    at ch.ivyteam.ivy.business.data.store.search.internal.elasticsearch.JestSearcher.search(JestSearcher.java:32)
    at ch.ivyteam.ivy.business.data.store.search.internal.ResultImpl.execute(ResultImpl.java:38)
    at ch.ivyteam.ivy.business.data.store.search.internal.QueryImpl.raw(QueryImpl.java:128)
    at ch.ivyteam.ivy.business.data.store.search.internal.QueryImpl.executeQuery(QueryImpl.java:174)
    at ch.ivyteam.ivy.business.data.store.search.internal.QueryImpl.execute(QueryImpl.java:107)
    at ch.ivyteam.ivy.business.data.store.search.internal.OrderByFieldOrLimitImpl.execute(OrderByFieldOrLimitImpl.java:29)
    at ch.ivy.addon.portalkit.service.ExpressProcessService.findAllOrderByName(ExpressProcessService.java:11)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at ch.ivyteam.ivy.scripting.internal.types.IvyJavaMethod.invokeImpl(IvyJavaMethod.java:73)
    ... 280 more
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It happens on Axon.ivy Engine RC-6.6.2.55064. In designer, sometimes it happens as well. Could you please guide us how to fix the problem?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2763/exception-when-querying-business-data-with-sorting" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 18 Jul 2017 03:04:41 -0400</lastBuildDate><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/2763/exception-when-querying-business-data-with-sorting/2768</link><description>&lt;p&gt;&lt;strong&gt;Axon.ivy  &amp;gt;= 6.7&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This issue has been fixed with the Axon.ivy version &amp;gt;= 6.7. See issue &lt;a href="https://jira.axonivy.com/jira/browse/XIVY-2042"&gt;XIVY-2042 Business Data Sorting fails on a field for which no data exists&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Before Axon.ivy 6.7&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As a workaround add a simple BusinessData existence check query before you do the real query. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;long totalCount = BusinessDataRepository.get().search(MyBusinessData.class).execute().totalCount();
if (totalCount &amp;gt; 0)
{
 //you query here...
}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 18 Jul 2017 03:04:41 -0400</pubDate><guid>https://answers.axonivy.com/questions/2763/exception-when-querying-business-data-with-sorting/2768</guid></item></channel></rss>