public class Elasticsearch2SchemaValidator extends Object implements ElasticsearchSchemaValidator
ElasticsearchSchemaValidator implementation for Elasticsearch 2.
Important implementation note: unexpected attributes (i.e. those not mapped to a field in TypeMapping) are totally ignored. This allows users to leverage Elasticsearch features that are not supported in Hibernate Search, by setting those attributes manually.
| Constructor and Description |
|---|
Elasticsearch2SchemaValidator(ElasticsearchSchemaAccessor schemaAccessor) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doValidateJsonPrimitive(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
DataType type,
String attributeName,
com.google.gson.JsonPrimitive expectedValue,
com.google.gson.JsonPrimitive actualValue) |
boolean |
isSettingsValid(IndexMetadata expectedIndexMetadata,
ExecutionOptions executionOptions)
Retrieves and validate actual index settings, returning a boolean indicating
whether the actual settings are valid or not.
|
void |
validate(IndexMetadata expectedIndexMetadata,
ExecutionOptions executionOptions)
Retrieves and validate actual index metadata, throwing an exception if validation fails.
|
protected <T> void |
validateAll(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
org.hibernate.search.elasticsearch.schema.impl.ValidationContextType type,
String messageIfMissing,
org.hibernate.search.elasticsearch.schema.impl.Elasticsearch2SchemaValidator.Validator<T> validator,
Map<String,T> expectedMap,
Map<String,T> actualMap)
Validate all elements in a map.
|
protected <T> void |
validateEqualWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
String attributeName,
Double expectedValue,
Double actualValue,
double delta,
Double defaultValueForNulls)
Variation of
validateEqualWithDefault(ValidationErrorCollector, String, Object, Object, Object) for doubles. |
protected <T> void |
validateEqualWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
String attributeName,
Float expectedValue,
Float actualValue,
float delta,
Float defaultValueForNulls)
Variation of
validateEqualWithDefault(ValidationErrorCollector, String, Object, Object, Object) for floats. |
protected <T> void |
validateEqualWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
String attributeName,
T expectedValue,
T actualValue,
T defaultValueForNulls)
Validate that two values are equal, using a given default value when null is encountered on either value.
|
protected <T> void |
validateFormatWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
String attributeName,
List<String> expectedValue,
List<String> actualValue,
List<String> defaultValueForNulls)
Special validation for an Elasticsearch format:
Checks that the first element (the format used for output format in ES) is equal
Checks all expected formats are present in the actual value
|
protected void |
validateIndexOptions(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
PropertyMapping expectedMapping,
PropertyMapping actualMapping) |
protected void |
validateJsonPrimitive(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector,
DataType type,
String attributeName,
com.google.gson.JsonPrimitive expectedValue,
com.google.gson.JsonPrimitive actualValue) |
public Elasticsearch2SchemaValidator(ElasticsearchSchemaAccessor schemaAccessor)
public void validate(IndexMetadata expectedIndexMetadata, ExecutionOptions executionOptions)
ElasticsearchSchemaValidatorThe metadata mainly contain the type mappings and the index settings.
validate in interface ElasticsearchSchemaValidatorexpectedIndexMetadata - The expected metadata, generated by Hibernate Search.executionOptions - The execution options, giving more context information.public boolean isSettingsValid(IndexMetadata expectedIndexMetadata, ExecutionOptions executionOptions)
ElasticsearchSchemaValidatorisSettingsValid in interface ElasticsearchSchemaValidatorexpectedIndexMetadata - The expected metadata, generated by Hibernate Search.executionOptions - The execution options, giving more context information.protected <T> void validateEqualWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, String attributeName, T expectedValue, T actualValue, T defaultValueForNulls)
Useful to take into account the fact that Elasticsearch has default values for attributes.
protected <T> void validateEqualWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, String attributeName, Float expectedValue, Float actualValue, float delta, Float defaultValueForNulls)
validateEqualWithDefault(ValidationErrorCollector, String, Object, Object, Object) for floats.protected <T> void validateEqualWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, String attributeName, Double expectedValue, Double actualValue, double delta, Double defaultValueForNulls)
validateEqualWithDefault(ValidationErrorCollector, String, Object, Object, Object) for doubles.protected <T> void validateFormatWithDefault(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, String attributeName, List<String> expectedValue, List<String> actualValue, List<String> defaultValueForNulls)
protected final void validateJsonPrimitive(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, DataType type, String attributeName, com.google.gson.JsonPrimitive expectedValue, com.google.gson.JsonPrimitive actualValue)
protected void doValidateJsonPrimitive(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, DataType type, String attributeName, com.google.gson.JsonPrimitive expectedValue, com.google.gson.JsonPrimitive actualValue)
protected <T> void validateAll(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, org.hibernate.search.elasticsearch.schema.impl.ValidationContextType type, String messageIfMissing, org.hibernate.search.elasticsearch.schema.impl.Elasticsearch2SchemaValidator.Validator<T> validator, Map<String,T> expectedMap, Map<String,T> actualMap)
Unexpected elements are ignored, we only validate expected elements.
protected void validateIndexOptions(org.hibernate.search.elasticsearch.schema.impl.ValidationErrorCollector errorCollector, PropertyMapping expectedMapping, PropertyMapping actualMapping)
Copyright © 2006–2017 Hibernate. All rights reserved.