Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 8,091 Bytes
a8fb296 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | ---
sidebar_position: 10
---
# Search Update Summary - Topics, Bills & Decisions
## Yes 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:
- Yes Contacts
- Yes Meetings
- Yes Organizations
- Yes Bills
- Yes Topics
- Yes Decisions
- Yes 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!**
|