@@ -130,6 +130,7 @@ Quick links:
130130- [ PostgreSQL + pgvector App] ( ./examples/pgvector-app/ ) - Code search
131131- [ Qdrant Integration App] ( ./examples/qdrant-app/ ) - Document retrieval
132132- [ RAG Application] ( ./examples/rag-app/ ) - Full RAG system
133+ - [ PageIndex App] ( ./examples/pageindex-app/ ) - Structured document retrieval
133134
134135## Contributing
135136
@@ -280,3 +281,161 @@ func main() {
280281
281282
282283```
284+
285+ ---
286+
287+ ## 🎯 Use Case Decision Guide
288+
289+ ** Get direct answers without learning — Let AI decide for you**
290+
291+ > 📖 ** [ 中文版 (Chinese Version) →] ( ./doc/USE_CASE_GUIDE_ZH.md ) **
292+
293+ ### Scenario 1️⃣: Semantic Search & Personalization
294+
295+ ** Use Vector Database (pgvector / Qdrant)**
296+
297+ ```
298+ Applicable Use Cases:
299+ ✅ Product recommendations ("Users who bought A also liked...")
300+ ✅ Code search ("Find similar function implementations")
301+ ✅ Customer service ("Find similar historical tickets")
302+ ✅ Content recommendations ("Similar articles, videos")
303+ ✅ Image search ("Find similar images")
304+
305+ Characteristics:
306+ - Fragmented data (each record independent)
307+ - Requires similarity matching
308+ - No clear structure
309+
310+ Example:
311+ sqlxb.Of(&Product{}).
312+ VectorSearch("embedding", userVector, 20).
313+ Eq("category", "electronics")
314+ ```
315+
316+ ---
317+
318+ ### Scenario 2️⃣: Structured Long Document Analysis
319+
320+ ** Use PageIndex**
321+
322+ ```
323+ Applicable Use Cases:
324+ ✅ Financial report analysis ("How is financial stability in 2024?")
325+ ✅ Legal contract retrieval ("Chapter 3 breach of contract terms")
326+ ✅ Technical manual queries ("Which page contains installation steps?")
327+ ✅ Academic paper reading ("Methodology section content")
328+ ✅ Policy document analysis ("Specific provisions in Section 2.3")
329+
330+ Characteristics:
331+ - Long documents (50+ pages)
332+ - Clear chapter structure
333+ - Context preservation required
334+
335+ Example:
336+ sqlxb.Of(&PageIndexNode{}).
337+ Eq("doc_id", docID).
338+ Like("title", "Financial Stability").
339+ Eq("level", 1)
340+ ```
341+
342+ ---
343+
344+ ### Scenario 3️⃣: Hybrid Retrieval (Structure + Semantics)
345+
346+ ** Use PageIndex + Vector Database**
347+
348+ ```
349+ Applicable Use Cases:
350+ ✅ Research report Q&A ("Investment advice for tech sector")
351+ ✅ Knowledge base retrieval (need both structure and semantics)
352+ ✅ Medical literature analysis ("Treatment plan related chapters")
353+ ✅ Patent search ("Patents with similar technical solutions")
354+
355+ Characteristics:
356+ - Both structured and semantic needs
357+ - Long documents + precise matching requirements
358+
359+ Example:
360+ // Step 1: PageIndex locates chapter
361+ sqlxb.Of(&PageIndexNode{}).
362+ Like("title", "Investment Advice").
363+ Eq("level", 2)
364+
365+ // Step 2: Vector search within chapter
366+ sqlxb.Of(&DocumentChunk{}).
367+ VectorSearch("embedding", queryVector, 10).
368+ Gte("page", chapterStartPage).
369+ Lte("page", chapterEndPage)
370+ ```
371+
372+ ---
373+
374+ ### Scenario 4️⃣: Traditional Business Data
375+
376+ ** Use Standard SQL (No Vector/PageIndex needed)**
377+
378+ ```
379+ Applicable Use Cases:
380+ ✅ User management ("Find users over 18")
381+ ✅ Order queries ("Orders in January 2024")
382+ ✅ Inventory management ("Products with low stock")
383+ ✅ Statistical reports ("Sales by region")
384+
385+ Characteristics:
386+ - Structured data
387+ - Exact condition matching
388+ - No semantic understanding needed
389+
390+ Example:
391+ sqlxb.Of(&User{}).
392+ Gte("age", 18).
393+ Eq("status", "active").
394+ Paged(...)
395+ ```
396+
397+ ---
398+
399+ ## 🤔 Quick Decision Tree
400+
401+ ```
402+ Your data is...
403+
404+ ├─ Fragmented (products, users, code snippets)
405+ │ └─ Need "similarity" matching?
406+ │ ├─ Yes → Vector Database ✅
407+ │ └─ No → Standard SQL ✅
408+ │
409+ └─ Long documents (reports, manuals, contracts)
410+ └─ Has clear chapter structure?
411+ ├─ Yes → PageIndex ✅
412+ │ └─ Also need semantic matching?
413+ │ └─ Yes → PageIndex + Vector ✅
414+ └─ No → Traditional RAG (chunking + vector) ✅
415+ ```
416+
417+ ---
418+
419+ ## 💡 Core Principles
420+
421+ ```
422+ Don't debate technology choices — Look at data characteristics:
423+
424+ 1️⃣ Fragmented data + need similarity
425+ → Vector Database
426+
427+ 2️⃣ Long documents + structured + need chapter location
428+ → PageIndex
429+
430+ 3️⃣ Long documents + unstructured + need semantics
431+ → Traditional RAG (chunking + vector)
432+
433+ 4️⃣ Structured data + exact matching
434+ → Standard SQL
435+
436+ 5️⃣ Complex scenarios
437+ → Hybrid approach
438+ ```
439+
440+ ** sqlxb supports all scenarios — One API for everything!** ✅
441+
0 commit comments