# How to Set Up Hister in Multiuser Mode: Complete Configuration Guide

> Learn how to set up Hister in multiuser mode with this complete configuration guide. Enable multiuser by starting the server with a flag or environment variable and create administrators to manage access.

- Repository: [Adam Tauber/hister](https://github.com/asciimoo/hister)
- Tags: how-to-guide
- Published: 2026-08-27

---

**To set up Hister in multiuser mode, start the server with the `--multiuser` flag or `HISTER_MULTIUSER=1` environment variable, create at least one administrator using `hister users add --admin`, and use `--global` or `--user-id` flags to control document visibility across isolated user namespaces.**

The `asciimoo/hister` search engine supports both single-user and multi-user deployments. In multiuser mode, Hister stores data with per-user namespace isolation while allowing administrators to expose documents globally. This configuration requires specific server flags and administrative commands to manage access control properly.

## Enable Multiuser Mode on the Server

Multiuser activation happens at the server level through either a command-line flag or environment variable. When enabled, Hister namespaces all indexed data by user ID and enforces authentication checks on every request.

Pass the `--multiuser` flag directly to the serve command:

```bash
hister serve --multiuser

```

Alternatively, set the `HISTER_MULTIUSER` environment variable before starting the process:

```bash
HISTER_MULTIUSER=1 hister serve

```

The flag definition and propagation logic reside in **[hister.go](https://github.com/asciimoo/hister/blob/master/hister.go)**, where the server initialization reads this setting and passes it to the underlying model layer to enable per-user data isolation.

## Create Administrator Accounts

Only administrators can import or index documents that are visible to all users or assign documents to specific users. Regular users cannot access global visibility flags.

Create an admin user with the **users** sub-command:

```bash
hister users add --admin --name alice

```

This command prompts for a password and sets the `IsAdmin` field to `true` in the user model. The CLI implementation lives in **[cmd/users.go](https://github.com/asciimoo/hister/blob/master/cmd/users.go)**, while the `User` struct definition—including the `IsAdmin` boolean—resides in **[server/model/user.go](https://github.com/asciimoo/hister/blob/master/server/model/user.go)**.

## Control Document Visibility During Import

Administrators use two exclusive flags to determine document scope when importing or indexing content:

- **`--global`**: Stores documents in a shared namespace accessible to all users
- **`--user-id <id>`**: Stores documents under a specific user's private namespace

These flags appear in **[cmd/import_export.go](https://github.com/asciimoo/hister/blob/master/cmd/import_export.go)** (lines 293-294) and **[cmd/index.go](https://github.com/asciimoo/hister/blob/master/cmd/index.go)** (lines 409-410). Both flags require administrative privileges.

Import a document for all users:

```bash
hister import --global shared-documentation.pdf

```

Import a document for a specific user only (requires knowing the user's numeric ID):

```bash
hister import --user-id 42 private-notes.md

```

## Regular User Access Patterns

Non-administrative users interact with Hister using standard client commands without special flags. The client automatically attaches authentication tokens to each request, and the server resolves permissions through the session layer.

When a regular user runs `hister search` or `hister history`, the client sends their credentials to the server, which validates access against the per-user namespaces defined in **[server/model/session.go](https://github.com/asciimoo/hister/blob/master/server/model/session.go)**. Users see only their own documents plus any global documents imported by administrators.

## Complete Multiuser Setup Example

The following workflow demonstrates a full deployment: starting the server, creating users, and managing document access controls.

```bash

# Start the server in multiuser mode in the background

HISTER_MULTIUSER=1 hister serve &

# Create an administrator account (required for global operations)

hister users add --admin --name adminuser

# Create a regular user

hister users add --name bob

# As admin: import a document visible to all users

hister import --global company-handbook.pdf

# As admin: import a document for user "bob" only (assuming user ID 2)

hister import --user-id 2 bob-confidential.md

# As "bob": search across personal and global documents

hister search "confidential"

```

## Summary

- **Activate multiuser mode** using the `--multiuser` flag or `HISTER_MULTIUSER=1` environment variable when starting `hister serve`
- **Create administrators** via `hister users add --admin` to enable global document management
- **Control visibility** with `--global` for universal access or `--user-id` for specific user assignment during import operations
- **Regular users** automatically authenticate via tokens and access only their own data plus global documents
- **Core logic** spans [`hister.go`](https://github.com/asciimoo/hister/blob/main/hister.go), [`cmd/users.go`](https://github.com/asciimoo/hister/blob/main/cmd/users.go), [`server/model/user.go`](https://github.com/asciimoo/hister/blob/main/server/model/user.go), and [`server/model/session.go`](https://github.com/asciimoo/hister/blob/main/server/model/session.go)

## Frequently Asked Questions

### How do I switch Hister from single-user to multiuser mode?

Stop the current server instance, then restart it with the `--multiuser` flag or set `HISTER_MULTIUSER=1` in your environment. The server logic in [`hister.go`](https://github.com/asciimoo/hister/blob/main/hister.go) detects this flag and initializes the database with per-user namespace support. Existing data imported in single-user mode may require re-indexing under specific user IDs to restore access in multiuser mode.

### Who can import documents for all users to see?

Only administrators with the `IsAdmin` flag set to `true` in the `User` model can use the `--global` flag during import. This restriction is enforced in [`cmd/import_export.go`](https://github.com/asciimoo/hister/blob/main/cmd/import_export.go) and [`cmd/index.go`](https://github.com/asciimoo/hister/blob/main/cmd/index.go), where the CLI checks administrative privileges before processing global scope requests. Regular users attempting to use `--global` receive a permission error.

### How does Hister isolate data between users?

Hister implements namespace isolation in the model layer, where every document record includes a user ID reference. When multiuser mode is active, the server queries in [`server/model/session.go`](https://github.com/asciimoo/hister/blob/main/server/model/session.go) automatically filter results to match the requesting user's ID or include globally flagged documents. Administrators bypass these filters but must explicitly specify target users with `--user-id` when not using `--global`.

### Can I assign existing documents to a different user?

Yes, administrators can re-import documents using the `--user-id` flag to assign them to specific user namespaces. The import commands in [`cmd/import_export.go`](https://github.com/asciimoo/hister/blob/main/cmd/import_export.go) process the `--user-id` parameter at lines 293-294, creating new records under the specified user ID. There is no direct "move" command; you must re-index or re-import the content with the target user specified.