# Search Query

## Basic Query format

{% hint style="success" %}
**query:**   *query* includes following options items below for conditional select
{% endhint %}

|  NO | KEY         |   TYPE  | REQUIRED | DESC                                                          |
| :-: | ----------- | :-----: | :------: | ------------------------------------------------------------- |
|  1  | filter      |   list  |    :x:   | filter out within operator                                    |
|  2  | filter\_or  |   list  |    :x:   | filter out within operator                                    |
|  3  | page        |   dict  |    :x:   | set number of selected list to express pages or other reasons |
|  4  | sort        |   dict  |    :x:   | sorting a list with given keys                                |
|  5  | minimal     | boolean |    :x:   | display every item in search or minimize its results          |
|  6  | count\_only | boolean |    :x:   | display only number of items in the list                      |
|  7  | only        |   list  |    :x:   | display only given items in the list                          |
|  8  | keyword     |  string |    :x:   | global search any string                                      |

{% hint style="info" %}
**FILTER:**&#x20;

*filter* performs within **AND**  condition  \
&#x20;:point\_right: \<filter> and \<filter> and \<filter> ...
{% endhint %}

{% hint style="info" %}
**FILTER\_OR:**&#x20;

*filter\_or* performs within **OR**  condition  \
&#x20;:point\_right:  \<filter> or \<filter> or \<filter> ...
{% endhint %}

{% tabs %}
{% tab title="SKELETON" %}

```javascript
{ 
    "query": {
                "filter": [],
                "filter_or": [],  
                "page": {},
                "sort": {},
                "minimal": false,
                "count_only": false,
                "only": []
    }
}
```

{% endtab %}

{% tab title="Filter" %}

```javascript
{
    "query": {
        "filter": [
            {
                "key": "name",
                "value": [
                    "stark",
                    "nick"
                ],
                "operator": "in"
            }
        ]
    }
}
```

{% hint style="warning" %}
**NOTE:** \
\
\&#xNAN;***filter*** and ***filter\_or*** input simultaneously, it performs :point\_right: **`AND`** :point\_left: condition between them.
{% endhint %}

| NO | KEY      | TYPE        |       REQUIRED       | DESC                       |
| -- | -------- | ----------- | :------------------: | -------------------------- |
| 1  | key      | string      | :white\_check\_mark: | any key that to filter out |
| 2  | value    | list or any |          :x:         |                            |
| 3  | operator | string      | :white\_check\_mark: | refer to operator below    |

***Operator refers to*** [***Filter Operators***](/api-reference/common-v1/search-query/filter-options.md)
{% endtab %}

{% tab title="Filter\_or" %}

```javascript
{ 
    "query": {
                "filter_or": [
                    {
                        "key": "name",
                        "value": ["stark", "admin"],
                        "operator": "in"
                    },
                    {
                        "key": "user_id",
                        "value": ["ua-abcdefg"],
                        "operator": "not_in"
                    }
                ]
    }
}
```

{% hint style="warning" %}
**NOTE:** \
\
\&#xNAN;***filter*** and ***filter\_or*** input simultaneously, it performs :point\_right: **`AND`** :point\_left: condition between them.
{% endhint %}

| KEY      | TYPE        |       REQUIRED       | DESC                       |
| -------- | ----------- | :------------------: | -------------------------- |
| key      | string      | :white\_check\_mark: | any key that to filter out |
| value    | list or any |          :x:         |                            |
| operator | string      | :white\_check\_mark: | refer to operator below    |

***Operator refers to*** [***Filter Operators***](/api-reference/common-v1/search-query/filter-options.md)
{% endtab %}

{% tab title="Page" %}

```javascript
{
    "query": {
        "page": {
            "start": 1,
            "limit": 3
        }
    }
}
```

| KEY          | TYPE    | REQUIRED | DESC                        |
| ------------ | ------- | :------: | --------------------------- |
| start        | integer |    :x:   | start number                |
| limit        | integer |    :x:   | number of limit on selected |
| {% endtab %} |         |          |                             |

{% tab title="Sort" %}

```javascript
{
    "query": {
        "sort": {
            "key": "name",
            "desc": true
        }
    }
}
```

| KEY          | TYPE    |       REQUIRED       | DESC                              |
| ------------ | ------- | :------------------: | --------------------------------- |
| key          | string  | :white\_check\_mark: | string sorting priority           |
| desc         | boolean |          :x:         | ascending or descending order Y/N |
| {% endtab %} |         |                      |                                   |

{% tab title="Minimal" %}

```javascript
{
    "query": {
        "minimal": false
    }
}
```

| Key          | TYPE    | Required | description                             |
| ------------ | ------- | :------: | --------------------------------------- |
| minimal      | boolean |    :x:   | displays only minimized summary of list |
| {% endtab %} |         |          |                                         |

{% tab title="Count\_only" %}

```javascript
{
    "query": {
        "count_only": false
    }
}
```

| KEY          | TYPE    | REQUIRED | DESC                                |
| ------------ | ------- | :------: | ----------------------------------- |
| count\_only  | boolean |    :x:   | displays only counts on search list |
| {% endtab %} |         |          |                                     |

{% tab title="Only" %}

```javascript
{
    "query": {
        "only": [
            "name",
            "tags"
        ]
    }
}
```

| KEY          | TYPE | REQUIRED | DESC                                                 |
| ------------ | :--: | :------: | ---------------------------------------------------- |
| only         | list |    :x:   | column keys that user wants to expect on the results |
| {% endtab %} |      |          |                                                      |

{% tab title="Keyword" %}

```javascript
{
    "query": {
        "keyword": "any_string"
    }
}
```

{% endtab %}

{% tab title="Sample" %}

```javascript
{
    "query": {
        "filter": [
            {
                "key": "name",
                "value": [
                    "stark",
                    "nick"
                ],
                "operator": "in"
            }
        ],
        "filter_or": [
            {
                "key": "name",
                "value": [
                    "stark",
                    "admin"
                ],
                "operator": "in"
            },
            {
                "key": "user_id",
                "value": [
                    "ua-abcdefg"
                ],
                "operator": "not_in"
            }
        ],
        "page": {
            "start": 1,
            "limit": 3
        },
        "sort": {
            "key": "name",
            "desc": true
        },
        "minimal": false,
        "count_only": false,
        "only": [
            "name",
            "tag"
        ]
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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://spaceone-dev.gitbook.io/api-reference/common-v1/search-query.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.
