{
  "id": "elasticsearch/invalid-boost-in-query",
  "signature": "QueryShardException: failed to create query: boost must be positive, got [-2.0]",
  "signature_zh": "查询分片异常：创建查询失败：提升值必须为正数，得到[-2.0]",
  "regex": "QueryShardException: failed to create query: boost must be positive, got \\[.*\\]",
  "domain": "elasticsearch",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A negative or zero boost value in a query DSL, such as in a function_score query or term query, violates the requirement that boost must be a positive float.",
  "root_cause_type": "generic",
  "root_cause_zh": "查询DSL中的负值或零提升值（例如在function_score查询或term查询中）违反了提升值必须为正浮点的要求。",
  "versions": [
    {
      "version": "7.17.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.13.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Index-time boost is deprecated and ignored; the error is about query-time boost, not mapping boost",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Negative boost is not supported; use a 'must_not' clause or script_score with negation instead",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Change the boost value to a positive float, e.g., in a function_score query: { \"function_score\": { \"query\": { \"match\": { \"field\": \"value\" } }, \"boost\": 0.5 } }",
      "success_rate": 0.95,
      "how": "Change the boost value to a positive float, e.g., in a function_score query: { \"function_score\": { \"query\": { \"match\": { \"field\": \"value\" } }, \"boost\": 0.5 } }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a script_score query with Math.max(boost, 0.01) to ensure positivity: { \"script_score\": { \"query\": { \"match_all\": {} }, \"script\": { \"source\": \"Math.max(_score, 0.01)\" } } }",
      "success_rate": 0.85,
      "how": "Use a script_score query with Math.max(boost, 0.01) to ensure positivity: { \"script_score\": { \"query\": { \"match_all\": {} }, \"script\": { \"source\": \"Math.max(_score, 0.01)\" } } }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将提升值改为正浮点数，例如在function_score查询中：{ \"function_score\": { \"query\": { \"match\": { \"field\": \"value\" } }, \"boost\": 0.5 } }",
    "使用script_score查询并确保提升值正数：{ \"script_score\": { \"query\": { \"match_all\": {} }, \"script\": { \"source\": \"Math.max(_score, 0.01)\" } } }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}