> For the complete documentation index, see [llms.txt](https://docs.hyper-space.io/hyperspace-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyper-space.io/hyperspace-docs/api-documentation/hyperspace-client/dsl_search.md).

# dsl\_search

The function dsl\_search`(query_schema, size, function_name, collection_name)` runs search queries Iin DSL syntaxt inside a collection.

**Input**

* <mark style="color:purple;">query\_schema</mark> – the DLS query 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
query = {
        "query": {
            "bool": {
                "must": [
                    {"term": {"name": "John"}}
                ]
            }
        }
    }
results = hyperspace_client.dsl_search(query,
                                   size=10,                 
                                   collection_name=collection_name)
```

{% endcode %}
{% endtab %}

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

```java
String queryJson =  "{" +
                    "  \"query\": {" +
                    "    \"bool\": {" +
                    "      \"must\": [" +
                    "        {" +
                    "          \"term\":{" +
                    "            \"name\":\"John\"" +
                    "           }" +
                    "        }" +
                    "      ]" +
                    "    }" +
                    "  }" +
                    "}";
JsonObject query = JsonParser.parseString(queryJson).getAsJsonObject();
Object response = client.dslSearch(collectionName, 10, query));
```

{% endcode %}
{% endtab %}

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

```javascript
const size = 10;
const query = {
        "query": {
            "bool": {
                "must": [
                    {"term": {"name": "John"}}
                ]
            }
        }
};
await hyperspaceClient.search(collectionName, size, query);
```

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

Where <mark style="color:purple;">query\_string</mark> is your query logic, see example below.

{% code lineNumbers="true" %}

```
{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
            {
              "term": {
                "genres": "genres_value"
              }
            },
            {
              "term": {
                "adult": "adult_value"
              }
            },
            {
              "bool": {
                "must_not": [
                  {
                    "term": {
                      "title": "title_value"
                    }
                  }
                ]
              }
            }
          ],
          "should": [
            {
              "range": {
                "rating": {
                  "gt": 7.0
                }
              }
            }
          ]
        }
      },
      "boost_mode": "multiply",
      "boost": 2.0
    }
  }
}Response
```

{% endcode %}

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 }
