search_hub

at 5e2a417 Raw

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Config",
  "description": "Application configuration loaded from the TOML config file.\n\nAll config structs derive `schemars::JsonSchema` so the full schema can be printed via `search_hub config-schema`.\n\n# Example\n\n```ignore let cfg = search_hub::config::Config::load(); let engines = cfg.engines.clone(); println!(\"{} engines enabled\", engines.len()); ```",
  "type": "object",
  "properties": {
    "bangs": {
      "description": "User-defined shortcut overrides and additions.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/BangOverride"
      }
    },
    "db_path": {
      "description": "Default bookmark database path.",
      "default": null,
      "type": [
        "string",
        "null"
      ]
    },
    "engines": {
      "description": "Per-engine configuration. Each entry defines an enabled search engine.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/EngineConfig"
      }
    },
    "exclude_urls": {
      "description": "Hostnames to exclude from content fetching.",
      "default": null,
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      }
    },
    "tagging": {
      "description": "Tagging-specific configuration (always present; defaults apply when `[tagging]` is absent).",
      "allOf": [
        {
          "$ref": "#/definitions/TaggingConfig"
        }
      ]
    },
    "web": {
      "description": "Web server configuration (always present; defaults apply when `[web]` is absent).",
      "allOf": [
        {
          "$ref": "#/definitions/WebConfig"
        }
      ]
    }
  },
  "definitions": {
    "BangOverride": {
      "description": "User-defined override or addition to auto-generated shortcuts.",
      "type": "object",
      "required": [
        "trigger"
      ],
      "properties": {
        "enabled": {
          "description": "Set to `false` to suppress an auto-generated shortcut.",
          "default": null,
          "type": [
            "boolean",
            "null"
          ]
        },
        "name": {
          "description": "Optional display name override.",
          "type": [
            "string",
            "null"
          ]
        },
        "trigger": {
          "description": "The trigger keyword (e.g. \"w\" for !w).",
          "type": "string"
        },
        "url": {
          "description": "Optional override URL template with `{}` placeholder.",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "EngineConfig": {
      "description": "Configuration for a single search engine instance.",
      "oneOf": [
        {
          "description": "crates.io registry (public or private)",
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "bang_enabled": {
              "default": null,
              "type": [
                "boolean",
                "null"
              ]
            },
            "bang_url": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "shortcode": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "timeout_secs": {
              "default": null,
              "type": [
                "number",
                "null"
              ],
              "format": "float"
            },
            "type": {
              "type": "string",
              "enum": [
                "crates_io"
              ]
            },
            "url": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        {
          "description": "SearXNG meta-search engine",
          "type": "object",
          "required": [
            "instance",
            "type"
          ],
          "properties": {
            "bang_enabled": {
              "default": null,
              "type": [
                "boolean",
                "null"
              ]
            },
            "bang_url": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "instance": {
              "type": "string"
            },
            "shortcode": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "timeout_secs": {
              "default": null,
              "type": [
                "number",
                "null"
              ],
              "format": "float"
            },
            "type": {
              "type": "string",
              "enum": [
                "searxng"
              ]
            }
          }
        },
        {
          "description": "Wikipedia search (language-specific)",
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "bang_enabled": {
              "default": null,
              "type": [
                "boolean",
                "null"
              ]
            },
            "bang_url": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "lang": {
              "description": "Language code (e.g. \"en\", \"fr\", \"de\"). Defaults to \"en\" if omitted.",
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "shortcode": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "timeout_secs": {
              "default": null,
              "type": [
                "number",
                "null"
              ],
              "format": "float"
            },
            "type": {
              "type": "string",
              "enum": [
                "wikipedia"
              ]
            }
          }
        },
        {
          "description": "MDN Web Docs search (language-specific)",
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "bang_enabled": {
              "default": null,
              "type": [
                "boolean",
                "null"
              ]
            },
            "bang_url": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "locale": {
              "description": "Locale code (e.g. \"en-US\", \"fr\", \"de\"). Defaults to \"en-US\" if omitted.",
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "shortcode": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "timeout_secs": {
              "default": null,
              "type": [
                "number",
                "null"
              ],
              "format": "float"
            },
            "type": {
              "type": "string",
              "enum": [
                "mdn"
              ]
            }
          }
        },
        {
          "description": "Generic HTML-scraped search engine (configurable URL + CSS selector)",
          "type": "object",
          "required": [
            "name",
            "selector",
            "type",
            "url"
          ],
          "properties": {
            "bang_enabled": {
              "default": null,
              "type": [
                "boolean",
                "null"
              ]
            },
            "bang_url": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "name": {
              "description": "Display name for this engine (e.g. \"DuckDuckGo\", \"Stack Overflow\").",
              "type": "string"
            },
            "selector": {
              "description": "CSS selector targeting the result container.",
              "type": "string"
            },
            "shortcode": {
              "default": null,
              "type": [
                "string",
                "null"
              ]
            },
            "timeout_secs": {
              "default": null,
              "type": [
                "number",
                "null"
              ],
              "format": "float"
            },
            "type": {
              "type": "string",
              "enum": [
                "generic"
              ]
            },
            "url": {
              "description": "URL template with `{}` placeholder for the query.",
              "type": "string"
            }
          }
        }
      ]
    },
    "TagDef": {
      "description": "A named tag with positive and negative example texts for semantic similarity.\n\n# Example\n\n```rust use search_hub::tagging::TagDef;\n\nlet tag = TagDef { name: \"rust\".into(), examples: vec![\"serde serialization\".into(), \"tokio async runtime\".into()], negatives: vec![], }; assert_eq!(tag.name, \"rust\"); ```",
      "type": "object",
      "required": [
        "examples",
        "name"
      ],
      "properties": {
        "examples": {
          "description": "Positive example phrases that exemplify this tag.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "name": {
          "description": "The tag label (e.g. \"rust\", \"web\").",
          "type": "string"
        },
        "negatives": {
          "description": "Negative example phrases that should NOT match this tag.",
          "default": [],
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "TaggingConfig": {
      "description": "Tagging-specific configuration options.",
      "type": "object",
      "properties": {
        "enabled": {
          "description": "Whether auto-tagging is enabled (default: false).",
          "default": false,
          "type": [
            "boolean",
            "null"
          ]
        },
        "max_tags": {
          "description": "Max tags to assign per bookmark (default: 5).",
          "default": 5,
          "type": [
            "integer",
            "null"
          ],
          "format": "uint",
          "minimum": 0.0
        },
        "onnx_model": {
          "description": "ONNX embedding model name (default: \"BGESmallENV15\").",
          "default": "BGESmallENV15",
          "type": [
            "string",
            "null"
          ]
        },
        "override_tags": {
          "description": "If true, use only user-provided [[tags]] and ignore built-in tag defaults.",
          "default": false,
          "type": [
            "boolean",
            "null"
          ]
        },
        "reranker_enabled": {
          "description": "Whether to use the cross-encoder reranker (default: true).",
          "default": false,
          "type": [
            "boolean",
            "null"
          ]
        },
        "reranker_model": {
          "description": "Cross-encoder reranker model code (default: \"rozgo/bge-reranker-v2-m3\").",
          "default": "rozgo/bge-reranker-v2-m3",
          "type": [
            "string",
            "null"
          ]
        },
        "tag_weight": {
          "description": "Weight multiplier for the tags column in FTS5 search ranking (default: 3.0).",
          "default": 3.0,
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        },
        "tags": {
          "description": "Custom tag definitions. If non-empty and `override_tags` is false, these replace the hardcoded defaults (nested under `[tagging]` in TOML).",
          "type": "array",
          "items": {
            "$ref": "#/definitions/TagDef"
          }
        },
        "threshold": {
          "description": "Tagging threshold (0.0 to 1.0, default: 0.6).",
          "default": 0.35,
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        },
        "truncation": {
          "description": "Max characters to use from page content for tagging (default: 4000).",
          "default": 4000,
          "type": [
            "integer",
            "null"
          ],
          "format": "uint",
          "minimum": 0.0
        }
      }
    },
    "WebConfig": {
      "description": "Web server configuration options.",
      "type": "object",
      "properties": {
        "bind_address": {
          "description": "Server bind address (default: \"127.0.0.1\").",
          "default": null,
          "type": [
            "string",
            "null"
          ]
        },
        "page_size": {
          "description": "Results per page (default: 20).",
          "default": null,
          "type": [
            "integer",
            "null"
          ],
          "format": "uint",
          "minimum": 0.0
        },
        "workers": {
          "description": "Actix worker threads (default: 2).",
          "default": null,
          "type": [
            "integer",
            "null"
          ],
          "format": "uint",
          "minimum": 0.0
        }
      }
    }
  }
}