diff --git a/README.md b/README.md
index 56f28a7..85669c3 100644
--- a/README.md
+++ b/README.md
@@ -18,14 +18,14 @@ Add the following to your pom.xml
io.github.concurrent-recursion
enterprisesearch-java-client
- 0.5.4
+ 0.5.5
```
### Gradle
Add the following dependency
```groovy
dependencies {
- implementation 'io.github.concurrent-recursion:enterprisesearch-java-client:0.5.4'
+ implementation 'io.github.concurrent-recursion:enterprisesearch-java-client:0.5.5'
}
```
diff --git a/pom.xml b/pom.xml
index 0568ac1..114a23d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
io.github.concurrent-recursion
enterprisesearch-java-client
- 0.5.4
+ 0.5.5
jar
Enterprise Search Java Client
@@ -39,16 +39,16 @@
11
UTF-8
1.18.20.0
- 3.1.2
+ 3.2.5
3.5.0
3.2.1
1.6.13
3.1.0
- 2.15.2
- 2.0.9
- 1.4.11
- 1.18.30
+ 2.17.1
+ 2.0.13
+ 1.5.6
+ 1.18.32
5.10.0
3.0.2
4.11.0
@@ -109,6 +109,12 @@
commons-collections4
${apache-commons-collections4.version}
+
+ org.springframework.data
+ spring-data-mongodb
+ 4.3.0
+ test
+
com.squareup.okhttp3
mockwebserver
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/SortOrder.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/SortOrder.java
index 90fb6f2..6acec62 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/SortOrder.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/SortOrder.java
@@ -9,4 +9,6 @@ public interface SortOrder {
* @return The sort order
*/
Sort.Order getOrder();
+
+
}
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/Group.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/Group.java
index 33ea856..9adeb99 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/Group.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/Group.java
@@ -23,6 +23,10 @@
@AllArgsConstructor
@NoArgsConstructor
public class Group {
+ /**
+ * Create a group on the given field
+ * @param field the name of the field
+ */
public Group(String field){
this.field = field;
}
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/facet/ValueFacet.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/facet/ValueFacet.java
index 274550a..a183f72 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/facet/ValueFacet.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/facet/ValueFacet.java
@@ -25,14 +25,26 @@
@JsonDeserialize
public class ValueFacet implements Facet {
+ /**
+ * Create a ValueFacet
+ */
public ValueFacet() {
}
+ /**
+ * Create a ValueFacet with the given field name
+ * @param fieldName the name of the facet field
+ */
public ValueFacet(String fieldName) {
this.fieldName = fieldName;
}
+ /**
+ * The field name
+ * @param fieldName the name of the field this value facet is on
+ * @return the field name
+ */
private String fieldName;
@Override
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/DateRangeFilter.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/DateRangeFilter.java
index eccc40a..61bcf3d 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/DateRangeFilter.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/DateRangeFilter.java
@@ -25,6 +25,7 @@
public class DateRangeFilter implements Filter, FieldFilter {
/**
* The field from your schema upon which to apply your filter
+ * @param name The name of the field to filter
* @return The field name
*/
private String name;
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/FieldFilter.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/FieldFilter.java
index b66e542..ce56e30 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/FieldFilter.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/FieldFilter.java
@@ -1,6 +1,13 @@
package co.elasticsearch.enterprisesearch.client.model.request.search.filter;
+/**
+ * Interface for identifying filters on a field
+ */
public interface FieldFilter {
+ /**
+ * The name of the filter
+ * @return The name of the filter
+ */
String getName();
}
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/Filters.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/Filters.java
index 6cd5e7b..8736e47 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/Filters.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/request/search/filter/Filters.java
@@ -4,14 +4,31 @@
import java.util.Optional;
+/**
+ * Utility class that wraps an instance of a filter and provides methods for working with filters.
+ */
@RequiredArgsConstructor
public class Filters {
+ /**
+ * The filter that will be operated on
+ * @param filter the filter
+ * @return the filter
+ */
private final Filter filter;
+
+ /**
+ * Determine whether the filter is a bool filter
+ * @return true if the filter is a BooleanFilter, otherwise false
+ */
public boolean isBoolean(){
return filter instanceof BooleanFilter;
}
+ /**
+ * Determine whether the filter contains a nested any filter
+ * @return true if the filter is a BooleanFilter and it contains an any filter
+ */
public boolean hasAnyFilter(){
if(filter instanceof BooleanFilter){
BooleanFilter bool = (BooleanFilter) filter;
@@ -20,6 +37,10 @@ public boolean hasAnyFilter(){
return false;
}
+ /**
+ * Determine whether the filter contains a nested all filter
+ * @return true if the filter is a BooleanFilter and it contains an all filter
+ */
public boolean hasAllFilter(){
if(filter instanceof BooleanFilter){
BooleanFilter bool = (BooleanFilter) filter;
@@ -28,6 +49,10 @@ public boolean hasAllFilter(){
return false;
}
+ /**
+ * Determine whether the filter contains a nested none filter
+ * @return true if the filter is a BooleanFilter and it contains a none filter
+ */
public boolean hasNoneFilter(){
if(filter instanceof BooleanFilter){
BooleanFilter bool = (BooleanFilter) filter;
@@ -36,14 +61,31 @@ public boolean hasNoneFilter(){
return false;
}
+ /**
+ * Determine whether the filter applies to a field. Boolean filters do not directly apply to fields and would return
+ * false
+ * @return true if the filter applies to a field, otherwise false.
+ */
public boolean isField(){
return filter instanceof FieldFilter;
}
+ /**
+ * Ensure that the filter is a field filter, and cast it to the appropriate class type
+ * @param clazz The concrete FieldFilter class that the filter represents
+ * @return an Optional that will contain the given FieldFilter class type, or an empty Optional if the filter is null or
+ * is not the given class type
+ * @param The given concrete FieldFilter class
+ */
public Optional getFieldFilter(Class clazz){
return filter == null ? Optional.empty() : Optional.of(filter).filter(clazz::isInstance).map(clazz::cast);
}
+ /**
+ * Ensure that the filter is a bool filter, and cast it to a BooleanFilter
+ * @return an Optional that will contain the given BooleanFilter, or an empty Optional if the filter is null or
+ * is not a BooleanFilter
+ */
public Optional getBooleanFilter(){
return filter == null ? Optional.empty() : Optional.of(filter).filter(BooleanFilter.class::isInstance).map(BooleanFilter.class::cast);
}
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/ErrorResponse.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/ErrorResponse.java
index b52668c..b34edf3 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/ErrorResponse.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/ErrorResponse.java
@@ -31,5 +31,19 @@ public class ErrorResponse implements Serializable {
*/
private String error;
+ /**
+ * Whether the request is ok
+ * @param ok The status of the request
+ * @return The status
+ */
+ private Boolean ok;
+
+ /**
+ * The error message
+ * @param message The error message
+ * @return the message
+ */
+ private String message;
+
}
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/Group.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/Group.java
index d4f4530..e718d5f 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/Group.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/Group.java
@@ -8,6 +8,10 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * Represents a group in search results
+ * @param the result type contained in the group
+ */
@Getter
@Accessors(chain = true)
public class Group {
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/MultiSearchApiResponse.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/MultiSearchApiResponse.java
index 4d4acf0..e60a5b5 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/MultiSearchApiResponse.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/MultiSearchApiResponse.java
@@ -21,6 +21,10 @@
@Accessors(chain = true)
public class MultiSearchApiResponse implements Iterable>, ErrorableResponse {
+ /**
+ * Create MultiSearchApiResponse object
+ * @param results The list of Search Results from the response
+ */
@JsonCreator
public MultiSearchApiResponse(List> results){
this.results = results;
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateRangeFacet.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateRangeFacet.java
index 6044e23..ee12e7e 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateRangeFacet.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateRangeFacet.java
@@ -25,6 +25,10 @@ public class DateRangeFacet implements Facet{
* @param name the name of the facet
*/
private String name;
+ /**
+ * The date ranges
+ * @param data the date ranges
+ */
private List data = new ArrayList<>();
@Override
@@ -32,10 +36,18 @@ public FacetType getType() {
return FacetType.RANGE;
}
+ /**
+ * Get the raw FacetValues associated with this DateRangeFacet
+ * @return A List of FacetValues representing the date ranges
+ */
public List getData(){
return data.stream().map(r -> (FacetRangeValue) r).collect(Collectors.toList());
}
+ /**
+ * Get the date range values from this facet
+ * @return The list of Date Ranges
+ */
public List getDateRanges(){
return data;
}
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateValueFacet.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateValueFacet.java
index 6bfa883..4f698da 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateValueFacet.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/DateValueFacet.java
@@ -20,8 +20,14 @@ public class DateValueFacet implements Facet{
/**
* The facet name
* @param name the name of the facet
+ * @return The name of the facet
*/
private String name;
+ /**
+ * The DateValueFacet values that represent this facet
+ * @param data a list of DateValueFacets
+ * @return a list of DateValueFacets
+ */
private List data = new ArrayList<>();
@Override
@@ -29,6 +35,11 @@ public FacetType getType() {
return FacetType.VALUE;
}
+ /**
+ * Set the DateValueFacets for this facet
+ * @param dateValues The date values that represent the values of this facet
+ * @return This facet
+ */
public DateValueFacet setData(List dateValues){
data.addAll(dateValues);
return this;
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/GeolocationRangeFacet.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/GeolocationRangeFacet.java
index d78a113..a636dd9 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/GeolocationRangeFacet.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/GeolocationRangeFacet.java
@@ -37,6 +37,7 @@ public FacetType getType() {
return FacetType.RANGE;
}
+
public GeolocationRangeFacet setData(List data){
//this.data.addAll(data);
return this;
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberRangeFacet.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberRangeFacet.java
index 409c8eb..82072c9 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberRangeFacet.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberRangeFacet.java
@@ -21,8 +21,14 @@ public class NumberRangeFacet implements Facet {
* The facet name
*
* @param name the name of the facet
+ * @return the name of the facet
*/
private String name;
+ /**
+ * The facet values
+ * @param data the facet values
+ * @return the facet values
+ */
private List data = new ArrayList<>();
@Override
@@ -30,6 +36,11 @@ public FacetType getType() {
return FacetType.RANGE;
}
+ /**
+ * Set the number range values on this facet
+ * @param data The list of number ranges
+ * @return this facet
+ */
public NumberRangeFacet setData(List data){
this.data.addAll(data);
return this;
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberValueFacet.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberValueFacet.java
index aae67e4..069e2b3 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberValueFacet.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/NumberValueFacet.java
@@ -19,10 +19,15 @@
public class NumberValueFacet implements Facet {
/**
* The facet name
- *
* @param name the name of the facet
+ * @return the name of the facet
*/
private String name;
+ /**
+ * The facet values
+ * @param data the number values
+ * @return the number values for this facet
+ */
private List data = new ArrayList<>();
@Override
@@ -30,6 +35,11 @@ public FacetType getType() {
return FacetType.VALUE;
}
+ /**
+ * The list of facet values for this facet
+ * @param data the facet values
+ * @return this facet
+ */
public NumberValueFacet setData(List data){
this.data.addAll(data);
return this;
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/TextValueFacet.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/TextValueFacet.java
index e4a04b6..0f8a8e4 100644
--- a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/TextValueFacet.java
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/TextValueFacet.java
@@ -22,15 +22,27 @@ public class TextValueFacet implements Facet {
* The facet name
*
* @param name the name of the facet
+ * @return the name of the facet
*/
private String name;
+ /**
+ * The facet values
+ * @param data the value of the facet
+ * @return the value of the facet
+ */
private List data = new ArrayList<>();
@Override
public FacetType getType() {
return FacetType.VALUE;
}
+
+ /**
+ * The facet values
+ * @param data The facet values
+ * @return this facet
+ */
public TextValueFacet setData(List data){
this.data.addAll(data);
return this;
diff --git a/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/value/GeolocationRange.java b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/value/GeolocationRange.java
new file mode 100644
index 0000000..e45ddbe
--- /dev/null
+++ b/src/main/java/co/elasticsearch/enterprisesearch/client/model/response/search/facet/value/GeolocationRange.java
@@ -0,0 +1,21 @@
+package co.elasticsearch.enterprisesearch.client.model.response.search.facet.value;
+
+import co.elasticsearch.enterprisesearch.client.model.Geolocation;
+
+public class GeolocationRange implements FacetRangeValue{
+
+ @Override
+ public Geolocation getFrom() {
+ return null;
+ }
+
+ @Override
+ public Geolocation getTo() {
+ return null;
+ }
+
+ @Override
+ public Long getCount() {
+ return null;
+ }
+}
diff --git a/src/test/java/co/elasticsearch/enterprisesearch/client/ClientUtilsTest.java b/src/test/java/co/elasticsearch/enterprisesearch/client/ClientUtilsTest.java
index 65194b8..e90c5e9 100644
--- a/src/test/java/co/elasticsearch/enterprisesearch/client/ClientUtilsTest.java
+++ b/src/test/java/co/elasticsearch/enterprisesearch/client/ClientUtilsTest.java
@@ -16,6 +16,8 @@
import java.io.IOException;
import java.time.Duration;
+import static org.junit.Assert.assertEquals;
+
class ClientUtilsTest {
private AppSearchClient asp;
@@ -65,6 +67,17 @@ void testBadRequest(){
Assertions.assertTrue(results.isError());
}
+ @Test
+ void testProxyError(){
+ String mockResponse = "{\"ok\":false,\"message\":\"backend closed connection\"}";
+ mockWebServer.enqueue(new MockResponse().setResponseCode(502).setBody(mockResponse));
+ SearchApi search = asp.search(TestSearchDocument.class);
+ SearchRequest r = new SearchRequest();
+ AppSearchErrorResponseException error = Assertions.assertThrows(AppSearchErrorResponseException.class,() -> search.search(ENGINE_NAME,r));
+ Assertions.assertEquals(Boolean.FALSE, error.getErrorResponse().getOk());
+ Assertions.assertEquals("backend closed connection", error.getErrorResponse().getMessage());
+ }
+
@Test
void testClientAuthFailure(){
String mockResponse = "{\"error\": \"Invalid credentials\"}";