A full-text search application for NASA's Astronomy Picture of the Day (APOD) archive. This application provides a modern interface to search through thousands of astronomy pictures and their descriptions.
- Full-Text Search: Search through titles and explanations of NASA's astronomy pictures
- Advanced Search Capabilities:
- Exact phrase matching for titles
- Fuzzy matching for typo tolerance
- Relevance-based sorting
- Year-based Filtering: Filter results by year with aggregated counts
- Responsive Grid Display: View results in a clean, organized table format
- Real-time Search: Search results update as you type
- Server-side Pagination: Efficient loading of large datasets
- Frontend: Next.js with React
- UI Components: Material-UI (MUI)
- Search Engine: Elasticsearch
- Language: TypeScript
- Package Manager: pnpm
- Node.js (v18 or higher)
- pnpm
- Elasticsearch (v8.x)
- Docker (optional, for running Elasticsearch)
-
Clone the repository
git clone https://github.com/hamidfarmani/nasa-full-text-search.git cd nasa-full-text-search
-
Install dependencies
pnpm install
-
Start Elasticsearch
Make sure Elasticsearch is running on
http://localhost:9200
If using Docker:
docker run -d --name elasticsearch -p 9200:9200 -e "discovery.type=single-node" elasticsearch:8.x
-
Load the data
pnpm run load-data
-
Start the development server
pnpm dev
- Searches across title and explanation fields
- Title matches are boosted for higher relevance
- Exact phrase matching for titles
- Fuzzy matching for typo tolerance
- Minimum match threshold for better quality results
- Year-based filtering using Elasticsearch aggregations
- Real-time counts of items per year
- Combines with text search
- Results are sorted by relevance when searching
- Chronological sorting (newest first) when not searching
The application includes a data loading script that:
- Creates the Elasticsearch index with proper mappings
- Loads APOD data in chunks to prevent overwhelming the server
- Includes error handling and retry logic
- Shows progress during loading
The application uses a custom Elasticsearch mapping that includes:
- Text fields with standard analyzer for better search
- Date fields with proper formatting
- Runtime fields for year extraction
- Keyword fields for exact matching
- Custom analyzers for improved search quality
pnpm dev
: Start development serverpnpm build
: Build for productionpnpm start
: Start production serverpnpm load-data
: Load data into Elasticsearch
Create a .env.local
file with:
ELASTICSEARCH_URL=http://localhost:9200
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request