-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-2434 Introduce an Elasticsearch 5 dialect and dialect autodet…
…ection
- Loading branch information
Showing
7 changed files
with
203 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
52 changes: 52 additions & 0 deletions
52
.../main/java/org/hibernate/search/elasticsearch/dialect/impl/es5/Elasticsearch5Dialect.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,52 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.dialect.impl.es5; | ||
|
||
import org.hibernate.search.elasticsearch.dialect.impl.DialectIndependentGsonProvider; | ||
import org.hibernate.search.elasticsearch.dialect.impl.ElasticsearchDialect; | ||
import org.hibernate.search.elasticsearch.gson.impl.GsonProvider; | ||
import org.hibernate.search.elasticsearch.nulls.impl.Elasticsearch5MissingValueStrategy; | ||
import org.hibernate.search.elasticsearch.schema.impl.Elasticsearch5SchemaTranslator; | ||
import org.hibernate.search.elasticsearch.schema.impl.Elasticsearch5SchemaValidator; | ||
import org.hibernate.search.elasticsearch.schema.impl.ElasticsearchSchemaAccessor; | ||
import org.hibernate.search.elasticsearch.schema.impl.ElasticsearchSchemaTranslator; | ||
import org.hibernate.search.elasticsearch.schema.impl.ElasticsearchSchemaValidator; | ||
import org.hibernate.search.elasticsearch.work.impl.factory.Elasticsearch5WorkFactory; | ||
import org.hibernate.search.elasticsearch.work.impl.factory.ElasticsearchWorkFactory; | ||
import org.hibernate.search.engine.nulls.impl.MissingValueStrategy; | ||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
public class Elasticsearch5Dialect implements ElasticsearchDialect { | ||
|
||
@Override | ||
public GsonProvider createGsonProvider() { | ||
return DialectIndependentGsonProvider.INSTANCE; | ||
} | ||
|
||
@Override | ||
public ElasticsearchWorkFactory createWorkFactory(GsonProvider gsonProvider) { | ||
return new Elasticsearch5WorkFactory( gsonProvider ); | ||
} | ||
|
||
@Override | ||
public ElasticsearchSchemaTranslator createSchemaTranslator() { | ||
return new Elasticsearch5SchemaTranslator(); | ||
} | ||
|
||
@Override | ||
public ElasticsearchSchemaValidator createSchemaValidator(ElasticsearchSchemaAccessor schemaAccessor) { | ||
return new Elasticsearch5SchemaValidator( schemaAccessor ); | ||
} | ||
|
||
@Override | ||
public MissingValueStrategy createMissingValueStrategy() { | ||
return Elasticsearch5MissingValueStrategy.INSTANCE; | ||
} | ||
|
||
} |
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
52 changes: 52 additions & 0 deletions
52
...ava/org/hibernate/search/elasticsearch/nulls/impl/Elasticsearch5MissingValueStrategy.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,52 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.nulls.impl; | ||
|
||
import org.hibernate.search.bridge.spi.NullMarker; | ||
import org.hibernate.search.elasticsearch.logging.impl.Log; | ||
import org.hibernate.search.elasticsearch.nulls.codec.impl.ElasticsearchBooleanNullMarkerCodec; | ||
import org.hibernate.search.elasticsearch.nulls.codec.impl.ElasticsearchDoubleNullMarkerCodec; | ||
import org.hibernate.search.elasticsearch.nulls.codec.impl.ElasticsearchFloatNullMarkerCodec; | ||
import org.hibernate.search.elasticsearch.nulls.codec.impl.ElasticsearchIntegerNullMarkerCodec; | ||
import org.hibernate.search.elasticsearch.nulls.codec.impl.ElasticsearchLongNullMarkerCodec; | ||
import org.hibernate.search.elasticsearch.nulls.codec.impl.ElasticsearchStringNullMarkerCodec; | ||
import org.hibernate.search.engine.metadata.impl.DocumentFieldPath; | ||
import org.hibernate.search.engine.nulls.codec.impl.NullMarkerCodec; | ||
import org.hibernate.search.engine.nulls.impl.MissingValueStrategy; | ||
import org.hibernate.search.util.logging.impl.LoggerFactory; | ||
|
||
public final class Elasticsearch5MissingValueStrategy implements MissingValueStrategy { | ||
private static final Log LOG = LoggerFactory.make( Log.class ); | ||
|
||
public static final Elasticsearch5MissingValueStrategy INSTANCE = new Elasticsearch5MissingValueStrategy(); | ||
|
||
@Override | ||
public NullMarkerCodec createNullMarkerCodec(Class<?> entityType, DocumentFieldPath path, NullMarker nullMarker) { | ||
Object nullEncoded = nullMarker.nullEncoded(); | ||
if ( nullEncoded instanceof String ) { | ||
return new ElasticsearchStringNullMarkerCodec( nullMarker ); | ||
} | ||
else if ( nullEncoded instanceof Integer ) { | ||
return new ElasticsearchIntegerNullMarkerCodec( nullMarker ); | ||
} | ||
else if ( nullEncoded instanceof Long ) { | ||
return new ElasticsearchLongNullMarkerCodec( nullMarker ); | ||
} | ||
else if ( nullEncoded instanceof Float ) { | ||
return new ElasticsearchFloatNullMarkerCodec( nullMarker ); | ||
} | ||
else if ( nullEncoded instanceof Double ) { | ||
return new ElasticsearchDoubleNullMarkerCodec( nullMarker ); | ||
} | ||
else if ( nullEncoded instanceof Boolean ) { | ||
return new ElasticsearchBooleanNullMarkerCodec( nullMarker ); | ||
} | ||
else { | ||
throw LOG.unsupportedNullTokenType( entityType, path.getAbsoluteName(), nullEncoded.getClass() ); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...n/java/org/hibernate/search/elasticsearch/schema/impl/Elasticsearch5SchemaTranslator.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,16 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.schema.impl; | ||
|
||
/** | ||
* An {@link ElasticsearchSchemaTranslator} implementation for Elasticsearch 5. | ||
* | ||
* @author Yoann Rodiere | ||
*/ | ||
public class Elasticsearch5SchemaTranslator extends Elasticsearch2SchemaTranslator { | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...in/java/org/hibernate/search/elasticsearch/schema/impl/Elasticsearch5SchemaValidator.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,20 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.schema.impl; | ||
|
||
/** | ||
* An {@link ElasticsearchSchemaValidator} implementation for Elasticsearch 5. | ||
* | ||
* @author Yoann Rodiere | ||
*/ | ||
public class Elasticsearch5SchemaValidator extends Elasticsearch2SchemaValidator { | ||
|
||
public Elasticsearch5SchemaValidator(ElasticsearchSchemaAccessor schemaAccessor) { | ||
super( schemaAccessor ); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
.../java/org/hibernate/search/elasticsearch/work/impl/factory/Elasticsearch5WorkFactory.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,20 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.work.impl.factory; | ||
|
||
import org.hibernate.search.elasticsearch.gson.impl.GsonProvider; | ||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
public class Elasticsearch5WorkFactory extends Elasticsearch2WorkFactory { | ||
|
||
public Elasticsearch5WorkFactory(GsonProvider gsonProvider) { | ||
super( gsonProvider ); | ||
} | ||
|
||
} |