Adds Query Language#814
Conversation
- Adapts README
- Fixes field-to-field comparisons - Enables AASQL for AAS Registry Log MongoDB - [WIP] initiates Search Feature for AasRegistry by Jannis Jung Co-authored-by: Jannis Jung <jannis.jung@iese.fraunhofer.de> Co-authored-by: Aaron Zielstorff <aaron.zi@web.de>
This reverts commit f8e0e5d.
- Removes unused files
- Adapts RestControllers of Registries
There was a problem hiding this comment.
Pull Request Overview
This PR adds a first implementation for the AAS Query Language as defined per IDTA specification. The implementation provides search capabilities for submodel registries and concept description repositories using Elasticsearch as the search backend.
Key changes include:
- Implementation of the AAS Query Language (AASQL) converter for Elasticsearch
- Search features for Submodel Registry with indexing and query capabilities
- Search features for Concept Description Repository with similar functionality
Reviewed Changes
Copilot reviewed 123 out of 163 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| basyx.common/pom.xml | Adds querycore module to common components |
| basyx.conceptdescriptionrepository/pom.xml | Adds search feature module for concept descriptions |
| basyx.submodelregistry/basyx.submodelregistry-feature-search/pom.xml | Maven configuration for submodel registry search feature |
| basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-feature-search/pom.xml | Maven configuration for concept description search feature |
| Multiple source files | Core implementation of search functionality, API controllers, and configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| @Override | ||
| public Set<String> clear() { | ||
| return Set.of(); |
There was a problem hiding this comment.
The clear() method returns an empty Set instead of actually clearing the storage. This should delegate to the decorated storage's clear() method and also clear the Elasticsearch index.
| return Set.of(); | |
| Set<String> clearedIds = decorated.clear(); | |
| try { | |
| esclient.deleteByQuery(d -> d | |
| .index(indexName) | |
| .query(q -> q.matchAll(m -> m)) | |
| ); | |
| } catch (IOException e) { | |
| throw new RuntimeException(e); | |
| } | |
| return clearedIds; |
| // Hard Code to only retrieve ids -> Fetching the actual SM Descs from MongoDB | ||
| query.set$select("id"); | ||
| queryResponse = getQueryResponse(query, limit, cursor); | ||
| queryResponse.paging_metadata.resulType = "SubmodelDescriptor"; |
There was a problem hiding this comment.
Spelling error: 'resulType' should be 'resultType'.
| queryResponse.paging_metadata.resulType = "SubmodelDescriptor"; | |
| queryResponse.paging_metadata.resultType = "SubmodelDescriptor"; |
| // Hard Code to only retrieve ids -> Fetching the actual CD from MongoDB | ||
| query.set$select("id"); | ||
| queryResponse = getQueryResponse(query, limit, cursor); | ||
| queryResponse.paging_metadata.resulType = "ConceptDescription"; |
There was a problem hiding this comment.
Spelling error: 'resulType' should be 'resultType'.
| queryResponse.paging_metadata.resulType = "ConceptDescription"; | |
| queryResponse.paging_metadata.resultType = "ConceptDescription"; |
| error = true; | ||
| } else { | ||
| logger.info("BaSyx Backend: " + basyxBackend); | ||
| } |
There was a problem hiding this comment.
Potential NullPointerException: basyxBackend could be null. Should use Objects.equals() or add null check before calling equals().
| } | |
| if (Objects.equals(basyxBackend, "InMemory")) { | |
| logger.error("BaSyx Backend is set to InMemory. Search feature requires a persistent backend."); | |
| error = true; | |
| } else { | |
| logger.info("BaSyx Backend: " + basyxBackend); | |
| } |
| searchAPI = appContext.getBean(SearchSubmodelRegistryApiHTTPController.class); | ||
| preloadSmds(); | ||
| Thread.sleep(2000); | ||
| } |
There was a problem hiding this comment.
Hard-coded sleep in tests is unreliable and slows down test execution. Consider using proper synchronization mechanisms or polling with timeout instead.
| } | |
| @BeforeClass | |
| public static void setUp() throws IOException, DeserializationException, InterruptedException { | |
| appContext = new SpringApplication(DummySearchSubmodelRegistryComponent.class).run(new String[] {}); | |
| storage = appContext.getBean(SearchSubmodelRegistryStorage.class); | |
| searchAPI = appContext.getBean(SearchSubmodelRegistryApiHTTPController.class); | |
| preloadSmds(); | |
| waitForSearchApiReady(); | |
| } |
There was a problem hiding this comment.
We should definitely consider this.
|
|
||
| private static void waitForData() throws InterruptedException { | ||
| Thread.sleep(2000); | ||
| } |
There was a problem hiding this comment.
Hard-coded sleep in tests is unreliable and slows down test execution. Consider using proper synchronization mechanisms or polling with timeout instead.
| } | |
| private static void waitForData() throws InterruptedException { | |
| // Wait up to 5 seconds for at least one ConceptDescription to be available | |
| int maxAttempts = 50; | |
| int attempt = 0; | |
| while (searchBackend.getAllConceptDescriptions(new PaginationInfo(0, "")).getResult().isEmpty() && attempt < maxAttempts) { | |
| Thread.sleep(100); | |
| attempt++; | |
| } | |
| if (searchBackend.getAllConceptDescriptions(new PaginationInfo(0, "")).getResult().isEmpty()) { | |
| throw new IllegalStateException("ConceptDescriptions not available after waiting for data."); | |
| } | |
| } |
There was a problem hiding this comment.
We should definitely consider this.
aaronzi
left a comment
There was a problem hiding this comment.
Please also add the search example to the GitHub Actions
There was a problem hiding this comment.
Line endings must have changed here. please revert this change so that the actual diff is visible
There was a problem hiding this comment.
Please check line endings here as well
There was a problem hiding this comment.
Please revert change of line endings
There was a problem hiding this comment.
Please revert line endings change
| @@ -0,0 +1,181 @@ | |||
| /******************************************************************************* | |||
| * Copyright (C) 2024 the Eclipse BaSyx Authors | |||
There was a problem hiding this comment.
| * Copyright (C) 2024 the Eclipse BaSyx Authors | |
| * Copyright (C) 2025 the Eclipse BaSyx Authors |
There was a problem hiding this comment.
Please revert line endings change
There was a problem hiding this comment.
Please revert line endings change
Description of Changes
This PR adds a first implementation for the AAS Query Language as defined per specification of the IDTA.
BaSyx Configuration for Testing
See the BaSyxQueryLanguage folder in the examples as a reference
examples/BaSyxQueryLanguage/docker-compose.yml
Additional Information
There are still some operators that are not fully implemented yet:
Please feel free to report any problems as an issue.