-
Notifications
You must be signed in to change notification settings - Fork 2
Enhance ElasticsearchFilterTranslator to support String.Contains() and Enumerable.Any() expressions #19
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
base: main
Are you sure you want to change the base?
Conversation
…d Enumerable.Any() expressions Summary This PR extends the ElasticsearchFilterTranslator to handle additional LINQ expression patterns — specifically: string.Contains() for text wildcard matching Enumerable.Any() for array or list membership checks This improves query translation for Semantic Kernel filters mapped to Elasticsearch queries.
|
💚 CLA has been signed |
|
Hi @achawla83 , thank you for the PR! The For the Edit: Should be fine without |
Used the MatchPhraseQuery instead of the WildcardQuery.
|
Hi @flobernd, Thank you for the feedback! I’ve updated the code to use MatchPhraseQuery instead of WildcardQuery, as suggested. However, I’m not very familiar with writing test cases since my primary focus is on development. Could you please guide me or point me to an example so I can create the appropriate test? Thanks for your understanding! |
|
Hi @achawla83 , thanks for updating the PR. The best place to add a test would be this file which contains filter tests specific to the Elasticsearch connector. You can find some examples in the generic test suite that is provided by Microsoft and used as a common ground for all connector implementations. The related |
…and added the test cases
MatchQuery was producing zero results for substring searches, causing the StringContains_with_substring test to fail.
Implemented WildcardQuery (*{substring}*) to align behavior with .Contains() semantics.
|
Hi @flobernd, I made an update related to the failing test StringContains_with_substring. Since the .Contains("fo") logic requires a substring match, I replaced the MatchQuery with a WildcardQuery that uses {substring}. This aligns the Elasticsearch behavior with what the test expects. Updated code: After this change, the test passes as expected. I also added the necessary test cases to ensure this scenario is covered. Let me know if you want to adjust the behavior or discuss alternative approaches. |
|
Hi @achawla83 , thank you for adding the tests. I'll have a look soon 🙂 Regarding |
Summary
This PR extends the ElasticsearchFilterTranslator to handle additional LINQ expression patterns — specifically:
string.Contains() for text wildcard matching
Enumerable.Any() for array or list membership checks
This improves query translation for Semantic Kernel filters mapped to Elasticsearch queries.