> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sixtyfour.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Filter Search

> Search people or companies with structured filters, discover fields and values, and page through results.

> [card] [API Reference](https://docs.sixtyfour.ai/api-reference/search/search-query.md)
>
> See the full request/response schema and parameters in the API Reference.

> [!WARNING]
>
> `POST /search/start-filter-search` is deprecated and returns a `Deprecation` header. Use `POST /search/query`, which takes the same filters and returns the same response.

## Core concepts

| Term | Description |
| - | - |
| `simple_filters` | The primary query format. Mongo-style operators such as `$eq`, `$in`, `$gte`, `$match`, and `$and`. |
| `filters` | A JSON query DSL for cases `simple_filters` can't express. Validated against the limits in `GET /search/filter-capabilities`. |
| `query` | A natural language query, as an alternative to filters. The response echoes the structured `parsed_query` it was turned into. |
| `exclude_entity_ids`, `exclude_list_ids` | Leave specific people or companies out of results. See [Search Exclusions](https://docs.sixtyfour.ai/api-reference/search/search-exclusions.md). |
| `fields` | Field metadata from `GET /search/filter-capabilities`: which fields are queryable, sortable, rangeable, and support top values. |
| `filter_snippet` | A ready-to-use exact-match `filters` clause returned with each top value. |
| `cursor` | Pagination token returned as `next_cursor`. Send it as the only field to get the next page. See [cursor rules](https://docs.sixtyfour.ai/api-reference/legacy/search-results.md#paginate-with-cursors). |

## Recommended flow

```mermaid theme={null}
flowchart TD
    A["GET<br/>/search/filter-capabilities"] -->|"Discover valid fields & limits"| B["POST<br/>/search/filter-field-values"]
    B -->|"Inspect top values for a field"| C["POST<br/>/search/query"]
    C --> D{has_more?}
    D -->|"true, send {cursor} only"| C
    D -->|false| E[Done]
```

## Simple filters

### Top-level shape

```json theme={null}
{
  "simple_filters": {
    "hq_country_iso2": { "$eq": "US" },
    "employees_count": { "$gte": 100, "$lte": 5000 }
  }
}
```

### Supported operators

The capabilities response exposes supported simple-query operators in `simple_query_operators`.

| Operator | Value | Description |
| - | - | - |
| `$eq`, `$ne` | Scalar | Exact match or exact exclusion. |
| `$gt`, `$gte`, `$lt`, `$lte` | Number or date | Numeric or date range comparisons. The field must be `rangeable`. |
| `$in`, `$nin` | Array of 1 to 25 scalars | Match or exclude multiple exact values. |
| `$exists` | Boolean | Match records where a field is present or absent. |
| `$match`, `$phrase` | String, up to 200 characters | Text matching for one text or keyword field. On a text field, `$match` needs any word of the value and `$phrase` needs every word. |
| `$and`, `$or`, `$nor` | Array of 1 to 25 filter objects | Logical composition. |
| `$not` | Filter object | Negate a condition. |
| `$elemMatch` | Object keyed by full field paths | Match nested array elements. See [Nested array matching](#nested-array-matching). |
| `$search` | Object with `query`, `fields`, and optional `type` and `operator` | Full-text search across up to 25 queryable fields. `query` is up to 200 characters. |
| `$sort` | Object, or array of single-field objects, with up to 2 fields | Sort results in search requests. Each direction is `asc`, `desc`, `1`, `-1`, or `{"order": "desc", "missing": "_last"}`. |
| `$limit` | Integer from 1 to 5,000 | Limit result count in search requests. |

### Nested array matching

`$elemMatch` queries fields inside nested arrays. It is keyed on the field's `nested_path` from capabilities, which is not always the outermost array: `currentCompanies.company.companyId` has `nested_path: "currentCompanies"`, and `currentCompanies.positions.title` has `nested_path: "currentCompanies.positions"`, so `$elemMatch` on `currentCompanies` cannot reference a positions field.

> [!WARNING]
>
> Inside `$elemMatch`, use the field's full dotted path. A relative path with a dot, such as `company.companyId`, returns a `400`, although its message suggests a relative path.

In people mode, conditions inside one `$elemMatch` on `currentCompanies`, `previousCompanies`, `educations`, or a `positions` path hold on the same entry. On any other path, each condition can match a different entry.

Find people currently at a specific company by numeric LinkedIn company ID, which company results expose as `source_id`:

```json theme={null}
{
  "mode": "people",
  "simple_filters": {
    "currentCompanies": {
      "$elemMatch": {
        "currentCompanies.company.companyId": 1234567
      }
    }
  }
}
```

### Excluding results

There are two ways to exclude records:

* Use `simple_filters` operators such as `$ne`, `$nin`, `$not`, and `$nor` to exclude records that match field conditions.
* Use the top-level exclusion fields, `exclude_entity_ids` or `exclude_list_ids`, to suppress specific people or companies by ID. See [Search Exclusions](https://docs.sixtyfour.ai/api-reference/search/search-exclusions.md) for identifier formats, saved lists, and limits.

ID-based exclusions apply after matching, so a page can hold fewer rows than `page_size`.

### Query examples

Find a company by website domain:

```json theme={null}
{
  "mode": "company",
  "simple_filters": {
    "website_domain": "acme.com"
  }
}
```

Exclude companies in specific industries:

```json theme={null}
{
  "mode": "company",
  "simple_filters": {
    "industry": { "$nin": ["Staffing", "Recruiting"] }
  }
}
```

Exclude records that match any disallowed condition:

```json theme={null}
{
  "mode": "company",
  "simple_filters": {
    "$nor": [
      { "industry": { "$eq": "Staffing" } },
      { "categories_and_keywords": { "$match": "recruiting" } }
    ]
  }
}
```

Find US-based companies sorted by employee count descending, capped to 8 total results:

```json theme={null}
{
  "mode": "company",
  "simple_filters": {
    "hq_country_iso2": { "$eq": "US" },
    "$sort": [{ "employees_count": "desc" }],
    "$limit": 8
  }
}
```

Find Canadian companies that have raised any amount and mention technology in categories or keywords:

```json theme={null}
{
  "mode": "company",
  "simple_filters": {
    "$and": [
      { "hq_country_iso2": { "$eq": "CA" } },
      { "last_funding_round_amount_raised": { "$gt": 0 } },
      { "categories_and_keywords": { "$match": "technology" } }
    ]
  }
}
```

Search several fields at once with `$search`:

```json theme={null}
{
  "mode": "company",
  "simple_filters": {
    "$search": {
      "query": "cloud security",
      "fields": ["description", "categories_and_keywords"],
      "operator": "and"
    }
  }
}
```

Find people by current job title:

```json theme={null}
{
  "mode": "people",
  "simple_filters": {
    "currentCompanies.positions.title": { "$match": "engineering manager" }
  }
}
```

Fields with a doubly nested path accept `$elemMatch` on the inner nested path:

```json theme={null}
{
  "mode": "people",
  "simple_filters": {
    "currentCompanies.positions": {
      "$elemMatch": {
        "currentCompanies.positions.title": { "$match": "engineering manager" }
      }
    }
  }
}
```

## DSL filters

### Top-level shape

```json theme={null}
{
  "filters": {
    "query": {"match_all": {}},
    "sort": [],
    "size": 100
  }
}
```

### Supported query clauses

| Clause | Description |
| - | - |
| `bool` | Combine conditions with `must`, `filter`, `should`, and `must_not`. |
| `term` | Exact-match query for a single value. |
| `terms` | Exact-match query for multiple values. |
| `range` | Numeric or date range with `gt`, `gte`, `lt`, `lte`. |
| `exists` | Match records where a field is present. |
| `match` | Text match. On a text field, any word of the value, or every word with `"operator": "and"`. |
| `match_phrase` | Text match. On a text field, every word of the value. |
| `multi_match` | Search the same value across multiple fields. |
| `nested` | Query nested arrays and nested objects. Conditions inside it match as they do in [`$elemMatch`](#nested-array-matching). |
| `match_all` | Match all records in the selected mode. |

### Query examples

Range filter:

```json theme={null}
{
  "range": {
    "employees_count": {
      "gte": 100,
      "lte": 5000
    }
  }
}
```

Multi-field full-text search:

```json theme={null}
{
  "multi_match": {
    "query": "cloud security",
    "fields": [
      "description",
      "categories_and_keywords"
    ],
    "type": "best_fields",
    "operator": "and"
  }
}
```

Nested query:

```json theme={null}
{
  "nested": {
    "path": "technologies_used",
    "query": {
      "term": {
        "technologies_used.technology": "Kubernetes"
      }
    }
  }
}
```

Exclude with `must_not`:

```json theme={null}
{
  "bool": {
    "must": [
      { "term": { "hq_country_iso2": "US" } }
    ],
    "must_not": [
      { "term": { "industry": "Staffing" } }
    ]
  }
}
```

## Filter capabilities

```http theme={null}
GET https://api.sixtyfour.ai/search/filter-capabilities
```

Returns every field you can query, sort, range, or get top values for, plus the `simple_filters` operators and DSL limits.

> [!TIP]
>
> Call this first to discover what is filterable. Only fields in `fields`, and their `.keyword` and `.raw` forms, can be queried.

### Query parameters

| Parameter | Type | Description |
| - | - | - |
| `mode` | string | `people` or `company`. Defaults to `company`. |

### Example request

```bash theme={null}
curl -X GET "https://api.sixtyfour.ai/search/filter-capabilities?mode=company" \
  -H "x-api-key: YOUR_API_KEY"
```

### Response shape

| Field | Type | Description |
| - | - | - |
| `mode` | string | The mode these capabilities describe. |
| `fields` | array | Every queryable field in the selected mode. See [Field entry](#field-entry). |
| `nested_paths` | string\[] | Top-level paths that hold nested arrays or objects. |
| `simple_query_operators` | string\[] | Operators allowed in `simple_filters` (`$eq`, `$in`, `$gte`, `$match`, etc.). |
| `limits` | object | Hard limits applied to `filters` queries. See [Limits](#limits). |
| `price_per_result_credits` | number | Credits per result that `POST /search/query` charges this credential, or `0` when your searches are not charged. See [Credit Costs](https://docs.sixtyfour.ai/guides/credits-and-pricing.md#search). |
| `cache_ttl_seconds` | integer | Seconds you can cache this response client-side. |
| `mapping_hash` | string | Hash of the field list. Changes when fields are added or removed. |

### Limits

| Limit | Description |
| - | - |
| `max_query_depth` | Maximum nesting depth of `filters.query`. |
| `max_clause_count` | Maximum total clauses across a `filters` query. |
| `max_terms_per_clause` | Maximum values in a single `terms` or `$in` clause. |
| `max_sort_clauses` | Maximum sort fields. |
| `max_string_length` | Maximum length of any string value in a query. |

### Field entry

Each item in `fields` describes one queryable field.

| Property | Type | Description |
| - | - | - |
| `field` | string | The field path to use in `simple_filters` and `filters`. |
| `field_type` | string | The field's data type: `keyword`, `text`, `long`, `double`, `date`, or `boolean`. |
| `value_type` | string | The type to send. Matches `field_type`, except for text fields with an exact-match form, which expose `keyword`. |
| `nested_path` | string \| null | The field's nested path, or `null`. It is the key of `$elemMatch` and the `path` of a `nested` clause. |
| `queryable` | boolean | Whether the field is valid in `simple_filters` and `filters`. |
| `sortable` | boolean | Whether the field can be used in `$sort` or DSL `sort`. |
| `rangeable` | boolean | Whether the field accepts `$gt`, `$gte`, `$lt`, `$lte`, or DSL `range`. |
| `sort_field` | string \| null | The path to sort on when it differs from `field`, such as `company_name.keyword`. |
| `aggregation_field` | string \| null | Path used for top-value aggregation in `POST /search/filter-field-values`. |
| `supports_top_values` | boolean | Whether the field can be passed to `POST /search/filter-field-values`. |
| `supports_exact_filter_snippet` | boolean | Whether a `filter_snippet` is returned alongside top values for this field. |
| `preferred_for_exact_match` | boolean | Whether the field suits exact-match queries. `false` on text fields. |

To list fields by property, filter the capabilities response, for example with `jq '.fields[] | select(.supports_top_values) | .field'`.

### Example response

Trimmed to two representative fields, a top-level keyword and a nested numeric.

```json theme={null}
{
  "mode": "company",
  "fields": [
    {
      "field": "website_domain",
      "field_type": "keyword",
      "value_type": "keyword",
      "nested_path": null,
      "queryable": true,
      "sortable": false,
      "rangeable": false,
      "sort_field": null,
      "aggregation_field": "website_domain",
      "supports_top_values": true,
      "supports_exact_filter_snippet": true,
      "preferred_for_exact_match": true
    },
    {
      "field": "last_funding_round.amount_raised",
      "field_type": "long",
      "value_type": "long",
      "nested_path": "last_funding_round",
      "queryable": true,
      "sortable": true,
      "rangeable": true,
      "sort_field": null,
      "aggregation_field": "last_funding_round.amount_raised",
      "supports_top_values": true,
      "supports_exact_filter_snippet": true,
      "preferred_for_exact_match": true
    }
  ],
  "nested_paths": [
    "company_locations_full",
    "funding_rounds",
    "last_funding_round",
    "technologies_used"
  ],
  "simple_query_operators": [
    "$eq", "$ne", "$gt", "$gte", "$lt", "$lte",
    "$in", "$nin", "$exists", "$match", "$phrase",
    "$and", "$or", "$not", "$nor", "$elemMatch",
    "$search", "$sort", "$limit"
  ],
  "limits": {
    "max_query_depth": 12,
    "max_clause_count": 200,
    "max_terms_per_clause": 25,
    "max_sort_clauses": 2,
    "max_string_length": 200
  },
  "cache_ttl_seconds": 600,
  "mapping_hash": "ea1a21b4ccf1fef56bc102f80a7a59bb4b7ff5777d70d267236c357205e2eb99"
}
```

## Field values

```http theme={null}
POST https://api.sixtyfour.ai/search/filter-field-values
```

Returns the most common values of one field, ranked by record count, optionally scoped by a query.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `field` | string | required | Field path. Must have `supports_top_values: true` in capabilities. |
| `mode` | string | `company` | `people` or `company`. |
| `top_k` | integer | `25` | Number of values to return, from 1 to 100. |
| `simple_filters` or `filters` | object | None | Optional scope. Send at most one. |

### Scoped query

A scope takes no `filters.sort`, `filters.size`, `simple_filters.$sort`, or `simple_filters.$limit`.

> [!TIP]
>
> A high `top_k` lists the valid values of an enum-like field before filtering.

### Example request

Global:

```bash theme={null}
curl -X POST "https://api.sixtyfour.ai/search/filter-field-values" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode": "company", "field": "hq_country_iso2", "top_k": 4}'
```

Scoped:

```json theme={null}
{
  "mode": "company",
  "field": "industry",
  "top_k": 4,
  "simple_filters": {
    "hq_country_iso2": { "$eq": "US" },
    "employees_count": { "$gte": 200, "$lte": 5000 },
    "ownership_status": { "$eq": "private" }
  }
}
```

### Response fields

| Field | Description |
| - | - |
| `field`, `canonical_field`, `aggregation_field` | The requested field and the paths used to count it. |
| `nested_path` | Set for fields inside nested arrays. |
| `value_type` | Type of the returned values (`keyword`, `long`, etc.). |
| `total_scoped_documents` | Records matched by the scope. |
| `values[]` | Top values, each with `value`, `count`, `percent_of_scope` (0 to 1), and `filter_snippet`. |
| `supports_top_values`, `supports_exact_filter_snippet`, `preferred_for_exact_match` | Same meaning as in [Field entry](#field-entry). |

### Nested fields

For nested fields such as `technologies_used.technology`, counts are record counts, and each `filter_snippet` is wrapped in a `nested` clause, ready to use in `filters`.

## Search query

```http theme={null}
POST https://api.sixtyfour.ai/search/query
```

Runs a paginated search and returns the first page.

### Request

| Parameter | Type | Default | Description |
| - | - | - | - |
| `simple_filters` | object | None | Mongo-style filters. See [Simple filters](#simple-filters). |
| `filters` | object | None | DSL filters. See [DSL filters](#dsl-filters). |
| `query` | string | None | Natural language query, for people or companies. |
| `parsed_query` | object | None | Structured query echoed by a previous response. |
| `search_id` | string | None | Re-run a previous search, including deep and lookalike searches. See [Replay a saved search](https://docs.sixtyfour.ai/api-reference/legacy/search-results.md#replay-a-saved-search). |
| `mode` | string | `company` | `people` or `company`. Inferred from `search_id` and `query` when omitted. |
| `page_size` | integer | `10` | Rows per page, from 1 to 100. |
| `max_results` | integer | `1000` | Total rows across all pages, up to your ceiling from [`GET /search/limits`](https://docs.sixtyfour.ai/api-reference/legacy/search-results#search-limits). |
| `output_shape` | string | `raw` | `raw` returns each record as stored. `workflow` returns the flattened lead or company rows used by workflows and [CSV exports](https://docs.sixtyfour.ai/api-reference/legacy/search-results.md#csv-columns). |
| `from_offset` | integer | None | Company mode only: start at this row offset (0 to 10,000) for page-numbered navigation. A non-zero offset returns no cursor and is not saved, so its `search_id` cannot be replayed. |
| `exclude_entity_ids` | string\[] | None | IDs to leave out (max 1,000). |
| `exclude_list_ids` | string\[] | None | Saved exclusion lists to apply. |
| `exclude_public_ids` | string\[] | None | Deprecated. Use `exclude_entity_ids`. |
| `location_expansion_enabled` | boolean | `true` | Widen the location in a `query` to related place names. |
| `query_label` | string | None | Label shown for this search in the web app's search history. Does not affect results. |
| `persist_history` | boolean | `true` | `false` does not save the search, so its `search_id` cannot be replayed or exported. |
| `cursor` | string | None | `next_cursor` from the previous page. Send it alone. |

### Request flow

1. First request: send exactly one of `simple_filters`, `filters`, `query`, `parsed_query`, or `search_id`, plus any options above.
2. Next page: send only `{"cursor": "..."}`. Mode, page size, output shape, and exclusions carry over.

See [Paginate with cursors](https://docs.sixtyfour.ai/api-reference/legacy/search-results.md#paginate-with-cursors) for every cursor rule.

### Effective result cap

The smallest of `max_results`, `simple_filters.$limit`, and `filters.size` applies. The response reports it as `max_results`, with `remaining_results` left after each page.

### Response fields

For every response field, see [Search Results → Query response](https://docs.sixtyfour.ai/api-reference/legacy/search-results.md#query-response).

### Example request

Fresh search:

```bash theme={null}
curl -X POST "https://api.sixtyfour.ai/search/query" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "company",
    "simple_filters": {
      "hq_country_iso2": { "$eq": "US" },
      "employees_count": { "$gte": 100, "$lte": 5000 }
    }
  }'
```

Exclude specific people with `exclude_entity_ids`:

```json theme={null}
{
  "mode": "people",
  "parsed_query": {
    "jobTitleExperience": {
      "titles": ["VP Engineering", "Head of Engineering"],
      "searchBoth": false
    }
  },
  "exclude_entity_ids": ["saarthshah", "https://www.linkedin.com/in/saarthshah"]
}
```

For identifier formats, saved lists, and limits, see [Search Exclusions](https://docs.sixtyfour.ai/api-reference/search/search-exclusions.md).

Re-run a previous search:

```json theme={null}
{
  "search_id": "e3b0c442-98fc-1c14-9afb-f4c8996fb924"
}
```

Next page:

```json theme={null}
{
  "cursor": "eyJpZCI6I..."
}
```

### Photo and logo URLs

People rows carry image URLs that need no credentials, so they can be embedded directly in an `<img>` tag, CRM record, or spreadsheet cell.

| Field | Contains |
| - | - |
| `logoUrl` | The person's profile photo URL. Use it exactly as returned, including its query string. Empty or `null` when the person has no photo. |
| `currentCompanies[].company.logo` in `raw_source`, `currentCompanyLogo` in workflow rows and CSV exports | The employer's LinkedIn logo. Empty when no company logo is available. |

When `logoUrl` holds a bare 32-character key instead of a URL, the photo is at `https://api.sixtyfour.ai/v1/media/profiles/{key}`. These URLs do not expire. See [Rate Limits](https://docs.sixtyfour.ai/api-reference/rate-limits.md#media) and [Handling Errors](https://docs.sixtyfour.ai/api-reference/errors.md).

## Export search results

Export results from any search as a CSV. See [Export Search Results](https://docs.sixtyfour.ai/api-reference/legacy/search-results.md#export-search-results) for the full endpoint reference.

## Example usage

The following examples walk through the full recommended flow: discover valid fields, inspect top values for one field, then paginate through results.

```bash cURL theme={null}
API_KEY="YOUR_API_KEY"
BASE_URL="https://api.sixtyfour.ai"

# 1. Get filter capabilities to discover valid fields
curl -s "$BASE_URL/search/filter-capabilities" \
  -H "x-api-key: $API_KEY" \
  | jq '[.fields[] | select(.queryable) | .field] | .[0:5]'

# 2. Inspect top values for a field to build a simple filter
TOP_COUNTRY=$(curl -s -X POST "$BASE_URL/search/filter-field-values" \
  -H "x-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode": "company", "field": "hq_country_iso2", "top_k": 4}' \
  | jq -r '.values[0].value')
echo "Top country: $TOP_COUNTRY"

# 3. Run the paginated filter search, following cursors until has_more is false
CURSOR=""
while true; do
  if [ -z "$CURSOR" ]; then
    PAYLOAD=$(jq -nc --arg c "$TOP_COUNTRY" \
      '{mode:"company", simple_filters:{hq_country_iso2:{"$eq":$c}, employees_count:{"$gte":100}}}')
  else
    PAYLOAD=$(jq -nc --arg cur "$CURSOR" '{cursor:$cur}')
  fi

  RESP=$(curl -s -X POST "$BASE_URL/search/query" \
    -H "x-api-key: $API_KEY" \
    -H "Content-Type: application/json" \
    -d "$PAYLOAD")

  echo "$RESP" | jq -r '"Page \(.page_number), \(.page_count) rows"'

  HAS_MORE=$(echo "$RESP" | jq -r '.has_more')
  [ "$HAS_MORE" != "true" ] && break
  CURSOR=$(echo "$RESP" | jq -r '.next_cursor')
done
```

```python Python theme={null}
import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.sixtyfour.ai"
headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}

# 1. Get filter capabilities to discover valid fields
caps = requests.get(
    f"{BASE_URL}/search/filter-capabilities",
    headers=headers,
).json()
queryable_fields = [f["field"] for f in caps["fields"] if f["queryable"]][:5]
print(f"Available queryable fields: {queryable_fields}")
print(f"Supported simple operators: {caps['simple_query_operators']}")

# 2. Inspect top values for a field to build a simple filter
values_resp = requests.post(
    f"{BASE_URL}/search/filter-field-values",
    headers=headers,
    json={"mode": "company", "field": "hq_country_iso2", "top_k": 4},
).json()

top_country = values_resp["values"][0]["value"]
print(f"Top country: {values_resp['values'][0]['value']}")

# 3. Run the paginated filter search using simple_filters
all_results = []
cursor = None

while True:
    if cursor:
        payload = {"cursor": cursor}
    else:
        payload = {
            "mode": "company",
            "simple_filters": {
                "hq_country_iso2": {"$eq": top_country},
                "employees_count": {"$gte": 100},
            },
        }

    resp = requests.post(
        f"{BASE_URL}/search/query",
        headers=headers,
        json=payload,
    ).json()

    all_results.extend(resp["results"])
    print(f"Page {resp['page_number']}, {resp['page_count']} rows")

    if not resp["has_more"]:
        break

    cursor = resp["next_cursor"]

print(f"Total rows fetched: {len(all_results)}")
```

```javascript JavaScript theme={null}
const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://api.sixtyfour.ai";
const headers = { "x-api-key": API_KEY, "Content-Type": "application/json" };

// 1. Get filter capabilities to discover valid fields
const capsResp = await fetch(`${BASE_URL}/search/filter-capabilities`, { headers });
const caps = await capsResp.json();
const queryableFields = caps.fields.filter(f => f.queryable).slice(0, 5).map(f => f.field);
console.log("Available queryable fields:", queryableFields);
console.log("Supported simple operators:", caps.simple_query_operators);

// 2. Inspect top values for a field to build a simple filter
const valuesResp = await fetch(`${BASE_URL}/search/filter-field-values`, {
  method: "POST",
  headers,
  body: JSON.stringify({ mode: "company", field: "hq_country_iso2", top_k: 4 }),
});
const valuesData = await valuesResp.json();

const topCountry = valuesData.values[0].value;
console.log("Top country:", valuesData.values[0].value);

// 3. Run the paginated filter search using simple_filters
const allResults = [];
let cursor = null;

while (true) {
  const payload = cursor
    ? { cursor }
    : {
        mode: "company",
        simple_filters: {
          hq_country_iso2: { $eq: topCountry },
          employees_count: { $gte: 100 },
        },
      };

  const resp = await fetch(`${BASE_URL}/search/query`, {
    method: "POST",
    headers,
    body: JSON.stringify(payload),
  });
  const data = await resp.json();

  allResults.push(...data.results);
  console.log(`Page ${data.page_number}, ${data.page_count} rows`);

  if (!data.has_more) break;
  cursor = data.next_cursor;
}

console.log(`Total rows fetched: ${allResults.length}`);
```

## Rate limits

For per-endpoint limits, see [Rate Limits](https://docs.sixtyfour.ai/api-reference/rate-limits.md#search).

## Pricing

See [Credit Costs](https://docs.sixtyfour.ai/guides/credits-and-pricing.md) for more information.

## Related

* [Batch Processing](https://docs.sixtyfour.ai/guides/batch-processing.md)
* [Async Jobs](https://docs.sixtyfour.ai/api-reference/async-jobs.md)
* [Handling Errors](https://docs.sixtyfour.ai/api-reference/errors.md)
* [Credit Costs](https://docs.sixtyfour.ai/guides/credits-and-pricing.md)

> [!NOTE]
>
> For new integrations, see [Filter Search](https://docs.sixtyfour.ai/api-reference/search/filter-search.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.