dice icon indicating copy to clipboard operation
dice copied to clipboard

Implement API to serve Playground Search requests

Open lucifercr07 opened this issue 1 year ago • 17 comments

Description

DiceDB Playground is an interactive platform that allows users to experiment with DiceDB commands in a live environment, similar to the Go Playground. Users will be able to submit and execute commands directly through a web interface. The initial implementation will focus on enabling users to search for and trigger commands.
For more details about DiceDB playground you can check here.

Implement an API endpoint that allows users to search for DiceDB commands using a query parameter. The API should return a list of commands that match the search query along with relevant metadata, including syntax, description, and documentation links. The primary use case is to enable users to easily discover and learn how to use DiceDB commands in the Playground.

Note: Implementation will be part of DiceDB playground backend repo.

API Details

Request

  • URL:
    GET /search

  • Query Parameters:

    • q: The search term to look for in command names. Supports wildcard matching (*).
  • Example Request: GET /search?q=SET*

Response

  • Content-Type: application/json
  • Status Codes:
    • 200 OK: The request was successful and returns search results.
    • 400 Bad Request: Invalid query or missing query parameter.

Example Response

{
    "total": 2,
    "results": [
        {
            "title": "<b>SET</b>",
            "syntax": "SET key value [NX | XX] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL ]"
            "body": "The SET command in DiceDB is used to set the value of a key. If the key already holds a value, it is overwritten, regardless of its type. This is one of the most fundamental operations in DiceDB as it allows for both creating and updating key-value pairs.",
            "url": "https://dicedb-docs.netlify.app/commands/set/"
        },
        {
            "title": "<b>SETBIT</b>",
            "syntax": "SETBIT key offset value"
            "body": "The SETBIT command in DiceDB is used to set or clear the bit at a specified offset in the string value stored at a given key. This command is particularly useful for bitwise operations and can be used to implement various data structures and algorithms efficiently.",
            "url": "https://dicedb.io/docs/latest/commands/setbit"
        }
    ]
}

Tasks

1. Implement Search API

  • Create an API endpoint /search that accepts the query parameter q.
  • Support wildcard (*) queries for partial matches.
  • Return a list of matching commands with highlighted titles (<b> tags for matched portions).
  • Create the metadata for commands, can be a static struct with all command details.
  • Include command metadata such as title, syntax, body, and URL in the response.

2. Validation

  • Ensure proper error handling for invalid queries (e.g., missing q parameter).
  • Other validations like valid queries, edge cases (e.g., no matches, wildcard searches) etc.

lucifercr07 avatar Sep 26 '24 12:09 lucifercr07

Can you please assign this to me

tanbirali avatar Sep 26 '24 12:09 tanbirali

@tanbirali assigned, thanks for contributing. Please let me know if any other details required.

lucifercr07 avatar Sep 26 '24 13:09 lucifercr07

hey @tanbirali let me know if if can help in this

rishavvajpayee avatar Sep 26 '24 14:09 rishavvajpayee

@tanbirali please fix the changes according to the issue description.

lucifercr07 avatar Sep 28 '24 17:09 lucifercr07

Hello @tanbirali,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

arpitbbhayani avatar Oct 03 '24 14:10 arpitbbhayani

hey if required i can take this up. @arpitbbhayani @lucifercr07 . i already worked on the /search on the playground-web side so i have a context to this.

rishavvajpayee avatar Oct 03 '24 14:10 rishavvajpayee

I have submitted a PR that intends to resolve this issue This is the PR https://github.com/DiceDB/playground-mono/pull/14 I have made the changes requested

tanbirali avatar Oct 04 '24 01:10 tanbirali

Hello @tanbirali,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

arpitbbhayani avatar Oct 09 '24 02:10 arpitbbhayani

I have added the unit test and asked @lucifercr07 for a review

tanbirali avatar Oct 18 '24 09:10 tanbirali

@lucifercr07, This issue is holding up the implementation of Issue 732.

harsha-mangena avatar Oct 22 '24 15:10 harsha-mangena

@harsha-mangena would you like to pick up https://github.com/DiceDB/dice/issues/728 has been on hold from some time.

lucifercr07 avatar Oct 22 '24 16:10 lucifercr07

@lucifercr07, Sure.

harsha-mangena avatar Oct 22 '24 17:10 harsha-mangena

@harsha-mangena please let me know if any help is required.

lucifercr07 avatar Oct 22 '24 17:10 lucifercr07

Sure. Thanks Much.

harsha-mangena avatar Oct 22 '24 17:10 harsha-mangena

Sorry for holding you guys for so long, I tried from my side probably wasn't ready enough solve this problem

tanbirali avatar Oct 22 '24 17:10 tanbirali

@tanbirali it's fine, you can co-ordinate with @harsha-mangena on this, let me know if you guys need any help.

lucifercr07 avatar Oct 22 '24 17:10 lucifercr07

Hi @tanbirali @harsha-mangena are you still working on this issue?

tarun-29 avatar Dec 01 '24 17:12 tarun-29