0

I'm currently testing the viability of using Gentics Mesh CMS just in a minor role for to populate a news feed. The general idea being that I have a news folder item, with various news items under it currently.

What is determining the order of children? When I grab the data of said news node, the order of the children just seems haphazard at best. I have 3 items in there for testing.

Yesterday I was getting them back in the order 3-1-2. Now they are 1-3-2.

Neither of these is a useful order, as I would like 3-2-1. So how can I force an order? Either in how it's storing things, or in retrieval?

2 Answers2

1

You can force an order if you are using Elasticsearch (enabled by default).

POST this example to https://demo.getmesh.io/api/v1/search/nodes

{
    "query": {
        "term": {
            "parentNode.uuid": "21203632520b4d19a03632520b2d19c1"
        }
    },
    "sort": {
        "created": "asc"    
    }
}

This will get the first 25 nodes which are in the folder with UUID 21203632520b4d19a03632520b2d19c1, sorted by their creation date.

PGuertler
  • 243
  • 1
  • 2
  • 6
0

The elements are currently returned in natural order in which they are returned by the graph database. It is possible that new elements are inserted in "free" slots and thus the order changes. I believe the behavior you observed is caused by not applying any sorting. I created an issue for this bug.

https://github.com/gentics/mesh/issues/327

Jotschi
  • 3,270
  • 3
  • 31
  • 52