nit0906 commented on code in PR #1804:
URL: https://github.com/apache/jackrabbit-oak/pull/1804#discussion_r1820034467
##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java:
##########
@@ -381,4 +398,151 @@ protected IndexDefinition createInstance(NodeState
indexDefnStateToUse) {
return new ElasticIndexDefinition(root, indexDefnStateToUse,
indexPath, indexPrefix);
}
}
+
+ public static class InferenceDefinition {
+
+ public List<Property> properties;
+
+ public List<Query> queries;
+
+ public InferenceDefinition() { }
+
+ public InferenceDefinition(NodeState inferenceNode) {
+ if (inferenceNode.hasChildNode("properties")) {
+ this.properties =
StreamSupport.stream(inferenceNode.getChildNode("properties").getChildNodeEntries().spliterator(),
false)
+ .map(cne -> new Property(cne.getName(),
cne.getNodeState()))
+ .collect(Collectors.toList());
+ }
+ if (inferenceNode.hasChildNode("queries")) {
+ this.queries =
StreamSupport.stream(inferenceNode.getChildNode("queries").getChildNodeEntries().spliterator(),
false)
+ .map(cne -> new Query(cne.getName(),
cne.getNodeState()))
+ .collect(Collectors.toList());
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ InferenceDefinition that = (InferenceDefinition) o;
+ return Objects.equals(properties, that.properties) &&
Objects.equals(queries, that.queries);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(properties);
+ }
+
+ public static class Property {
+ public String name;
+ public String model;
+ public List<String> fields;
+ public int dims;
+ public String similarity;
+
+ public Property() {}
+
+ public Property(String name, NodeState inferenceNode) {
+ this.name = ElasticIndexDefinition.INFERENCE + "." + name;
+ this.model = getOptionalValue(inferenceNode, "model",
"semantic");
+ this.fields = Arrays.asList(getOptionalValues(inferenceNode,
"fields", Type.STRINGS, String.class, new String[0]));
+ this.dims = getOptionalValue(inferenceNode, "dims", 1024);
+ this.similarity = getOptionalValue(inferenceNode,
"similarity", "cosine");
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Property property = (Property) o;
+ return dims == property.dims && Objects.equals(name,
property.name) &&
+ Objects.equals(model, property.model) &&
+ Objects.equals(fields, property.fields) &&
+ Objects.equals(similarity, property.similarity);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, model, fields, dims, similarity);
+ }
+ }
+
+ public static class Query {
Review Comment:
Could we add a small description for the class and the configuration
parameters ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]