Skip to content

Adds Query Language#814

Merged
aaronzi merged 53 commits into
eclipse-basyx:mainfrom
FriedJannik:queryLanguage
Aug 21, 2025
Merged

Adds Query Language#814
aaronzi merged 53 commits into
eclipse-basyx:mainfrom
FriedJannik:queryLanguage

Conversation

@FriedJannik

@FriedJannik FriedJannik commented Aug 11, 2025

Copy link
Copy Markdown
Member

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:

  • Querying in Submodel Elements
  • Operators: $gt, $lt, $le, $ge

Please feel free to report any problems as an issue.

@aaronzi aaronzi requested a review from Copilot August 20, 2025 13:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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();

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
// 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";

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

Spelling error: 'resulType' should be 'resultType'.

Suggested change
queryResponse.paging_metadata.resulType = "SubmodelDescriptor";
queryResponse.paging_metadata.resultType = "SubmodelDescriptor";

Copilot uses AI. Check for mistakes.
// 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";

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

Spelling error: 'resulType' should be 'resultType'.

Suggested change
queryResponse.paging_metadata.resulType = "ConceptDescription";
queryResponse.paging_metadata.resultType = "ConceptDescription";

Copilot uses AI. Check for mistakes.
error = true;
} else {
logger.info("BaSyx Backend: " + basyxBackend);
}

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

Potential NullPointerException: basyxBackend could be null. Should use Objects.equals() or add null check before calling equals().

Suggested change
}
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);
}

Copilot uses AI. Check for mistakes.
searchAPI = appContext.getBean(SearchSubmodelRegistryApiHTTPController.class);
preloadSmds();
Thread.sleep(2000);
}

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

Hard-coded sleep in tests is unreliable and slows down test execution. Consider using proper synchronization mechanisms or polling with timeout instead.

Suggested change
}
@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();
}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should definitely consider this.


private static void waitForData() throws InterruptedException {
Thread.sleep(2000);
}

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

Hard-coded sleep in tests is unreliable and slows down test execution. Consider using proper synchronization mechanisms or polling with timeout instead.

Suggested change
}
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.");
}
}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should definitely consider this.

@FriedJannik FriedJannik marked this pull request as ready for review August 21, 2025 10:54

@aaronzi aaronzi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please also add the search example to the GitHub Actions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Line endings must have changed here. please revert this change so that the actual diff is visible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please check line endings here as well

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert change of line endings

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert line endings change

@@ -0,0 +1,181 @@
/*******************************************************************************
* Copyright (C) 2024 the Eclipse BaSyx Authors

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Copyright (C) 2024 the Eclipse BaSyx Authors
* Copyright (C) 2025 the Eclipse BaSyx Authors

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert line endings change

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert changes please

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert line endings change

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert this file

Comment thread examples/BaSyxQueryLanguage/README.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert this file

@aaronzi aaronzi merged commit a542451 into eclipse-basyx:main Aug 21, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants