# Wildcard Search

### **Overview**

Wildcard Search allows retrieving multiple key-value pairs stored under a common hierarchical structure. In this case, keys are organized such that a `context_entity_id` can contain multiple `context_id`s, and each `context_id` can have multiple `memory_id`s. This method enables fetching all associated data efficiently.

***

Refer below structure to understand

```
├── user_uuid               #Always Needed
│   └── context_entity_id   #Always Needed
│       └── context_id
│           └── memory_id
```

So, basic idea is that you if you want to fetch all context\_id keep it none in memory\_context object and if you want to fetch all memory\_id keep it none in memory\_context.

### **Search by `context_entity_id` only:**

```python
memory_context = {"context_entity_id": "entity1"}
results = memorylake.short_memory_read(user_uuid="user123", memory_context=memory_context)
print(results)
```

**Example Output:**

```json
{
    "user123:entity1:context1:memory1": {
        "query_text": "Example query",
        "response_text": "Example response",
        "entities": [
            {
                "time": "2023-01-01T12:00:00",
                "memory_id": "memory1",
                "context_id": "context1",
                "memory_quality": 1
            }
        ],
        "metadata": {
            "context_entity_id": "entity1",
            "user_uuid": "user123"
        }
    }
}
```

### **Search by `context_entity_id` and `context_id`:**

```python
memory_context = {
    "context_entity_id": "entity1",
    "context_id": "context1"
}
results = memorylake.short_memory_read(user_uuid="user123", memory_context=memory_context)
print(results)
```

**Example Output:**

```json
{
    "user123:entity1:context1:memory1": {
        "query_text": "Example query",
        "response_text": "Example response",
        "entities": [
            {
                "time": "2023-01-01T12:00:00",
                "memory_id": "memory1",
                "context_id": "context1",
                "memory_quality": 1
            }
        ],
        "metadata": {
            "context_entity_id": "entity1",
            "user_uuid": "user123"
        }
    },
    "user123:entity1:context1:memory2": {
        "query_text": "Another query",
        "response_text": "Another response",
        "entities": [
            {
                "time": "2023-01-02T12:00:00",
                "memory_id": "memory2",
                "context_id": "context1",
                "memory_quality": 2
            }
        ],
        "metadata": {
            "context_entity_id": "entity1",
            "user_uuid": "user123"
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groclake.ai/lakes/agent-management-and-deployment/memorylake/editor-4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
