# search

The function `search(query_schema, size, function_name, collection_name)` runs search queries inside a collection.

**Input**

* <mark style="color:purple;">query\_schema</mark> – Specifies the document for the query schema object.
* <mark style="color:purple;">size</mark> – Specifies the number of results to return.
* <mark style="color:purple;">function\_name</mark> – Specifies the scoring function to be used in the Classic Search query, as described in Step 1, Creating the Scoring Function.
* <mark style="color:purple;">collection\_name</mark> – Specifies the Collection in which to search.
* <mark style="color:purple;">fields (optional)</mark> – Specifies the document fields to be returned with each result.

**Example**&#x20;

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
params= {
         "name": "John"
        }
results = hyperspace_client.search(params,
                                   size=10,                 
                                   collection_name=collection_name
                                   function_name='score_function')
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
int size = 10;
String params= "{" +
    "\"name\": \"John\""+
    "}";
String functionName = "score_function";
await hyperspaceClient.search(collectionName, size, params, functionName);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```python
let size = 10;
let params= {
    "name": "John"
}
let functionName = 'score_function';
await hyperspaceClient.search(collectionName, size, params, functionName);
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response**

A list of candidates, as shown in the example below

{ "candidates": 1, "similarity": \[ { "document\_id": "29", "score": 10.0, "fields": { "FirstSeenTime": 1506116398, "City": "Jakarta" } } ], "took\_ms": 33.625 }


---

# 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.hyper-space.io/hyperspace-docs/api-documentation/hyperspace-client/search.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.
