> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Give BettaFish a first batch of Xiaohongshu and Douyin research samples

> Check the BettaFish database connection, map sourced Xiaohongshu and Douyin sample records, and verify InsightEngine read-back.

If a BettaFish report is missing Xiaohongshu and Douyin, first check whether **InsightEngine can read sample records from the database InsightEngine connects to**. Fetch one relevant public item from each platform with BeatAPI, import the two items into a test database using your installed release's schema, then run the read-only `MediaCrawlerDB` check below. For a report on coffee-machine cleaning, use one Xiaohongshu note and one Douyin video.

## Identify the database read by InsightEngine

Check `DB_HOST`, `DB_PORT`, `DB_NAME` and `DB_DIALECT` in the BettaFish runtime. Initialize a test database with the same release's setup, then check that the four tables below exist. For a Docker deployment, verify the connection from inside the application container. The `INSIGHT_ENGINE_*` settings configure the model, not the database connection.

| Goal                           | Tables read by InsightEngine           |
| ------------------------------ | -------------------------------------- |
| Xiaohongshu notes and comments | `xhs_note`, `xhs_note_comment`         |
| Douyin videos and comments     | `douyin_aweme`, `douyin_aweme_comment` |

If a table is absent, check the release and the initialization. If a table already has rows, search for a short phrase from a known title with no date range first, then add the date filter.

## Prepare one note and one video

Use [Xiaohongshu search and detail](/guides/xiaohongshu-notes-research) and [Douyin search and comments](/guides/douyin-python-research) to select one cleaning-related result from each platform. Keep the real item ID, original URL, input keyword, request ID and saved response. Reuse data you already have. Import the content rows first, and add selected comments after the content rows read back.

| Target         | Mapping                                                                                                                                                               |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `xhs_note`     | Keep the note ID, title, returned description, verified `note_url` and `source_keyword`. The date query uses milliseconds in `time`.                                  |
| `douyin_aweme` | Keep the video ID, available title or description, verified `aweme_url` and `source_keyword`. Confirm the source unit before writing milliseconds into `create_time`. |
| Comment tables | Retain each comment ID, text and the real parent post ID. Store the parent comment for replies. Track missing like counts separately from measured zeros.             |

Map the fields from the BeatAPI action you actually ran. When a source is only a search excerpt, label the source as a search excerpt in your source manifest next to the request ID. Check the required columns, length limits and unique keys in the target release before running your own importer against the test database. Upsert by the actual platform object ID, and keep reviewer decisions. Confirm the comment foreign keys against the installed schema.

## Verify a read-back

Run the read-only check below in BettaFish's Python environment. Replace the sample `topic` with a short phrase that actually appears in the saved title or description, and run the check without a date range first.

```python
from InsightEngine.tools.search import MediaCrawlerDB

source = MediaCrawlerDB()
for platform in ("xhs", "douyin"):
    result = source.search_topic_on_platform(platform=platform, topic="清洗", limit=5)
    print(platform, result.results_count, result.error_message)
    for item in result.results[:2]:
        print(item.source_table, item.title_or_content, item.url, item.publish_time)
```

Suppose the note title contains “odor after cleaning” and the video description contains “cleaning the water tank.” Search with a short phrase confirmed in each record. Check that the note comes from `xhs_note` and the video from `douyin_aweme`, and that each URL and date matches the saved source. Once both items appear, generate a report and check one citation. If an item is missing from the report, check the report's search term, date range and platform selection.

Use the imported item's ID and URL to find the step where the item dropped out; the ID and URL also rule out a different record with the same title.

| What you can see                                            | Where to look next                                                                                             |
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| No row for the imported ID in the test database             | Check the import result, destination database and ID                                                           |
| The row exists, but InsightEngine cannot find the phrase    | Check the runtime log, database connection and dialect                                                         |
| The query finds the item until you add dates                | Check the millisecond timestamp, runtime timezone and date boundaries                                          |
| InsightEngine finds the item, but the report omits the item | Check which platform, keywords and dates the report used, then whether the report selected the item's citation |

Reuse the saved samples while diagnosing. Fetching new samples costs data requests and generating another report costs model usage; count the two separately. See [BeatAPI pricing](https://beatapi.io/pricing).

[BettaFish setup and configuration](https://github.com/666ghj/BettaFish/blob/main/README-EN.md) · [InsightEngine query implementation](https://github.com/666ghj/BettaFish/blob/main/InsightEngine/tools/search.py)