forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into custom-roles-get-roles-api
- Loading branch information
Showing
34 changed files
with
411 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 105373 | ||
summary: "Fix parsing of flattened fields within subobjects: false" | ||
area: Mapping | ||
type: bug | ||
issues: [] |
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,6 @@ | ||
pr: 105633 | ||
summary: "[Connector API] Bugfix: support list type in filtering advenced snippet\ | ||
\ value" | ||
area: Application | ||
type: bug | ||
issues: [] |
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
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
91 changes: 91 additions & 0 deletions
91
server/src/main/java/org/elasticsearch/inference/SemanticTextModelSettings.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,91 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.inference; | ||
|
||
import org.elasticsearch.core.Nullable; | ||
import org.elasticsearch.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.xcontent.ParseField; | ||
import org.elasticsearch.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Model settings that are interesting for semantic_text inference fields. This class is used to serialize common | ||
* ServiceSettings methods when building inference for semantic_text fields. | ||
* | ||
* @param taskType task type | ||
* @param inferenceId inference id | ||
* @param dimensions number of dimensions. May be null if not applicable | ||
* @param similarity similarity used by the service. May be null if not applicable | ||
*/ | ||
public record SemanticTextModelSettings( | ||
TaskType taskType, | ||
String inferenceId, | ||
@Nullable Integer dimensions, | ||
@Nullable SimilarityMeasure similarity | ||
) { | ||
|
||
public static final String NAME = "model_settings"; | ||
private static final ParseField TASK_TYPE_FIELD = new ParseField("task_type"); | ||
private static final ParseField INFERENCE_ID_FIELD = new ParseField("inference_id"); | ||
private static final ParseField DIMENSIONS_FIELD = new ParseField("dimensions"); | ||
private static final ParseField SIMILARITY_FIELD = new ParseField("similarity"); | ||
|
||
public SemanticTextModelSettings(TaskType taskType, String inferenceId, Integer dimensions, SimilarityMeasure similarity) { | ||
Objects.requireNonNull(taskType, "task type must not be null"); | ||
Objects.requireNonNull(inferenceId, "inferenceId must not be null"); | ||
this.taskType = taskType; | ||
this.inferenceId = inferenceId; | ||
this.dimensions = dimensions; | ||
this.similarity = similarity; | ||
} | ||
|
||
public SemanticTextModelSettings(Model model) { | ||
this( | ||
model.getTaskType(), | ||
model.getInferenceEntityId(), | ||
model.getServiceSettings().dimensions(), | ||
model.getServiceSettings().similarity() | ||
); | ||
} | ||
|
||
public static SemanticTextModelSettings parse(XContentParser parser) throws IOException { | ||
return PARSER.apply(parser, null); | ||
} | ||
|
||
private static final ConstructingObjectParser<SemanticTextModelSettings, Void> PARSER = new ConstructingObjectParser<>(NAME, args -> { | ||
TaskType taskType = TaskType.fromString((String) args[0]); | ||
String inferenceId = (String) args[1]; | ||
Integer dimensions = (Integer) args[2]; | ||
SimilarityMeasure similarity = args[3] == null ? null : SimilarityMeasure.fromString((String) args[2]); | ||
return new SemanticTextModelSettings(taskType, inferenceId, dimensions, similarity); | ||
}); | ||
static { | ||
PARSER.declareString(ConstructingObjectParser.constructorArg(), TASK_TYPE_FIELD); | ||
PARSER.declareString(ConstructingObjectParser.constructorArg(), INFERENCE_ID_FIELD); | ||
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), DIMENSIONS_FIELD); | ||
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), SIMILARITY_FIELD); | ||
} | ||
|
||
public Map<String, Object> asMap() { | ||
Map<String, Object> attrsMap = new HashMap<>(); | ||
attrsMap.put(TASK_TYPE_FIELD.getPreferredName(), taskType.toString()); | ||
attrsMap.put(INFERENCE_ID_FIELD.getPreferredName(), inferenceId); | ||
if (dimensions != null) { | ||
attrsMap.put(DIMENSIONS_FIELD.getPreferredName(), dimensions); | ||
} | ||
if (similarity != null) { | ||
attrsMap.put(SIMILARITY_FIELD.getPreferredName(), similarity); | ||
} | ||
return Map.of(NAME, attrsMap); | ||
} | ||
} |
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
7 changes: 4 additions & 3 deletions
7
...k/inference/common/SimilarityMeasure.java → ...icsearch/inference/SimilarityMeasure.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
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.