-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Use a system property to enable inference metadata fields #118876
Changes from all commits
a718a7e
af682c7
0b48f0c
c5ced6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,12 @@ | |
|
||
package org.elasticsearch.index.mapper; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.lucene.search.IndexSearcher; | ||
import org.apache.lucene.search.Query; | ||
import org.apache.lucene.search.join.BitSetProducer; | ||
import org.elasticsearch.common.util.FeatureFlag; | ||
import org.elasticsearch.core.Booleans; | ||
import org.elasticsearch.index.IndexVersion; | ||
import org.elasticsearch.index.IndexVersions; | ||
import org.elasticsearch.index.query.SearchExecutionContext; | ||
|
@@ -26,7 +28,37 @@ | |
* the field name for removal from _source. | ||
*/ | ||
public abstract class InferenceMetadataFieldsMapper extends MetadataFieldMapper { | ||
public static final FeatureFlag INFERENCE_METADATA_FIELDS_FEATURE_FLAG = new FeatureFlag("inference_metadata_fields"); | ||
public static class SystemProperty { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be better to add the possibility of using a (I know this is temporary but just wondering) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but that would require modifying the I plan on starting the discussion about opt-in feature flags in the new year, we can address a long-term solution for situations like this at that time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand. I don't like one-off temporary solutions but I get you're trying to get this in for 8.18. I trust you'll follow up on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will absolutely follow up on this, thank you for understanding the time constraints. And I put the hacky |
||
private static final Logger logger = LogManager.getLogger(SystemProperty.class); | ||
|
||
private final boolean enabled; | ||
|
||
private SystemProperty(String name) { | ||
String propertyName = "es." + name; | ||
this.enabled = parseSystemProperty(propertyName, false); | ||
if (this.enabled) { | ||
logger.info("Feature " + name + " (via system property '" + propertyName + "') is enabled"); | ||
} else { | ||
logger.debug("Feature " + name + " (via system property '" + propertyName + "') is disabled"); | ||
} | ||
} | ||
|
||
private boolean parseSystemProperty(String propertyName, boolean defaultValue) { | ||
final String propertyValue = System.getProperty(propertyName); | ||
logger.trace("System property [{}] is set to [{}]", propertyName, propertyValue); | ||
try { | ||
return Booleans.parseBoolean(propertyValue, defaultValue); | ||
} catch (IllegalArgumentException e) { | ||
throw new IllegalArgumentException("Invalid value [" + propertyValue + "] for system property [" + propertyName + "]", e); | ||
} | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
} | ||
|
||
public static final SystemProperty INFERENCE_METADATA_FIELDS_SYSTEM_PROPERTY = new SystemProperty("inference_metadata_fields"); | ||
|
||
public static final String NAME = "_inference_fields"; | ||
public static final String CONTENT_TYPE = "_inference_fields"; | ||
|
@@ -61,6 +93,6 @@ public abstract ValueFetcher valueFetcher( | |
} | ||
|
||
public static boolean isEnabled(IndexVersion indexVersion) { | ||
return indexVersion.onOrAfter(IndexVersions.INFERENCE_METADATA_FIELDS) && INFERENCE_METADATA_FIELDS_FEATURE_FLAG.isEnabled(); | ||
return indexVersion.onOrAfter(IndexVersions.INFERENCE_METADATA_FIELDS) && INFERENCE_METADATA_FIELDS_SYSTEM_PROPERTY.isEnabled(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick - there's no reason not to keep the FF in as well, in case we can remove this system property sooner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add the feature flag back with a one line change if/when we want to re-introduce it. In the meantime,
IMO better to not have a feature flag we know is not being used.