BadWord API

Overview

BadWord API is an API for managing Fess bad words (excluding inappropriate suggestion words). You can configure keywords that should not appear in the suggest feature.

Base URL

/api/admin/badword

Endpoint List

Method Path Description
GET/PUT /settings List bad words
GET /setting/{id} Get bad word
POST /setting Create bad word
PUT /setting Update bad word
DELETE /setting/{id} Delete bad word

List Bad Words

Request

GET /api/admin/badword/settings
PUT /api/admin/badword/settings

Parameters

Parameter Type Required Description
size Integer No Number of items per page (default: 20)
page Integer No Page number (starts from 0)

Response

{
  "response": {
    "status": 0,
    "settings": [
      {
        "id": "badword_id_1",
        "suggestWord": "inappropriate_word",
        "targetRole": "",
        "targetLabel": ""
      }
    ],
    "total": 5
  }
}

Get Bad Word

Request

GET /api/admin/badword/setting/{id}

Response

{
  "response": {
    "status": 0,
    "setting": {
      "id": "badword_id_1",
      "suggestWord": "inappropriate_word",
      "targetRole": "",
      "targetLabel": ""
    }
  }
}

Create Bad Word

Request

POST /api/admin/badword/setting
Content-Type: application/json

Request Body

{
  "suggestWord": "spam_keyword",
  "targetRole": "guest",
  "targetLabel": ""
}

Field Description

Field Required Description
suggestWord Yes Keyword to exclude
targetRole No Target role (empty = all roles)
targetLabel No Target label (empty = all labels)

Response

{
  "response": {
    "status": 0,
    "id": "new_badword_id",
    "created": true
  }
}

Update Bad Word

Request

PUT /api/admin/badword/setting
Content-Type: application/json

Request Body

{
  "id": "existing_badword_id",
  "suggestWord": "updated_spam_keyword",
  "targetRole": "guest",
  "targetLabel": "",
  "versionNo": 1
}

Response

{
  "response": {
    "status": 0,
    "id": "existing_badword_id",
    "created": false
  }
}

Delete Bad Word

Request

DELETE /api/admin/badword/setting/{id}

Response

{
  "response": {
    "status": 0,
    "id": "deleted_badword_id",
    "created": false
  }
}

Usage Examples

Exclude Spam Keyword

curl -X POST "http://localhost:8080/api/admin/badword/setting" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "suggestWord": "spam",
       "targetRole": "",
       "targetLabel": ""
     }'

Bad Word for Specific Role

curl -X POST "http://localhost:8080/api/admin/badword/setting" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "suggestWord": "internal",
       "targetRole": "guest",
       "targetLabel": ""
     }'

Reference