Skip to content

Commit d1c7664

Browse files
committed
sort options unit test
1 parent 7ed73ff commit d1c7664

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

java-client/src/test/java/co/elastic/clients/elasticsearch/model/SerializationTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package co.elastic.clients.elasticsearch.model;
2121

22+
import co.elastic.clients.elasticsearch._types.GeoDistanceSort;
23+
import co.elastic.clients.elasticsearch._types.SortOptions;
2224
import co.elastic.clients.elasticsearch.cat.NodesResponse;
2325
import co.elastic.clients.elasticsearch.core.GetSourceResponse;
2426
import co.elastic.clients.json.JsonpDeserializable;
@@ -131,4 +133,38 @@ public void testJsonpValuesToString() {
131133
JsonpUtils.toString(Json.createObjectBuilder().build());
132134
});
133135
}
136+
137+
@Test
138+
public void testSortOptionsDeserializer() {
139+
140+
String customField = """
141+
{
142+
"term" : "asc"
143+
}
144+
""";
145+
146+
SortOptions so = SortOptions.of(b->b.withJson(new StringReader(customField)));
147+
148+
String score = """
149+
"_score"
150+
""";
151+
152+
so = SortOptions.of(b->b.withJson(new StringReader(score)));
153+
154+
String geoDistance = """
155+
{
156+
"_geo_distance" : {
157+
"pin.location" : "<-70>, <40>",
158+
"order" : "asc",
159+
"unit" : "km",
160+
"mode" : "min",
161+
"distance_type" : "arc",
162+
"ignore_unmapped": true
163+
}
164+
}
165+
""";
166+
167+
so = SortOptions.of(b->b.withJson(new StringReader(geoDistance)));
168+
169+
}
134170
}

0 commit comments

Comments
 (0)