- Notifications
You must be signed in to change notification settings - Fork33
Gis 8639 add ElasticSearchEQLQueryParser#199
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
2e398a8 gis-8639 add elastic-eql-query parser
nazargesyk83958ed gis-8639 fix mapping
nazargesyk90f2179 gis-8639 fix
nazargesyk1c1333f gis-8639 fix
nazargesykd6bd1f9 gis-8639 fix
nazargesykbb92949 Merge branch 'main' into gis-8639
nazargesyk2703d8a Merge branch 'main' into gis-8639
nazargesyk608a1f4 gis-8639 fixes
nazargesykFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionsuncoder-core/app/translator/platforms/elasticsearch/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletionsuncoder-core/app/translator/platforms/elasticsearch/const.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionsuncoder-core/app/translator/platforms/elasticsearch/mapping.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletionsuncoder-core/app/translator/platforms/elasticsearch/parsers/elasticsearch_eql.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import re | ||
| from app.translator.core.models.platform_details import PlatformDetails | ||
| from app.translator.core.models.query_container import RawQueryContainer, TokenizedQueryContainer | ||
| from app.translator.core.parser import PlatformQueryParser | ||
| from app.translator.managers import parser_manager | ||
| from app.translator.platforms.base.lucene.mapping import LuceneMappings | ||
| from app.translator.platforms.elasticsearch.const import elastic_eql_query_details | ||
| from app.translator.platforms.elasticsearch.mapping import elastic_eql_query_mappings | ||
| from app.translator.platforms.elasticsearch.tokenizer import ElasticSearchEQLTokenizer | ||
| @parser_manager.register_supported_by_roota | ||
| class ElasticSearchEQLQueryParser(PlatformQueryParser): | ||
| details: PlatformDetails = elastic_eql_query_details | ||
| tokenizer = ElasticSearchEQLTokenizer() | ||
| mappings: LuceneMappings = elastic_eql_query_mappings | ||
| query_delimiter_pattern = r"\swhere\s" | ||
| def _parse_query(self, query: str) -> tuple[str, dict[str, list[str]]]: | ||
| log_source = {"category": []} | ||
| if re.search(self.query_delimiter_pattern, query, flags=re.IGNORECASE): | ||
| sp_query = re.split(self.query_delimiter_pattern, query, flags=re.IGNORECASE) | ||
| if sp_query[0].lower() != "all": | ||
| log_source["category"].append(sp_query[0]) | ||
| return sp_query[1], log_source | ||
| return query, log_source | ||
| def parse(self, raw_query_container: RawQueryContainer) -> TokenizedQueryContainer: | ||
| query, log_sources = self._parse_query(raw_query_container.query) | ||
| query_tokens = self.get_query_tokens(query) | ||
| field_tokens = self.get_field_tokens(query_tokens) | ||
| source_mappings = self.get_source_mappings(field_tokens, log_sources) | ||
| meta_info = raw_query_container.meta_info | ||
| meta_info.query_fields = field_tokens | ||
| meta_info.source_mapping_ids = [source_mapping.source_id for source_mapping in source_mappings] | ||
| return TokenizedQueryContainer(tokens=query_tokens, meta_info=meta_info) |
4 changes: 2 additions & 2 deletionsuncoder-core/app/translator/platforms/elasticsearch/renders/esql.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletionuncoder-core/app/translator/platforms/elasticsearch/str_value_manager.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletionsuncoder-core/app/translator/platforms/elasticsearch/tokenizer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.