File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed
core/src/main/java/com/arangodb
test-functional/src/test/java/com/arangodb Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 2020
2121package com .arangodb .entity .arangosearch ;
2222
23+ import com .fasterxml .jackson .annotation .JsonIgnore ;
24+ import com .fasterxml .jackson .annotation .JsonProperty ;
25+
2326/**
2427 * @author Heiko Kernbach
2528 */
@@ -28,6 +31,14 @@ public final class PrimarySort {
2831 private final String fieldName ;
2932 private Boolean ascending ;
3033
34+ public PrimarySort (
35+ @ JsonProperty ("field" ) String field ,
36+ @ JsonProperty ("asc" ) Boolean asc
37+ ) {
38+ this .fieldName = field ;
39+ this .ascending = asc ;
40+ }
41+
3142 private PrimarySort (final String fieldName ) {
3243 super ();
3344 this .fieldName = fieldName ;
@@ -46,11 +57,33 @@ public PrimarySort ascending(final Boolean ascending) {
4657 return this ;
4758 }
4859
60+ @ JsonIgnore
4961 public Boolean getAscending () {
5062 return ascending ;
5163 }
5264
65+ public Direction getDirection () {
66+ if (ascending == null ) {
67+ return null ;
68+ }
69+ return ascending ? Direction .asc : Direction .desc ;
70+ }
71+
72+ /**
73+ * @deprecated for removal, use {@link #getField()} instead
74+ */
75+ @ Deprecated
76+ @ JsonIgnore
5377 public String getFieldName () {
78+ return getField ();
79+ }
80+
81+ public String getField () {
5482 return fieldName ;
5583 }
84+
85+ public enum Direction {
86+ asc ,
87+ desc
88+ }
5689}
Original file line number Diff line number Diff line change 2323import com .arangodb .entity .ViewType ;
2424import com .arangodb .entity .arangosearch .*;
2525import com .arangodb .internal .serde .InternalSerializers ;
26+ import com .fasterxml .jackson .annotation .JsonIgnore ;
2627import com .fasterxml .jackson .databind .annotation .JsonSerialize ;
2728
2829import java .util .Arrays ;
@@ -217,7 +218,16 @@ public Collection<CollectionLink> getLinks() {
217218 return links ;
218219 }
219220
221+ /**
222+ * @deprecated for removal, use {@link #getPrimarySort()} instead
223+ */
224+ @ Deprecated
225+ @ JsonIgnore
220226 public Collection <PrimarySort > getPrimarySorts () {
227+ return getPrimarySort ();
228+ }
229+
230+ public Collection <PrimarySort > getPrimarySort () {
221231 return primarySorts ;
222232 }
223233
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ void createArangoSearchViewWithPrimarySort(ArangoDatabase db) {
154154 final ArangoSearchCreateOptions options = new ArangoSearchCreateOptions ();
155155
156156 final PrimarySort primarySort = PrimarySort .on ("myFieldName" );
157- primarySort .ascending (true );
157+ primarySort .ascending (false );
158158 options .primarySort (primarySort );
159159 options .primarySortCompression (ArangoSearchCompression .none );
160160 options .consolidationIntervalMsec (666666L );
@@ -179,6 +179,13 @@ void createArangoSearchViewWithPrimarySort(ArangoDatabase db) {
179179 assertThat (retrievedStoredValue ).isNotNull ();
180180 assertThat (retrievedStoredValue .getFields ()).isEqualTo (storedValue .getFields ());
181181 assertThat (retrievedStoredValue .getCompression ()).isEqualTo (storedValue .getCompression ());
182+ assertThat (properties .getPrimarySort ())
183+ .hasSize (1 )
184+ .allSatisfy (ps -> {
185+ assertThat (ps ).isNotNull ();
186+ assertThat (ps .getField ()).isEqualTo (primarySort .getField ());
187+ assertThat (ps .getAscending ()).isEqualTo (primarySort .getAscending ());
188+ });
182189 }
183190 }
184191
@@ -739,7 +746,7 @@ void arangoSearchOptions(ArangoDatabase db) {
739746 }
740747
741748 if (isEnterprise () && isAtLeastVersion (3 , 12 )) {
742- assertThat (properties .getOptimizeTopK ()).containsExactly (optimizeTopK );
749+ assertThat (properties .getOptimizeTopK ()).containsExactly (optimizeTopK );
743750 }
744751
745752 }
You can’t perform that action at this time.
0 commit comments