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

The grep search UI #33

Open
bskqd opened this issue Mar 17, 2023 · 0 comments
Open

The grep search UI #33

bskqd opened this issue Mar 17, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request Priority: Medium

Comments

@bskqd
Copy link
Contributor

bskqd commented Mar 17, 2023

endpoint: http://localhost/api/yang-search/v2/grep_search (replace localhost with yc-frontend if you want to get the information from one of the containers e.g yc-backend using requests.get())

query params
search_string - the actual string a user wants to search for. For example, you can use these searches to test it locally: 'organization' - this gives the most results,
typedef dscp {\n.*type uint8 {\n.*range "0..63";\n.*} - a more complicated search, this one gives me only two results locally.
The main idea of the search string is that if we have a module that contains such a part:

typedef dscp {
    type uint8 {
        range "0..63";
        }

every line break is matched by these chars\n.*, this is actually how the pcregrep search works
organizations - the list of organizations that modules should belong to, this param should be passed in such a way: ?organizations=ietf&organizations=mef, which means that organizations are ['ietf', 'mef']
inverted_search - true/false string which indicates if the result must contain all modules satisfying the search or all the modules not satisfying the search
case_sensitive - true/false string which indicates if the search must be case-sensitive or not
previous_cursor, cursor- cursors that are needed for the backend to understand which modules are already searched, will be provided by the backend itself, for the first search request they both should be set to 0

response
previous_page, next_page - URLs to the previous and next pages of the same search, the frontend should rely on them, in some edge cases (when all the modules are searched, or the cursor == 0) they can be just empty strings
results - the list of the modules that satisfy the search (can be an empty list as well), for example:

[
    {
            "module-name": "ietf-inet-types",
            "organization": "ietf",
            "revision": "2010-09-24"
    },
    ...
]

the request URL should always be quoted with the utf-8 encoding to prevent inconsistent results, the example of an actual request:
http://localhost/api/yang-search/v2/grep_search?search%3Dtypedef%20dscp%20%7B%5Cn.%2Atype%20uint8%20%7B%5Cn.%2Arange%20%220..63%22%3B%5Cn.%2A%7D%26organizations%3Dietf%3D%26inverted_search%3Dfalse%26case_sensitive%3Dfalse%26previous_cursor%3D0%26cursor%3D0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Priority: Medium
Projects
None yet
Development

No branches or pull requests

3 participants