-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Apply field type checking in text_expansion queries #116335
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
Apply field type checking in text_expansion queries #116335
Conversation
|
Hey guys! I'm pretty stuck with the field type checking. I was reading through other queries' code (such as
I'm thinking about going up in the call stack and making this verification in a place with a more meaningful context. I don't know if that's the right approach since it will probably lead to code outside the |
|
In general, I think the approach here should be to rewrite the query to a |
I read through your article and it gave me some ideas. You mention that "inference results that would be sent as input into a text expansion search". Since we're trying to rewrite most of the work as a WeightedTokens query, would it be enough to verify that the text expansion results produced weighted tokens? |
So you're thinking of making sure that a I had started down the path of seeing if we could omit the boolean query, but that didn't seem to work: #116047 I haven't looked into it further to see what the best solution would be. You could validate and experiment with solutions though, and add some tests to validate whether they work. First, you could add a test case in text_expansion_search.yml that does the following: This would show this behavior of what happens without the pruning configurations. (There is more information about our YAML REST tests here). You can then see if other tests break with the following command line call: (This is a more specific version of the ./gradlew :check function we ask contributors to run before submitting PRs). If specific tests fail, they'll be output with specific commands to reproduce them, so that you can test just the one failure and not wait for the entire test suite to fail. Hope that helps! |
|
Thanks for the material! It was really helpful to run the test suite.
Actually, since I noticed that the supplier is populated for each call regardless of the query type, I'm checking if there are any if(tokenPruning != null || textExpansionResultsHasWeightedTokens) {
...
}How does that sound? |
|
Pinging @elastic/ml-core (Team:ML) |
|
Pinging @elastic/search-eng (Team:SearchOrg) |
|
Pinging @elastic/search-relevance (Team:Search - Relevance) |
This PR closes #116046 by adding a type verification in a text_expansion query. As @kderusso detailed, field type checking happens only when a text_expansion query are rewritten as a weighted_tokens query due to token pruning. The code is refactored such that field type checking occurs regardless of token pruning and text_expansion queries occur only against allowed types (sparse_vector and rank features).