-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-4950 Update validation of vector-specific mapping attributes
- Loading branch information
1 parent
f7ca3fe
commit 5ae4212
Showing
11 changed files
with
356 additions
and
87 deletions.
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
73 changes: 73 additions & 0 deletions
73
...ckend/elasticsearch/lowlevel/index/mapping/impl/ElasticsearchDenseVectorIndexOptions.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,73 @@ | ||
/* | ||
* 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.backend.elasticsearch.lowlevel.index.mapping.impl; | ||
|
||
import java.util.Map; | ||
|
||
import org.hibernate.search.backend.elasticsearch.gson.impl.SerializeExtraProperties; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.annotations.JsonAdapter; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
/** | ||
* An object representing Elasticsearch dense vector-specific index options attributes. | ||
* | ||
* See https://www.elastic.co/guide/en/elasticsearch/reference/current/dense-vector.html | ||
*/ | ||
/* | ||
* CAUTION: | ||
* 1. JSON serialization is controlled by a specific adapter, which must be | ||
* updated whenever fields of this class are added, renamed or removed. | ||
* | ||
* 2. Whenever adding more properties consider adding property validation to PropertyMappingValidator#ElasticsearchDenseVectorIndexOptionsValidator. | ||
*/ | ||
@JsonAdapter(ElasticsearchDenseVectorIndexOptionsJsonAdapterFactory.class) | ||
public class ElasticsearchDenseVectorIndexOptions { | ||
|
||
private String type; | ||
|
||
private Integer m; | ||
|
||
@SerializedName("ef_construction") | ||
private Integer efConstruction; | ||
|
||
@SerializeExtraProperties | ||
private Map<String, JsonElement> extraAttributes; | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public Integer getM() { | ||
return m; | ||
} | ||
|
||
public void setM(Integer m) { | ||
this.m = m; | ||
} | ||
|
||
public Integer getEfConstruction() { | ||
return efConstruction; | ||
} | ||
|
||
public void setEfConstruction(Integer efConstruction) { | ||
this.efConstruction = efConstruction; | ||
} | ||
|
||
public Map<String, JsonElement> getExtraAttributes() { | ||
return extraAttributes; | ||
} | ||
|
||
public void setExtraAttributes(Map<String, JsonElement> extraAttributes) { | ||
this.extraAttributes = extraAttributes; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...h/lowlevel/index/mapping/impl/ElasticsearchDenseVectorIndexOptionsJsonAdapterFactory.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,21 @@ | ||
/* | ||
* 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.backend.elasticsearch.lowlevel.index.mapping.impl; | ||
|
||
import org.hibernate.search.backend.elasticsearch.gson.impl.AbstractConfiguredExtraPropertiesJsonAdapterFactory; | ||
|
||
public class ElasticsearchDenseVectorIndexOptionsJsonAdapterFactory | ||
extends | ||
AbstractConfiguredExtraPropertiesJsonAdapterFactory { | ||
|
||
@Override | ||
protected <T> void addFields(Builder<T> builder) { | ||
builder.add( "type", String.class ); | ||
builder.add( "m", Integer.class ); | ||
builder.add( "efConstruction", Integer.class ); | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
.../search/backend/elasticsearch/lowlevel/index/mapping/impl/OpenSearchVectorTypeMethod.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,118 @@ | ||
/* | ||
* 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.backend.elasticsearch.lowlevel.index.mapping.impl; | ||
|
||
import java.util.Map; | ||
|
||
import org.hibernate.search.backend.elasticsearch.gson.impl.SerializeExtraProperties; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.annotations.JsonAdapter; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
/** | ||
* An object representing OpenSearch K-NN vector Method attributes. | ||
* | ||
* See https://opensearch.org/docs/latest/field-types/supported-field-types/knn-vector/ | ||
*/ | ||
/* | ||
* CAUTION: | ||
* 1. JSON serialization is controlled by a specific adapter, which must be | ||
* updated whenever fields of this class are added, renamed or removed. | ||
* | ||
* 2. Whenever adding more properties consider adding property validation to PropertyMappingValidator. | ||
*/ | ||
@JsonAdapter(OpenSearchVectorTypeMethodJsonAdapterFactory.class) | ||
public class OpenSearchVectorTypeMethod { | ||
|
||
private String name; | ||
|
||
@SerializedName("space_type") | ||
private String spaceType; | ||
|
||
private String engine; | ||
|
||
private Parameters parameters; | ||
|
||
@SerializeExtraProperties | ||
private Map<String, JsonElement> extraAttributes; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getSpaceType() { | ||
return spaceType; | ||
} | ||
|
||
public void setSpaceType(String spaceType) { | ||
this.spaceType = spaceType; | ||
} | ||
|
||
public String getEngine() { | ||
return engine; | ||
} | ||
|
||
public void setEngine(String engine) { | ||
this.engine = engine; | ||
} | ||
|
||
public Parameters getParameters() { | ||
return parameters; | ||
} | ||
|
||
public void setParameters(Parameters parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
public Map<String, JsonElement> getExtraAttributes() { | ||
return extraAttributes; | ||
} | ||
|
||
public void setExtraAttributes(Map<String, JsonElement> extraAttributes) { | ||
this.extraAttributes = extraAttributes; | ||
} | ||
|
||
@JsonAdapter(OpenSearchVectorTypeMethodJsonAdapterFactory.ParametersJsonAdapterFactory.class) | ||
public static class Parameters { | ||
|
||
@SerializedName("ef_construction") | ||
private Integer efConstruction; | ||
private Integer m; | ||
|
||
@SerializeExtraProperties | ||
private Map<String, JsonElement> extraAttributes; | ||
|
||
public Integer getEfConstruction() { | ||
return efConstruction; | ||
} | ||
|
||
public void setEfConstruction(Integer efConstruction) { | ||
this.efConstruction = efConstruction; | ||
} | ||
|
||
public Integer getM() { | ||
return m; | ||
} | ||
|
||
public void setM(Integer m) { | ||
this.m = m; | ||
} | ||
|
||
public Map<String, JsonElement> getExtraAttributes() { | ||
return extraAttributes; | ||
} | ||
|
||
public void setExtraAttributes(Map<String, JsonElement> extraAttributes) { | ||
this.extraAttributes = extraAttributes; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...asticsearch/lowlevel/index/mapping/impl/OpenSearchVectorTypeMethodJsonAdapterFactory.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,32 @@ | ||
/* | ||
* 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.backend.elasticsearch.lowlevel.index.mapping.impl; | ||
|
||
import org.hibernate.search.backend.elasticsearch.gson.impl.AbstractConfiguredExtraPropertiesJsonAdapterFactory; | ||
|
||
public class OpenSearchVectorTypeMethodJsonAdapterFactory | ||
extends | ||
AbstractConfiguredExtraPropertiesJsonAdapterFactory { | ||
|
||
@Override | ||
protected <T> void addFields(Builder<T> builder) { | ||
builder.add( "name", String.class ); | ||
builder.add( "spaceType", String.class ); | ||
builder.add( "engine", String.class ); | ||
builder.add( "parameters", OpenSearchVectorTypeMethod.Parameters.class ); | ||
} | ||
|
||
public static class ParametersJsonAdapterFactory | ||
extends | ||
AbstractConfiguredExtraPropertiesJsonAdapterFactory { | ||
@Override | ||
protected <T> void addFields(Builder<T> builder) { | ||
builder.add( "m", Integer.class ); | ||
builder.add( "efConstruction", Integer.class ); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.