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

# Business Search 查询语法

> Business Search 结构化查询参考：and、or、not、equals、in、range 和 text 共 7 个运算符，以及嵌套与文本匹配规则。

Business Search 的结构化查询是一个嵌套 JSON 对象，在 Ludicrous 模式下作为 `query` 属性发送。字段运算符构造条件，逻辑运算符组合条件。

## 结构化查询支持哪些运算符

| 运算符      | 含义                            |
| -------- | ----------------------------- |
| `and`    | 所有子条件都必须匹配                    |
| `or`     | 至少一个子条件匹配                     |
| `not`    | 排除匹配其子条件的记录                   |
| `equals` | 匹配精确的字段值                      |
| `in`     | 匹配所提供列表中的任一值                  |
| `range`  | 使用 `>`、`>=`、`<` 或 `<=` 匹配数值边界 |
| `text`   | 搜索受支持的文本字段                    |

`and`、`or` 和 `not` 以条件为子项，`equals`、`in`、`range` 和 `text` 接收字段名与值。

## 如何组合条件

嵌套逻辑运算符即可构建所需的布尔表达式。以下公司查询搜索位于 US 或 GB 的软件或科技公司，并排除组织类型为 `Educational` 的记录：

```json theme={null}
{
  "and": [
    {
      "or": [
        { "text": { "industry": "software" } },
        { "text": { "industry": "technology" } }
      ]
    },
    { "in": { "headquarters_country_code": ["US", "GB"] } },
    { "not": { "equals": { "organization_type": "Educational" } } }
  ]
}
```

在同一字段上，用 `in` 代替 `or` 加 `equals` 的条件串。它适合国家列表、行业列表和其他枚举值集合。

## 文本匹配如何工作

`text` 条件可以是字符串（如上面的公司示例），也可以是包含 `value` 和 `mode` 的对象。当每个搜索词都必须匹配时使用 `mode: "all"`，这些词不必构成完整短语：

```json theme={null}
{
  "text": {
    "current_title": {
      "value": "machine learning engineer",
      "mode": "all"
    }
  }
}
```

`mode` 接受七个取值，API 会以 HTTP 400 拒绝其他任何取值并列出这七个：

| 模式                    | 行为                      |
| --------------------- | ----------------------- |
| `top-bm25`            | 默认值。按 BM25 排序的部分匹配      |
| `all`                 | 每个搜索词都必须命中              |
| `all-or-top-bm25`     | 先做全词匹配，结果过少时用 BM25 匹配补足 |
| `top-idf`             | 按 IDF 排序的部分匹配           |
| `all-or-top-idf`      | 先做全词匹配，再用 IDF 匹配补足      |
| `any`、`top-bm25-daat` | API 接受，本文不作说明           |

`top-k` 限制文本条件检索的候选记录数量，默认 100。没有任何模式支持精确短语匹配。

`text` 只适用于文本字段。对 `headquarters_country_code` 等有类型字段使用它会返回 HTTP 400，错误信息为 `Operator does not support field type 'string'. Supported types: array<text>, text`。

`equals` 不适用于文本字段。字段接受哪些运算符取决于字段类型：`industry`、`current_title` 等文本类型字段只接受 `text`，对它们使用 `equals` 会返回 HTTP 400，错误信息为 `Operator does not support field type 'text'`。`equals`、`in` 和 `range` 用于 `headquarters_country_code`、`city`、`followers` 等有类型字段。

## 如何表达数值边界

`range` 接收一个字段名以及一到两个比较键。提供两个键表示闭区间：

```json theme={null}
{
  "range": {
    "employees_in_linkedin": { ">=": 50, "<=": 500 }
  }
}
```

提供一个键表示开区间，例如 `{ "followers": { ">=": 1000 } }`。

## 哪些字段可以被搜索

字段名因类目而异，字段接受哪些运算符取决于字段类型。完整列表见[公司搜索](/cn/products/business-search/company-search)和[人物搜索](/cn/products/business-search/people-search)。出现在 `view` 输出中的字段不一定可以搜索：人物的 `connections` 会在 `summary` 中返回，但不能用于 `range` 条件。

当条件被拒绝时，请修正请求，而不要重试同一个请求体。Business Search 会返回 HTTP 400，并在消息中指出字段、运算符以及该运算符支持的类型。参见 [Business Search 错误处理](/cn/products/business-search/error-codes)。

## 常见问题

### 公司搜索和人物搜索的 query 对象一样吗

运算符完全相同，字段名不同。公司类目使用 `industry`、`headquarters_country_code` 和 `linkedin_followers`，人物类目使用 `current_title`、`country_code` 和 `followers`。参见 [公司搜索](/cn/products/business-search/company-search)和 [人物搜索](/cn/products/business-search/people-search)。

### 结构化查询能用于 Instant 或 Smart 模式吗

不能。`ludicrous` 接收结构化对象，`instant` 和 `smart` 接收自然语言字符串。类型不匹配会被以 HTTP 400 拒绝：在 Instant 中传对象会返回 `request: "query" must be a string`，在 Ludicrous 中传字符串会返回 `request: "query" must be of type object`。参见 [什么是 Business Search](/cn/products/business-search/introduction#每种模式有什么作用)。

### 在 view 中添加字段会过滤结果吗

不会。`view` 只选择输出字段。搜索条件写在 `query` 中，两者相互独立。
