# Search

**LIBSAFE Go** provides a user-friendly, easy to use web interface for searching alongside a full API for Query DSL (Domain Specific Language) based on JSON to define queries, that supports the [ElasticSearch syntax](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) to search for items.

This guide is just an introduction to the platform's capabilities for you to get familiar with them.

Here you can find:

* How to search using the management interface
* How to do basic search using the API

## Search using the Management Interface

In order to get to the search interface, you must sign in to the platform's management interface and go to Content Search:

<figure><img src="/files/2fPodEZtxRLnQtexXm2B" alt=""><figcaption></figcaption></figure>

Once here, you will notice that there is the option to do either a basic search or an advanced search.

<figure><img src="/files/q11lL2LiGTYnoToOdgzn" alt=""><figcaption></figcaption></figure>

Let's take a look at the basic search first.

### Basic search

<figure><img src="/files/nhAWyN7k0rY51Of0yOXm" alt=""><figcaption></figcaption></figure>

(1) Introduce your query here. It could simply be a word or it could be a metadata-based query if you start typing any metadata field.

<figure><img src="/files/KKgkGZTWwz7Bky1UmjTV" alt=""><figcaption></figcaption></figure>

(2) You can also make an advanced query by selecting the {;} symbol:

<figure><img src="/files/WyuFnkWEFM10wuVPRtYV" alt=""><figcaption></figcaption></figure>

(3) With these options you can restrict the types of data that the platform is going to search in.

<figure><img src="/files/bQpJnfa7quWMsMZqIDwk" alt=""><figcaption></figcaption></figure>

* **Metadata**, for searching in the item metadata
* **File content**, for searching in the item content (full text in a PDF for instance), for the indexed documents
* **Embedded metadata**, for searching in the item's embedded metadata (EXIF metadata for images, headers for PDF files, etc.)
* **File name and path**, for searching based on the item name.

(4) You can restrict your search to a particular archive node or group of containers.

(5) You can restrict your results to only files or only folders.

(6) You can filter based on content tags.

(7) You can filter by file format (if the content is characterized).

You will see your results in (8).

In (9) you will be able to arrange your results depending on different parameters.

<figure><img src="/files/DxPfx7lI9Nmxv66Brkmc" alt=""><figcaption></figcaption></figure>

And (10) is an example of a search made inside a file's content.

### Advanced search

The advanced search option allows you to do more complex queries in an easier, user-friendly way, by using fields and operators. This includes the nesting option of AND and OR, and adding as many rules to your query as you wish.

Unlike a basic search, which may rely on more simpler keywords, an advanced search allows users to apply filters such as exact phrases, date ranges, file types, and exclusions. These additional options help narrow down search results, making it easier to locate precise information quickly, especially useful for complex topics or detailed research needs.

<figure><img src="/files/o8OxOx6M2cGwxXjhWLjH" alt=""><figcaption></figcaption></figure>

(1) Here we have the logical operators AND and OR. These will allow users to define logical operators between search conditions. By default, AND is selected, meaning all specified conditions must be met for search results to appear.

(2) The "Search in" dropdown will allow users to specify the database, table or field in which they want to search. There is many different options; these are just some of them:

<figure><img src="/files/KPszQe1hXnKVKTAOi4dM" alt=""><figcaption></figcaption></figure>

(3) "Add rule" will add a new search condition to further define the query, while (4), "Add group", allows the user to add a nested group of conditions, combining multiple rules with either AND or OR logic.

(5) In "Fields to show in search results", the user will be able to specify which fields they want to display in the search results.

(6) The "Save this query" button lets users save their specific query, and those will be then found in (7).

Here we have an example of a saved query where we have also added some fields to show in the results:

<figure><img src="/files/20hq03ws1przC12Tvtqg" alt=""><figcaption></figcaption></figure>

As you can see, users are able to download the search results as a CSV file, and they are also able to go directly to their file as well as download it.

## Search using the API

{% hint style="info" %}
API examples here are just illustrative. Check the [API documentation](/libsafe-go/developers-guide/using-the-api.md) for additional information and all available methods.
{% endhint %}

1. Sign in to the platform's Management Interface
2. Obtain your API key selecting your name, then **Access Methods** and then follow one of the following methods:

### Search by container

To get a list of every item in the container with all properties use this method:

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

```bash
curl --re quest POST \
  --url "$your_platform_url/api/file/elastic" \
  --header "Content-Type: application/json" \
  --header "authorization: Bearer $your_platform_api_key" \
  --data '{
    "must": [
        {
            "term": {
                "container_id": 3
            }
        }
    ]
}'
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Use:

* **url**: Your platform address
* **header**: Your API Token (add Bearer prefix)
* **container\_id**: The id of the container to list.&#x20;
  {% endhint %}

You can also request the file list of more than one data container with a single query:

```bash
curl --request POST \
  --url "$your_platform_url/api/file/elastic" \
  --header "Content-Type: application/json" \
  --header "authorization: Bearer $your_platform_api_key" \
  --data '{
    "must": [
        {
            "terms": {
                "container_id": [
                    1,
                    2
                ]
            }
        }
    ]
}'
```

### File name search

{% hint style="warning" %}
When users are uploading a file to the platform, search results may not show the new file for a while. Consider this in your code when you are uploading and immediately after the upload you need to search for the uploaded file.
{% endhint %}

{% hint style="info" %}
This section is just an introduction. Many operators and properties are available for search. Make sure you read [Advanced API file search](/libsafe-go/developers-guide/using-the-api.md).
{% endhint %}

To get a list of every item in the container with all properties, use this method:

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

```bash
curl --request GET  --url "$your_platform_url/api/file" \
       --header "Content-Type: application/json" \
       --header "authorization: Bearer $your_platform_api_key" \
       --data '{
          "conditions": [
              {
                  "container_id": 185
              }
                        ],
          "limit": 100,
          "offset": 0
      }'
```

{% endtab %}
{% endtabs %}

Or if you are looking for all files in container 185, with a size larger than 702 bytes and characterized as a PDF 1.5 (PRONOM fmt/19), you can use:

```
curl --request GET  --url "$your_platform_url/api/file" \
       --header "Content-Type: application/json" \
       --header "authorization: Bearer $your_platform_api_key" \
       --data '{
          "conditions": [
              {
                  "container_id": 185
              },
              {
                  "size": {
                      "operator": "gt",
                      "value": 702
                  }
              },
              {
                  "type": "FILE"
              },
              {
                  "format": "fmt\/19"
              }
          ],
          "limit": 100,
          "offset": 0
      }'
```

### Metadata search

{% hint style="warning" %}
When users are updating metadata for an object, search results may not show the updated element for a while. Consider this in your code when you are updating the metadata and immediately after the edit you need to search for it.
{% endhint %}

It is possible to search for any of the metadata associated to your items (item metadata, item embedded metadata -if available-, file hash, etc.). It is also possible to create complex queries combining multiple query types into one, and to use wildcards:

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

```bash
curl --request POST \
  --url "$your_platform_url/api/file/elastic" \
  --header "Content-Type: application/json" \
  --header "authorization: Bearer $your_platform_api_key" \
  --data '{
    "must": [
        {
            "nested": {
                "path": "metadata",
                "query": {
                    "simple_query_string": {
                        "analyze_wildcard": true,
                        "fields": [
                            "metadata.author"
                        ],
                        "query": "albert*",
                        "default_operator": "and"
                    }
                }
            }
        }
    ]
}'
```

{% 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://docs.libnova.com/libsafe-go/get-started/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.
