We have Agraph implementation with version 5.1.x. When a query is fired for aggregated results, and sort is applied the "Representative Properties" change when the sort order is changed. Is there any solution to overcome other than having "derived properties"??
Agraph is used when data is shared across the machines and redirect client request to distributed Dgraphs. Each child Dgraph will be having its own set of data/records and its order. Agraph does not necessarily preserves the order of data/records from each child Dgraphs while combining them.
You can try enabling "Show with record list" from Developer studio for the property on which you will be doing sorting as explained in Basic dev guide Chapter 6. Sorting Endeca Records, Agraph default sort order and displayed record lists section.
And applying sort will change the Representative record as it is returned dynamically, this is expected behavior.
It seems your "representative record" is changing after the sort is applied. When the MDEX engine (agraph or dgraph) rolls up based on your rollup property, it chooses one Endeca record in each group to be the "representative record" for display purposes. The "representative record" is always the first one encountered in a record grouping. In your case, it appears that the records in your aggregate record groupings carry different properties, which is problematic on sort. I would suggest attempting one of the following approaches:
1 - sort your index during indexing using the dgidx flag sort "key|dir" (http://docs.oracle.com/cd/E28910_01/MDEX.622/pdf/BasicDevGuide.pdf "Changing the sort order with Dgidx flags". This will ensure that the records are already sorted as they rest in the index so that the sort described in your post won't actually rearrange or change the "representative record"
2 - Make sure all of the records in your record groups carry the same properties. This would have to be accomplished in ETL. Depending on your data, this may not be possible.
3 - Set Np=2 in your UrlENEQuery to ask the MDEX to return all records in the aggregate result set. This way you can "programmatically select" the representative record you want to display. Note that this will increase your response payload size which could have a performance impact as you will be bringing more data back to your application server from your MDEX. Np can be set to either 0 (no records are returned with each aggregated record), 1 (only a single representative record is returned with each aggregate record), or 2 (all records are returned with each aggregated record).