---
title: "Building a Chatbot for Hacker News and Stack Overflow with LlamaIndex and ClickHouse"
description: "HackBot is a chatbot that answers questions about developer opinions by combining text-to-SQL over the 2021 Stack Overflow survey with vector search over 28m embedded Hacker News comments, both stored in ClickHouse and orchestrated with LlamaIndex, OpenAI and Streamlit."
url: "https://swe.quest/articles/building-a-chatbot-for-hacker-news-and-stack-overflow-with-llamaindex-and-8e7d236d6eb904ee"
canonical: "https://clickhouse.com/blog/building-hackernews-stackoverflow-chatbot-with-llamaindex-and-clickhouse"
source: "ClickHouse"
published: "2024-02-29"
difficulty: "medium"
kind: "How-to"
reading_minutes: 23
tags: ["rag","vector-search","llms","analytics","python"]
---

# Building a Chatbot for Hacker News and Stack Overflow with LlamaIndex and ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-02-29, 23 min read, How-to. Original: [https://clickhouse.com/blog/building-hackernews-stackoverflow-chatbot-with-llamaindex-and-clickhouse](https://clickhouse.com/blog/building-hackernews-stackoverflow-chatbot-with-llamaindex-and-clickhouse)

## Summary

HackBot is a chatbot that answers questions about developer opinions by combining text-to-SQL over the 2021 Stack Overflow survey with vector search over 28m embedded Hacker News comments, both stored in ClickHouse and orchestrated with LlamaIndex, OpenAI and Streamlit. The design routes structured, unstructured and mixed questions through separate query pipelines, with mixed questions using a SQL result to drive a metadata-filtered vector search. Schema choices such as self-descriptive column names and Enum types help the LLM generate correct SQL without extra context. Ordering keys on date, length and score keep filtered vector queries fast.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- retrieval-augmented generation basics
- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- vector embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))

## Keywords

ClickHouse, LlamaIndex, Streamlit, OpenAI, Hacker News, Stack Overflow survey, all-MiniLM-L6-v2

## Related posts

- [Building a RAG pipeline for Google Analytics with ClickHouse and Amazon Bedrock](https://swe.quest/articles/building-a-rag-pipeline-for-google-analytics-with-clickhouse-and-amazon-bedrock-e2945701d51424da.md): ClickHouse · 2023-11-21 · Medium · 26 min read · RAG & retrieval, LLMs, Vector search, Analytics & OLAP, Cloud platforms
  A natural language interface over raw Google Analytics data stored in ClickHouse is built as a multi-step RAG pipeline that generates SQL from user questions using Amazon Bedrock models.
- [Building AI Search on Heroku](https://swe.quest/articles/building-ai-search-on-heroku-fdce052b7ed2fc31.md): Heroku Engineering · 2026-01-29 · Medium · 3 min read · RAG & retrieval, Vector search, PostgreSQL, Search, LLMs
  A reference RAG architecture on Heroku pairs pgvector cosine-similarity search (top 20 chunks) with a cross-encoder reranker (Cohere Rerank 3.5, top 5), so answers come from documents that actually address the query rather than ones that are merely semantically close.
- [Building Data-Aware AI Applications with Heroku AI and LlamaIndex](https://swe.quest/articles/building-data-aware-ai-applications-with-heroku-ai-and-llamaindex-8f85403b0aabecc2.md): Heroku Engineering · 2025-08-19 · Medium · 4 min read · RAG & retrieval, Vector search, PostgreSQL, Python, LLMs
  A RAG stack on Heroku pairs LlamaIndex for ingestion, indexing and retrieval with Heroku Managed Inference (Claude 4 Sonnet via an OpenAI-compatible API), Cohere Embed Multilingual for embeddings, and Heroku Postgres with pgvector as the vector store.
- [Beyond the Menu Tree: How Yelp Built a Smarter Customer Success Chatbot with AI](https://swe.quest/articles/beyond-the-menu-tree-how-yelp-built-a-smarter-customer-success-chatbot-with-ai-ff3ace4643697f19.md): Yelp Engineering · 2026-05-27 · Medium · 7 min read · RAG & retrieval, LLMs, Vector search, System design
  Yelp replaced a menu-tree and fixed-phrase customer support chatbot with an LLM system.
- [AI Functions in ClickHouse: Upgrade your SQL to the AI age](https://swe.quest/articles/ai-functions-in-clickhouse-upgrade-your-sql-to-the-ai-age-11cec6552950f306.md): ClickHouse · 2026-09-11 · Medium · 12 min read · LLMs, SQL, RAG & retrieval, Analytics & OLAP, Cost optimization
  ClickHouse's beta AI Functions call LLM and embedding providers directly from SQL.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
