Skip to content
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

feat(API,CLI) add support for searches with complex filters #367

Merged
merged 15 commits into from
Feb 19, 2024

Conversation

Barbozafab
Copy link
Collaborator

@Barbozafab Barbozafab commented Feb 6, 2024

Description

  • Created a new option for ls and get to perform searches with complex filters;

  • Created new API endpoint /api/objects/search;

  • Updated the CLI autocompleter with cp, connect3d and disconnect3d commands;

  • Updated the layers:

    • Layers used to have an attribute filters, which was a map[string]string filled with multiple simple filters; when the layer was applied, an AND operation was done between all the simple filters.
    • Now, this attribute has been changed to filter, a single string containing a complex filter;
    • The complex filter can be reassigned by doing [slug]:filter=[new complex filter];
    • A new filter can be added to the current one, resulting in an AND operation between the old filter and the new one, by doing [slug]:filter+=[new complex filter].
  • Fixes Logical operators in layers filters #278

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Local test

@Barbozafab Barbozafab linked an issue Feb 6, 2024 that may be closed by this pull request
API/controllers/entityController.go Outdated Show resolved Hide resolved
API/controllers/entityController.go Outdated Show resolved Hide resolved
CLI/controllers/layer.go Outdated Show resolved Hide resolved
CLI/utils/util.go Outdated Show resolved Hide resolved
@helderbetiol
Copy link
Collaborator

If someone forgets to put the path in the ls command, maybe we should give a better error:

/Physical> ls -f reservedColor=AAAAAA
Error: on GET /api/hierarchy-objects/reservedColor=AAAAAA/all?limit=1 : cannot unmarshal json : 
404 page not found

@helderbetiol
Copy link
Collaborator

The classic (simple) filter could use wildcards (*) as bellow while the complex one cannot:

admin@TenantName:/Physical> ls . name=site*
k, v name site*
siteA
siteB
siteD
admin@TenantName:/Physical> ls . -f name=site*
k, v filter name=site*
Error: Invalid filter expression

@Barbozafab
Copy link
Collaborator Author

I've updated the parser so now it demands a path to be specified when performing an ls or `get with a complex filter, and I've also added support for wildcards on complex filters.

var err error
var c *mongo.Cursor

var opts *options.FindOptions
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I've seen this code before, maybe we can create a function for it?

@Barbozafab Barbozafab merged commit 4025ae8 into main Feb 19, 2024
5 checks passed
@helderbetiol helderbetiol deleted the feat278-logical-operators branch February 28, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logical operators in layers filters
2 participants