# 查询分片异常：创建查询失败：提升值必须为正数，得到[-2.0]

- **ID:** `elasticsearch/invalid-boost-in-query`
- **领域:** elasticsearch
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

查询DSL中的负值或零提升值（例如在function_score查询或term查询中）违反了提升值必须为正浮点的要求。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.17.0 | active | — | — |
| 8.10.0 | active | — | — |
| 8.13.0 | active | — | — |

## 解决方案

1. ```
   将提升值改为正浮点数，例如在function_score查询中：{ "function_score": { "query": { "match": { "field": "value" } }, "boost": 0.5 } }
   ```
2. ```
   使用script_score查询并确保提升值正数：{ "script_score": { "query": { "match_all": {} }, "script": { "source": "Math.max(_score, 0.01)" } } }
   ```

## 无效尝试

- **** — Index-time boost is deprecated and ignored; the error is about query-time boost, not mapping boost (70% 失败率)
- **** — Negative boost is not supported; use a 'must_not' clause or script_score with negation instead (85% 失败率)
