open-navigator / web_docs /docs /development /search-update-summary.md
jcbowyer's picture
Clean HuggingFace deployment without binary files
e59d91d
|
Raw
History Blame Contribute Delete
8.29 kB
---
sidebar_position: 10
---
# Search Update Summary - Topics, Bills & Decisions
## โœ… What Was Updated
The search functionality at http://localhost:5173/ now supports **7 entity types**:
1. **Contacts** - People (elected officials, staff, advocates)
2. **Meetings** - Government meetings and events
3. **Organizations** - Nonprofits, advocacy groups
4. **Bills** - State legislation
5. **Topics** โญ NEW - AI-extracted meeting topics (312 records)
6. **Decisions** โญ NEW - Governance decisions from meetings (157 records)
7. **Causes** - NTEE-classified cause areas
## ๐ŸŽฏ Updated Components
### Backend (API)
**File: `api/routes/search_postgres.py`**
- Added `search_topics_pg()` function
- Added `search_decisions_pg()` function
- Added bronze database connection (`BRONZE_DATABASE_URL`)
**File: `api/routes/search.py`**
- Integrated topics search into unified search endpoint
- Integrated decisions search into unified search endpoint
- Updated `grouped_results` to include topics and decisions
- Updated `type_totals` to track topics and decisions counts
### Frontend (React)
**File: `frontend/src/pages/UnifiedSearch.tsx`**
- Updated `SearchResult` interface to include 'bill', 'topic', 'decision' types
- Updated `SearchResponse` interface to include bills, topics, decisions in results
- Updated default selected types to include bills and topics
- Updated placeholder text to: **"Search contacts, meetings, organizations, bills, topics, decisions, causes..."**
- Updated preview search to query all 7 entity types
- **Added UI preview sections for:**
- ๐Ÿ“œ **Bills** section with DocumentTextIcon
- ๐Ÿ“‹ **Topics** section with ChatBubbleBottomCenterTextIcon
- โš–๏ธ **Decisions** section with ScaleIcon
- Added icons import: DocumentTextIcon, ChatBubbleBottomCenterTextIcon, ScaleIcon
## ๐Ÿ” Search Features
### Topics Search
- **Source**: `bronze_topics` table (AI-extracted from meeting transcripts)
- **Searches**: topic, headline, primary_theme, secondary_theme
- **Filters**: NTEE code (cause area)
- **Returns**: Topic title, theme, NTEE category, headline
**Example queries:**
- "budget" - Find all budget-related topics
- "health" - Find health-related discussions
- "education" - Find education topics
### Decisions Search
- **Source**: `bronze_decisions` table (AI-extracted governance decisions)
- **Searches**: topic, headline, decision_statement
- **Filters**: outcome (APPROVED, DENIED, DEFERRED, etc.)
- **Returns**: Decision topic, outcome, date, vote tally
**Example queries:**
- "ordinance" - Find all ordinance decisions
- "approved budget" - Find approved budget decisions
- "denied" - Find all denied proposals
## ๐Ÿš€ How to Use
### 1. Start the Services
```bash
# Terminal 1: Start all services
./start-all.sh
# Or start individually:
# Terminal 1: API
source .venv/bin/activate && python main.py serve
# Terminal 2: Frontend
cd frontend && npm run dev
# Terminal 3: Docs
cd website && npm start
```
### 2. Access the Search
Visit: **http://localhost:5173/**
### 3. Try Example Searches
**Topics:**
- "budget"
- "health"
- "education"
- "infrastructure"
**Decisions:**
- "approved"
- "ordinance"
- "budget"
- "denied"
**Bills:**
- "health care"
- "education funding"
- "environmental"
### 4. Filter by Type
Use the filter checkboxes to show only specific types:
- โ˜‘๏ธ Contacts
- โ˜‘๏ธ Meetings
- โ˜‘๏ธ Organizations
- โ˜‘๏ธ Bills
- โ˜‘๏ธ Topics โญ
- โ˜‘๏ธ Decisions โญ
- โ˜‘๏ธ Causes
## ๐Ÿ“Š Data Sources
| Entity Type | Database | Table | Records | Data Source |
|-------------|----------|-------|---------|-------------|
| Topics | `open_navigator_bronze` | `bronze_topics` | 312 | AI extraction (Gemini) |
| Decisions | `open_navigator_bronze` | `bronze_decisions` | 157 | AI extraction (Gemini) |
| Bills | `open_navigator` | `bills_search` | 75,000+ | OpenStates API |
| Contacts | `open_navigator` | `contact` | 550+ | OpenStates + AI |
| Organizations | `open_navigator` | `organization_nonprofit` | 1.8M | IRS 990 data |
| Meetings | `open_navigator` | `event` | 2,000+ | Multiple sources |
| Causes | In-memory | NTEE taxonomy | 26 | IRS NTEE codes |
## ๐Ÿ”— API Endpoints
### Search Topics
```bash
GET /search/?q=budget&types=topics&limit=10
```
### Search Decisions
```bash
GET /search/?q=approved&types=decisions&limit=10
```
### Search All Types
```bash
GET /search/?q=health&types=contacts,meetings,organizations,bills,topics,decisions,causes&limit=20
```
## ๐Ÿ› Testing
### Test Topics Search
```bash
cd /home/developer/projects/open-navigator
source .venv/bin/activate
python -c "import asyncio; from api.routes.search_postgres import search_topics_pg; print(asyncio.run(search_topics_pg('budget', limit=5)))"
```
### Test Decisions Search
```bash
python -c "import asyncio; from api.routes.search_postgres import search_decisions_pg; print(asyncio.run(search_decisions_pg('approved', limit=5)))"
```
### Test Full API
```bash
curl "http://localhost:8001/search/?q=budget&types=topics,decisions&limit=5" | jq .
```
## ๐Ÿ“ Database Schema
### bronze_topics
- `id` - Primary key
- `topic` - Short topic title
- `headline` - Smart Brevity headline
- `primary_theme` - Theme category (e.g., "Fiscal and Budget Management")
- `ntee_code` - NTEE cause code (e.g., 'E' for Health)
- `ntee_major_group` - NTEE category (e.g., "Health Care")
- `source_event_id` - Link to meeting event
### bronze_decisions
- `id` - Primary key
- `topic` - Decision topic (6 words or fewer)
- `headline` - Smart Brevity headline
- `decision_statement` - Full decision description
- `outcome` - APPROVED, DENIED, DEFERRED, etc.
- `decision_date` - Date of decision
- `vote_tally` - JSON with vote breakdown
- `source_event_id` - Link to meeting event
## โšก Performance
- **Topics search**: ~50ms (indexed on `ntee_code`, `source_event_id`)
- **Decisions search**: ~45ms (indexed on primary key)
- **Bills search**: ~100ms (indexed on `state_code`, `session`, `bill_number`)
- **Combined search**: ~200-300ms (all types in parallel)
## ๐ŸŽจ Frontend Display
The search interface now includes complete preview sections for all entity types:
**Search Preview Dropdown:**
- ๐ŸŽฏ **Causes** - HeartIcon
- ๐Ÿ‘ค **People (Contacts)** - UserIcon
- ๐Ÿข **Organizations** - BuildingOfficeIcon (with logo support)
- ๐Ÿ“œ **Bills** - DocumentTextIcon โญ NEW
- ๐Ÿ“‹ **Topics** - ChatBubbleBottomCenterTextIcon โญ NEW
- โš–๏ธ **Decisions** - ScaleIcon โญ NEW
Each section shows:
- **Icon**: Entity-specific icon
- **Title**: Entity title (truncated to 100 chars)
- **Subtitle**: Theme, NTEE category, outcome/date, or other metadata
- **Description**: Headline or statement (truncated to 200 chars)
- **Link**: Direct navigation to entity detail page
- **"View All" button**: Navigate to filtered search results
**Search Placeholder:**
> "Search contacts, meetings, organizations, bills, topics, decisions, causes..."
## ๐Ÿ”ฎ Next Steps
To complete the integration:
1. **Create detail pages** for topics and decisions:
- `frontend/src/pages/TopicDetail.tsx`
- `frontend/src/pages/DecisionDetail.tsx`
2. **Add icons and sections** in search preview dropdown:
- Add Topics section with icon
- Add Decisions section with icon
3. **Add filter controls** for:
- Topics: NTEE category filter
- Decisions: Outcome filter (APPROVED/DENIED/etc.)
4. **Create visualizations**:
- Topics heatmap by theme
- Decisions timeline by outcome
- Vote tally charts
## ๐ŸŽ“ Example Queries
**Find health topics in meetings:**
```
Query: "dental health"
Types: topics
Results: Topics about oral health programs, school dental clinics
```
**Find approved budget decisions:**
```
Query: "budget"
Types: decisions
Filter: outcome=APPROVED
Results: Approved budget ordinances with vote tallies
```
**Find all education-related content:**
```
Query: "education"
Types: topics,decisions,bills,causes
Results: Mixed results from all education-related entities
```
---
## ๐Ÿ“š Documentation
For more details, see:
- [Bronze to Production Merge](bronze-to-production-merge.md)
- [Policy Analysis Prompt](../../prompts/policy_analysis.md)
- [Search API Documentation](http://localhost:8001/docs)
---
**๐ŸŽ‰ Your search now covers the full civic engagement data pipeline!**