Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: mongodb

RSS

Lite Version MongoDB Full-Text Search

This article primarily explores technical solutions for implementing Chinese full-text search in the MongoDB Community Edition. Since the Community Edition does not natively support Chinese word segmentation engines, the author proposes a custom solution based on NestJS, Mongoose, and the `@node-rs/jieba` segmentation library. The article details the use of Docker to deploy a MongoDB environment with replica set support, ensuring service stability through a health check mechanism. In terms of architecture, the project is organized using a Monorepo pattern. By listening to database change events, Chinese text is automatically segmented and written back to the collection upon data insertion, thereby constructing a full-text index that supports Chinese retrieval. This solution not only implements basic query functionality but also covers multi-entity detection, value object handling, and a comparative analysis with Elasticsearch, providing developers with a complete technical practice reference for achieving efficient Chinese search at low cost in constrained environments.

Views 175
docker fulltext mongodb nest node search study work

pyenv Notes

This article documents the practice and experience of managing Python versions using `pyenv` in an Ubuntu 24.04 environment. The motivation was that while building the MongoDB source code, the official documentation required Python 3.10+, but the system's default version 3.12.3 caused the build to fail due to API incompatibility. Since modifying the source code was not an option, the decision was made to use `pyenv` to specifically install a 3.10.x version. The article details the process of automatically installing `pyenv` via a `curl` script and configuring `~/.bashrc`. It also highlights the extremely unfriendly user experience of `pyenv`, specifically noting the lack of progress indicators, minimal information feedback, and the absence of interactive options during installation and build processes. Additionally, addressing the issue where `pip` and `poetry` command-line mirror source configurations failed, the author successfully configured the Tsinghua University or Tencent Cloud mirror addresses to accelerate dependency package downloads by manually creating and editing the `~/.pip/pip.conf` and `~/.config/pypoetry/config.toml` files. The article emphasizes the importance of not arbitrarily modifying the system's pre-installed Python environment and repeatedly warns developers to avoid writing programs that lack user feedback and interactivity. It suggests that readers refer to this configuration method in similar scenarios to avoid potential pitfalls.

Views 96
daily env install mongodb pyenv study

mongo-listener

This article introduces the design approach for building a data change monitoring service based on MongoDB oplog. Addressing the absence of binlog in MongoDB, it utilizes the watch API to achieve data heterogeneity and evaluates the pros and cons of embedding parsing logic within the database versus introducing third-party components. Architecturally, it adopts an independent microservice to simplify high-availability guarantees, with the core pipeline flowing from MongoDB through a Redis buffer before being delivered to Kafka. The introduction of Redis as a buffer aims to mitigate the risk of memory overflow caused by the disparity between production and consumption rates, while leveraging its persistence features to prevent message loss. The system implements checkpoint resumption by persisting the resumeToken and handles message duplication after restarts using a deduplication list. Regarding ordering, it flexibly selects ordered or unordered delivery based on business requirements and discusses batch sending to optimize performance. At the deployment level, it emphasizes secure configuration for Kafka and local execution of Redis. In summary, the current design focuses on single-node high availability, while multi-node consistency and complex query compensation mechanisms still require further refinement.

Views 109
High Availability MongoDB Change Streams kafka mongodb node redis