Skip to content

Commit

Permalink
Added ok and message fields to ErrorResponse to handle proxy errors. …
Browse files Browse the repository at this point in the history
…Added Javadoc to various classes. Updated dependencies
  • Loading branch information
concurrent-recursion committed May 21, 2024
1 parent 8adcf99 commit 73d8251
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ Add the following to your pom.xml
<dependency>
<groupId>io.github.concurrent-recursion</groupId>
<artifactId>enterprisesearch-java-client</artifactId>
<version>0.5.4</version>
<version>0.5.5</version>
</dependency>
```
### 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'
}
```

Expand Down
18 changes: 12 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.concurrent-recursion</groupId>
<artifactId>enterprisesearch-java-client</artifactId>
<version>0.5.4</version>
<version>0.5.5</version>
<packaging>jar</packaging>

<name>Enterprise Search Java Client</name>
Expand Down Expand Up @@ -39,16 +39,16 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-lombok-plugin.version>1.18.20.0</maven-lombok-plugin.version>
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<maven-javadoc-plugin.version>3.5.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>

<jackson.version>2.15.2</jackson.version>
<slf4j.version>2.0.9</slf4j.version>
<logback.version>1.4.11</logback.version>
<lombok.version>1.18.30</lombok.version>
<jackson.version>2.17.1</jackson.version>
<slf4j.version>2.0.13</slf4j.version>
<logback.version>1.5.6</logback.version>
<lombok.version>1.18.32</lombok.version>
<junit.version>5.10.0</junit.version>
<jakarta-validation.version>3.0.2</jakarta-validation.version>
<okhttp.version>4.11.0</okhttp.version>
Expand Down Expand Up @@ -109,6 +109,12 @@
<artifactId>commons-collections4</artifactId>
<version>${apache-commons-collections4.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public interface SortOrder {
* @return The sort order
*/
Sort.Order getOrder();


}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 <T> The given concrete FieldFilter class
*/
public <T extends FieldFilter> Optional<T> getFieldFilter(Class<T> 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<BooleanFilter> getBooleanFilter(){
return filter == null ? Optional.empty() : Optional.of(filter).filter(BooleanFilter.class::isInstance).map(BooleanFilter.class::cast);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import java.util.ArrayList;
import java.util.List;

/**
* Represents a group in search results
* @param <T> the result type contained in the group
*/
@Getter
@Accessors(chain = true)
public class Group<T extends ResponseDocument> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
@Accessors(chain = true)
public class MultiSearchApiResponse<T extends ResponseDocument> implements Iterable<SearchApiResponse<T>>, ErrorableResponse {

/**
* Create MultiSearchApiResponse object
* @param results The list of Search Results from the response
*/
@JsonCreator
public MultiSearchApiResponse(List<SearchApiResponse<T>> results){
this.results = results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,29 @@ 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<DateRange> data = new ArrayList<>();

@Override
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<FacetValue> getData(){
return data.stream().map(r -> (FacetRangeValue<OffsetDateTime>) r).collect(Collectors.toList());
}

/**
* Get the date range values from this facet
* @return The list of Date Ranges
*/
public List<DateRange> getDateRanges(){
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,26 @@ 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<FacetValue> data = new ArrayList<>();

@Override
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<DateValue> dateValues){
data.addAll(dateValues);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public FacetType getType() {
return FacetType.RANGE;
}


public GeolocationRangeFacet setData(List<GeolocationRange> data){
//this.data.addAll(data);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,26 @@ 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<FacetValue> data = new ArrayList<>();

@Override
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<NumberRange> data){
this.data.addAll(data);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@
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<FacetValue> data = new ArrayList<>();

@Override
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<NumberValue> data){
this.data.addAll(data);
return this;
Expand Down
Loading

0 comments on commit 73d8251

Please sign in to comment.