Skip to content

Conversation

parkertimmins
Copy link
Contributor

The value fetcher is used produce message values during the second phrase of the two phrase iterator during a source confirmed query to check that the message actually matches. A query may need to scan many values so the value fetcher must be fast. Currently the value fetcher requires building the source. Instead it should use the doc_value iterator and only load the message values.

@parkertimmins parkertimmins added >non-issue :StorageEngine/Mapping The storage related side of mappings labels Sep 13, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@@ -154,6 +154,24 @@ public void testSmallValueNotStored() throws IOException {
}
}

public void testPhraseQuery() throws IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way I could figure to test this change was to use the debugger during a phrase query and verify that the values were coming from the field data loader. If you can think of a better way I'd be interested. Decided to leave in this test that runs a phrase query since, though testQueryResultsSameAsMatchOnlyText does this, it's a bit too smart which makes it harder to trust.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a unit test to PatternedTextFieldTypeTests? I think using MapperTestCase#assertFetch(...) will help assert that we read from doc values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Implementing generateRandomInputValue values testFetch to run this test. We still have to disable assertFetchMany though since patterned_text only allows a single value per field.

return SourceValueFetcher.toString(name(), context, format);
// This operation is really a SEARCH, not a SCRIPT operation.
// But we only allow direct access to field data for scripts.
// The value fetcher uses field data internally though, so pretend the operation is script.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using SCRIPT here is a bit sketchy, but it's the only way I could think to disallow aggregations, while letting the value fetcher use doc_values (though the field data api).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is sketchy. The alternative is I think implementing a custom ValueFetcher implementation that uses PatternedTextDocValues.from(...) directly? To avoid the validation in PatternedTextFieldType#fielddataBuilder(...).

@@ -154,6 +154,24 @@ public void testSmallValueNotStored() throws IOException {
}
}

public void testPhraseQuery() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a unit test to PatternedTextFieldTypeTests? I think using MapperTestCase#assertFetch(...) will help assert that we read from doc values?

return SourceValueFetcher.toString(name(), context, format);
// This operation is really a SEARCH, not a SCRIPT operation.
// But we only allow direct access to field data for scripts.
// The value fetcher uses field data internally though, so pretend the operation is script.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is sketchy. The alternative is I think implementing a custom ValueFetcher implementation that uses PatternedTextDocValues.from(...) directly? To avoid the validation in PatternedTextFieldType#fielddataBuilder(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants