-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dynamic facets): facet ordering support (#747)
- Loading branch information
Showing
7 changed files
with
258 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
algoliasearch-core/src/main/java/com/algolia/search/models/rules/FacetOrdering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.algolia.search.models.rules; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.io.Serializable; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** Facets and facets values ordering rules container. */ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class FacetOrdering implements Serializable { | ||
private FacetsOrder facets; | ||
private Map<String, FacetValuesOrder> values; | ||
|
||
public FacetOrdering() {} | ||
|
||
public FacetOrdering(FacetsOrder facets, Map<String, FacetValuesOrder> values) { | ||
this.facets = facets; | ||
this.values = values; | ||
} | ||
|
||
public FacetsOrder getFacets() { | ||
return facets; | ||
} | ||
|
||
public FacetOrdering setFacets(FacetsOrder facets) { | ||
this.facets = facets; | ||
return this; | ||
} | ||
|
||
public Map<String, FacetValuesOrder> getValues() { | ||
return values; | ||
} | ||
|
||
public FacetOrdering setValues(Map<String, FacetValuesOrder> values) { | ||
this.values = values; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof FacetOrdering)) return false; | ||
FacetOrdering that = (FacetOrdering) o; | ||
return Objects.equals(facets, that.facets) && Objects.equals(values, that.values); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(facets, values); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FacetOrdering{" + "facets=" + facets + ", values=" + values + '}'; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
algoliasearch-core/src/main/java/com/algolia/search/models/rules/FacetValuesOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.algolia.search.models.rules; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** Facet values ordering rule container. */ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class FacetValuesOrder implements Serializable { | ||
private List<String> order; | ||
private String sortRemainingBy; | ||
|
||
public FacetValuesOrder() {} | ||
|
||
public FacetValuesOrder(List<String> order, String sortRemainingBy) { | ||
this.order = order; | ||
this.sortRemainingBy = sortRemainingBy; | ||
} | ||
|
||
public List<String> getOrder() { | ||
return order; | ||
} | ||
|
||
public FacetValuesOrder setOrder(List<String> order) { | ||
this.order = order; | ||
return this; | ||
} | ||
|
||
public String getSortRemainingBy() { | ||
return sortRemainingBy; | ||
} | ||
|
||
public FacetValuesOrder setSortRemainingBy(String sortRemainingBy) { | ||
this.sortRemainingBy = sortRemainingBy; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof FacetValuesOrder)) return false; | ||
FacetValuesOrder that = (FacetValuesOrder) o; | ||
return Objects.equals(order, that.order) | ||
&& Objects.equals(sortRemainingBy, that.sortRemainingBy); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(order, sortRemainingBy); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FacetValuesOrder{" | ||
+ "order=" | ||
+ order | ||
+ ", sortRemainingBy='" | ||
+ sortRemainingBy | ||
+ '\'' | ||
+ '}'; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
algoliasearch-core/src/main/java/com/algolia/search/models/rules/FacetsOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.algolia.search.models.rules; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** Define or override the way facet attributes are displayed. */ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class FacetsOrder implements Serializable { | ||
private List<String> order; | ||
|
||
public FacetsOrder() {} | ||
|
||
public FacetsOrder(List<String> order) { | ||
this.order = order; | ||
} | ||
|
||
public List<String> getOrder() { | ||
return order; | ||
} | ||
|
||
public FacetsOrder setOrder(List<String> order) { | ||
this.order = order; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof FacetsOrder)) return false; | ||
FacetsOrder that = (FacetsOrder) o; | ||
return Objects.equals(order, that.order); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(order); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FacetsOrder{" + "order=" + order + '}'; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
algoliasearch-core/src/main/java/com/algolia/search/models/rules/RenderingContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.algolia.search.models.rules; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Content defining how the search interface should be rendered. This is set via the settings for a | ||
* default value and can be overridden via rules. | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class RenderingContent implements Serializable { | ||
private FacetOrdering facetOrdering; | ||
|
||
public RenderingContent() {} | ||
|
||
public RenderingContent(FacetOrdering facetOrdering) { | ||
this.facetOrdering = facetOrdering; | ||
} | ||
|
||
public FacetOrdering getFacetOrdering() { | ||
return facetOrdering; | ||
} | ||
|
||
public RenderingContent setFacetOrdering(FacetOrdering facetOrdering) { | ||
this.facetOrdering = facetOrdering; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof RenderingContent)) return false; | ||
RenderingContent that = (RenderingContent) o; | ||
return Objects.equals(facetOrdering, that.facetOrdering); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(facetOrdering); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "RenderingContent{" + "facetOrdering=" + facetOrdering + '}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters