@@ -148,7 +148,7 @@ You can control the behaviour by using the `pickFirstByEntityProperty` or `trave
148
148
` referenceProperty ` container. You can also use the ` traverseByEntityProperty ` for non-hierarchical entities and for 1:1
149
149
references. It changes the order so that the entities are first sorted by the property of the thing they're referring to,
150
150
and then by the reference property itself. For more information, check out the examples and the detailed documentation
151
- of the [ ` traverseByEntityProperty ` ] constraint.
151
+ of the [ ` traverseByEntityProperty ` ] ( #traverse-by-entity-property ) constraint.
152
152
153
153
</Note >
154
154
@@ -168,13 +168,12 @@ pickFirstByEntityProperty(
168
168
</dd>
169
169
</dl >
170
170
171
- The ` pickFirstByEntityProperty ` ordering constraint can only be used within the [ ` referenceProperty ` ] ( #reference-property )
172
- ordering constraint, and makes sense only in case the cardinality of such reference is 1: N (although it's not actively
173
- checked by the query engine). This constraint allows you specify the order of the references to pick the first one from
174
- the list of references to the same entity to be used for ordering by ` referenceProperty ` .
171
+ The ` pickFirstByEntityProperty ` ordering constraint can only be used within the [ ` referenceProperty ` ] ( #reference-property ) ordering constraint.
172
+ It makes sense only in case the cardinality of the reference is 1: N (although this isn't actively checked by the query
173
+ engine). This constraint lets you specify the order of the references to pick the first one from the list of references
174
+ to the same entity to be used for ordering by ` referenceProperty ` .
175
175
176
- Let's extend our previous example so that it returns products that refer not only to the group "sale", but also to the
177
- group "new":
176
+ Let's expand our previous example to include products that refer to both the "sale" and "new" groups:
178
177
179
178
<SourceCodeTabs requires =" evita_functional_tests/src/test/resources/META-INF/documentation/evitaql-init.java " langSpecificTabOnly >
180
179
@@ -208,13 +207,13 @@ group "new":
208
207
209
208
</Note >
210
209
211
- The result will contain first products referring to a "new" group which has the lowest primary key, and then products
212
- referring to a "sale" group. The order of products within each group will be determined by the ` orderInGroup ` attribute.
213
- This is default behavior for references targeting non-hierarchical entities.
210
+ The result will contain the first products from the "new" group, which has the lowest primary key. Then it will contain
211
+ the products from the "sale" group. The order of products within each group will be determined by the ` orderInGroup `
212
+ attribute. This is the usual way things are done for references that target non-hierarchical entities.
214
213
215
214
If we want to change the order of the groups, we can use the ` pickFirstByEntityProperty ` ordering constraint to explicitly
216
- specify the order of the groups. For example, if we want to list products in the "sale" group first, we can use the
217
- following query:
215
+ specify the order of the groups. For example, if we want to list products in the "sale" group first, we can use
216
+ the following query:
218
217
219
218
<SourceCodeTabs requires =" evita_functional_tests/src/test/resources/META-INF/documentation/evitaql-init.java " langSpecificTabOnly >
220
219
@@ -246,8 +245,8 @@ following query:
246
245
247
246
</LS >
248
247
249
- As you can see when the product is related to both groups, the assignment to the "sale" group takes precedence and is
250
- used for ordering. You can use all sorts of ordering constraints and tune the ordering to your needs.
248
+ If a product is in both groups, the "sale" group takes priority and is used for ordering. You can use all sorts of
249
+ ordering constraints and adjust the ordering to suit your needs.
251
250
252
251
</Note >
253
252
@@ -272,15 +271,16 @@ traverseByEntityProperty(
272
271
</dd>
273
272
</dl >
274
273
275
- The ` traverseByEntityProperty ` ordering constraint can only be used within the [ ` referenceProperty ` ] ( #reference-property )
276
- ordering constraint. This constraint defines that the entities should be sorted first by the referenced entity property,
277
- and if such entity is hierarchical, it allows to specify whether the hierarchy should be traversed in depth-first or
278
- breadth-first order. When the order of the referenced entities is resolved, the ` referenceProperty ` ordering itself
279
- is applied on the references to the referenced entities. If there are multiple references only the first one that can
280
- be evaluated is used for ordering.
274
+ The ` traverseByEntityProperty ` ordering constraint can only be used with the [ ` referenceProperty ` ] ( #reference-property )
275
+ ordering constraint. This means that entities should be sorted first by the referenced entity property. If the entity is
276
+ hierarchical, you can specify whether the hierarchy should be traversed in
277
+ [ depth-first] ( https://en.wikipedia.org/wiki/Depth-first_search ) or [ breadth-first] ( https://en.wikipedia.org/wiki/Breadth-first_search ) order.
278
+
279
+ Once the referenced entities are sorted, the order of the referenced entities is applied to the references to
280
+ the referenced entities. If there are multiple references, only the first one that can be evaluated is used for ordering.
281
281
282
- This behaviour is best illustrated by a following example. Let's list products in the * Accessories* category ordered
283
- by the ` orderInCategory ` attribute on the reference to the category:
282
+ This behaviour is best illustrated by the following example. Let's list products in the ' Accessories' category in order
283
+ of the ` orderInCategory ` attribute on the category reference :
284
284
285
285
<SourceCodeTabs requires =" evita_functional_tests/src/test/resources/META-INF/documentation/evitaql-init.java " langSpecificTabOnly >
286
286
@@ -314,23 +314,23 @@ by the `orderInCategory` attribute on the reference to the category:
314
314
315
315
</LS >
316
316
317
- The result will first contain products directly related to the * Accessories* category, ordered by ` orderInCategory ` in
318
- ascending order, then products * Christmas electronics* (which is the first child of the * Accessories* category with
319
- the least primary key), then * Smart wearable* (which has no directly related products), then * Bands * (which is the first
320
- child of the * Smart wearable * category), and so on. The order follows the order of the categories in the following
321
- image:
317
+ The result will first contain products in the * Accessories* category, ordered by ` orderInCategory ` from most to least,
318
+ then products in the * Christmas electronics* category (which is the first child of the * Accessories* category with
319
+ the least primary key), then products in the * Smart wearable* category (which has no directly related products),
320
+ then products in the * Bands * category (which is the first child of the * Smart wearable * category), and so on.
321
+ The order follows the order of the categories in the following image:
322
322
323
323
![ dynamic-tree.png] ( ../requirements/assets/dynamic-tree.png )
324
324
325
- If the product was related to both ** Christmas electronics** and ** Smart wearable** categories, the product would be
326
- listed only once as if it would be related only to the ** Christmas electronics** category, because in this query
327
- primary key of the category is used for the hierarchy traversal.
325
+ If a product falls into both the ** Christmas** electronics and ** Smart wearable** categories, it will only be listed
326
+ once. This is because, in this query, the category's primary key is used to traverse the hierarchy.
328
327
329
328
</Note >
330
329
331
- Consider the another example where we want to list products in the * Accessories* category ordered by the ` orderInCategory `
332
- attribute on the reference to the category, but we want to traverse the hierarchy in breadth-first order and the categories
333
- themselves should be sorted by their ` order ` attribute first:
330
+ Here's another example: we want to list products in the * Accessories* category in a certain order. This order is based
331
+ on the ` orderInCategory ` attribute on the reference to the category. But we want to go through the hierarchy using
332
+ [ breadth first manner] ( https://en.wikipedia.org/wiki/Breadth-first_search ) , where each hierarchy level should be sorted
333
+ by category ` order ` attribute first:
334
334
335
335
<SourceCodeTabs requires =" evita_functional_tests/src/test/resources/META-INF/documentation/evitaql-init.java " langSpecificTabOnly >
336
336
@@ -363,8 +363,7 @@ themselves should be sorted by their `order` attribute first:
363
363
364
364
</LS >
365
365
366
- As you can see you have full control over the the ordering of the entities and the order of the references within the
367
- hierarchy.
366
+ As you can see, you can arrange the order of the entities and the references within the hierarchy however you want.
368
367
369
368
</Note >
370
369
0 commit comments