mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#589 - ElasticSearch - extend mapping options
This commit is contained in:
1 parent
ae31117b8f
commit
da8766533f
5 files changed
+239
-67
No files matched your search
+125
-11
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebeanservice.docstore.api.mapping;
|
||||
|
||||
import com.avaje.ebean.annotation.DocMapping;
|
||||
import com.avaje.ebean.annotation.DocProperty;
|
||||
|
||||
/**
|
||||
* Options for mapping a property for document storage.
|
||||
@@ -17,6 +18,22 @@ public class DocPropertyOptions {
|
||||
|
||||
private String nullValue;
|
||||
|
||||
private Boolean includeInAll;
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
private Boolean norms;
|
||||
|
||||
private Boolean docValues;
|
||||
|
||||
private String analyzer;
|
||||
|
||||
private String searchAnalyzer;
|
||||
|
||||
private String copyTo;
|
||||
|
||||
private DocProperty.Option options;
|
||||
|
||||
/**
|
||||
* Construct with no values set.
|
||||
*/
|
||||
@@ -33,17 +50,14 @@ public class DocPropertyOptions {
|
||||
this.store = source.store;
|
||||
this.boost = source.boost;
|
||||
this.nullValue = source.nullValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct with options set.
|
||||
*/
|
||||
public DocPropertyOptions(Boolean code, Boolean sortable, Boolean store, Float boost, String nullValue) {
|
||||
this.code = code;
|
||||
this.sortable = sortable;
|
||||
this.store = store;
|
||||
this.boost = boost;
|
||||
this.nullValue = nullValue;
|
||||
this.includeInAll = source.includeInAll;
|
||||
this.analyzer = source.analyzer;
|
||||
this.searchAnalyzer = source.searchAnalyzer;
|
||||
this.options = source.options;
|
||||
this.docValues = source.docValues;
|
||||
this.norms = source.norms;
|
||||
this.copyTo = source.copyTo;
|
||||
this.enabled = source.enabled;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@@ -106,6 +120,77 @@ public class DocPropertyOptions {
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
public Boolean getIncludeInAll() {
|
||||
return includeInAll;
|
||||
}
|
||||
|
||||
public void setIncludeInAll(Boolean includeInAll) {
|
||||
this.includeInAll = includeInAll;
|
||||
}
|
||||
|
||||
public Boolean getDocValues() {
|
||||
return docValues;
|
||||
}
|
||||
|
||||
public void setDocValues(Boolean docValues) {
|
||||
this.docValues = docValues;
|
||||
}
|
||||
|
||||
public String getAnalyzer() {
|
||||
return analyzer;
|
||||
}
|
||||
|
||||
public void setAnalyzer(String analyzer) {
|
||||
this.analyzer = analyzer;
|
||||
}
|
||||
|
||||
public String getSearchAnalyzer() {
|
||||
return searchAnalyzer;
|
||||
}
|
||||
|
||||
public void setSearchAnalyzer(String searchAnalyzer) {
|
||||
this.searchAnalyzer = searchAnalyzer;
|
||||
}
|
||||
|
||||
public String getCopyTo() {
|
||||
return copyTo;
|
||||
}
|
||||
|
||||
public void setCopyTo(String copyTo) {
|
||||
this.copyTo = copyTo;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getNorms() {
|
||||
return norms;
|
||||
}
|
||||
|
||||
public void setNorms(Boolean norms) {
|
||||
this.norms = norms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the index options is set to a non-default value.
|
||||
*/
|
||||
public boolean isOptionsSet() {
|
||||
return options != null && options != DocProperty.Option.DEFAULT;
|
||||
}
|
||||
|
||||
public DocProperty.Option getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(DocProperty.Option options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this such that it can be overridden on a per index basis.
|
||||
*/
|
||||
@@ -117,7 +202,15 @@ public class DocPropertyOptions {
|
||||
* Apply override mapping from the document level or embedded property level.
|
||||
*/
|
||||
public void apply(DocMapping docMapping) {
|
||||
apply(docMapping.options());
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the property level mapping options.
|
||||
*/
|
||||
public void apply(DocProperty docMapping) {
|
||||
|
||||
options = docMapping.options();
|
||||
if (docMapping.code()) {
|
||||
code = true;
|
||||
}
|
||||
@@ -133,6 +226,27 @@ public class DocPropertyOptions {
|
||||
if (!"".equals(docMapping.nullValue())) {
|
||||
nullValue = docMapping.nullValue();
|
||||
}
|
||||
if (!docMapping.includeInAll()) {
|
||||
includeInAll = false;
|
||||
}
|
||||
if (!docMapping.docValues()) {
|
||||
docValues = false;
|
||||
}
|
||||
if (!docMapping.enabled()) {
|
||||
enabled = false;
|
||||
}
|
||||
if (!docMapping.norms()) {
|
||||
norms = false;
|
||||
}
|
||||
if (!"".equals(docMapping.analyzer())) {
|
||||
analyzer = docMapping.analyzer();
|
||||
}
|
||||
if (!"".equals(docMapping.searchAnalyzer())) {
|
||||
searchAnalyzer = docMapping.searchAnalyzer();
|
||||
}
|
||||
if (!"".equals(docMapping.copyTo())) {
|
||||
copyTo = docMapping.copyTo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user