Skip to content

[ML] adding result_type and mlcategory fields to category definitions #63326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CategoryDefinition implements ToXContentObject, Writeable {
public static final ParseField GROK_PATTERN = new ParseField("grok_pattern");
public static final ParseField NUM_MATCHES = new ParseField("num_matches");
public static final ParseField PREFERRED_TO_CATEGORIES = new ParseField("preferred_to_categories");
public static final ParseField MLCATEGORY = new ParseField("mlcategory");

// Used for QueryPage
public static final ParseField RESULTS_FIELD = new ParseField("categories");
Expand All @@ -62,6 +63,8 @@ private static ConstructingObjectParser<CategoryDefinition, Void> createParser(b
parser.declareString(CategoryDefinition::setGrokPattern, GROK_PATTERN);
parser.declareLongArray(CategoryDefinition::setPreferredToCategories, PREFERRED_TO_CATEGORIES);
parser.declareLong(CategoryDefinition::setNumMatches, NUM_MATCHES);
parser.declareString((cd, rt) -> { /*Ignore as it is always category_definition*/ }, Result.RESULT_TYPE);
parser.declareLong((cd, mc) -> { /*Ignore as it is always equal to category_id*/ }, MLCATEGORY);
return parser;
}

Expand Down Expand Up @@ -246,6 +249,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (partitionFieldName != null && partitionFieldValue != null && ReservedFieldNames.isValidFieldName(partitionFieldName)) {
builder.field(partitionFieldName, partitionFieldValue);
}
builder.field(Result.RESULT_TYPE.getPreferredName(), TYPE.getPreferredName());
builder.field(MLCATEGORY.getPreferredName(), categoryId);

builder.endObject();
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public final class ReservedFieldNames {
CategoryDefinition.EXAMPLES.getPreferredName(),
CategoryDefinition.NUM_MATCHES.getPreferredName(),
CategoryDefinition.PREFERRED_TO_CATEGORIES.getPreferredName(),
CategoryDefinition.MLCATEGORY.getPreferredName(),

DataCounts.PROCESSED_RECORD_COUNT.getPreferredName(),
DataCounts.PROCESSED_FIELD_COUNT.getPreferredName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@
"missing_field_count" : {
"type" : "long"
},
"mlcategory": {
"type": "keyword"
},
"model_bytes" : {
"type" : "long"
},
Expand Down