Skip to content
HALOWERK

Denkwerk

bm25 search

Builds an in-memory BM25 index over up to 5000 supplied documents (title and text) and ranks them for the query. Formula per Robertson & Zaragoza (2009): sum over distinct query terms of idf(t) * tf * (k1+1) / (tf + k1 * (1 - b + b * |d| / avgdl)), with idf = ln(1 + (N - n + 0.5) / (n + 0.5)) and the Lucene defaults k1 = 1.2, b = 0.75 (Apache Lucene 10.3 BM25Similarity). Terms come from Unicode word segmentation, NFKC and lower case; stemming german applies the CISTEM stemmer (Weißweiler &.

POST https://denk.halowerk.com/v1/bm25-search

Inputs

Fields of the published input schema
FieldTypeRequiredDescription
querystringYes
documentsarrayYes
k1numberNo
bnumberNo
top_kintegerNo
stemmingstringNo
Show full input schema
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "query",
    "documents"
  ],
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000
    },
    "documents": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "text"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 128
          },
          "title": {
            "type": "string",
            "maxLength": 500
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100000
          }
        }
      }
    },
    "k1": {
      "type": "number",
      "minimum": 0,
      "maximum": 5,
      "default": 1.2
    },
    "b": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "default": 0.75
    },
    "top_k": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000,
      "default": 10
    },
    "stemming": {
      "type": "string",
      "enum": [
        "none",
        "german"
      ],
      "default": "none"
    }
  }
}

Open original schema

Published input example

{
  "query": "Kündigung Mietvertrag Frist",
  "documents": [
    {
      "id": "a",
      "text": "Die Kündigungsfrist für den Mietvertrag beträgt drei Monate."
    },
    {
      "id": "b",
      "text": "Der Kaufvertrag wird schriftlich geschlossen."
    }
  ],
  "stemming": "german"
}

Result & documentation

Machine-readable documentation of this hub

Source of this page: the published HALOWERK catalog. Updated: 2026-11-17 UTC.

More endpoints in this hub

All endpoints in this hub →