This project provides a web-based interface for performing hybrid searches across hotel data in Elasticsearch, combining semantic search with traditional text matching.
-
Hybrid search across hotel data with:
- E5 Semantic Search (dense embeddings)
- ELSER Semantic Search (sparse embeddings)
- Text Match across multiple fields
-
Adjustable search component weights:
- E5 Semantic Search
- ELSER Semantic Search
- Text Match
-
AI Summary Chat: Intelligent explanations of search results with:
- 🤖 "Query Advisor" button for each result with explain data
- Resizable chat pane for follow-up questions
- UI-aware recommendations for improving search performance
- Context-aware guidance based on your search query
-
Visual Score Breakdown: AI-generated visual explanations with:
- 📊 "Visual Score Breakdown" button for each result with explain data
- Interactive charts and progress bars showing score contributions
- Color-coded field breakdowns and semantic model identification
- Visual suggestions for improving search performance
- Responsive HTML visualizations generated by AI
-
Real-time search results with highlighting
-
Modern, responsive UI built with Bootstrap
-
Query visualization for debugging
-
Optional semantic reranking
- Python 3.11 or higher (for local development)
- Docker and Docker Compose (for containerized deployment)
- Elasticsearch cluster with the
hotels
index containing:- Hotel information (name, description, address, etc.)
- Semantic embeddings (
semantic_description_e5
,semantic_description_elser
) - Combined fields for reranking
- Azure OpenAI account (for AI Summary Chat feature):
- OpenAI endpoint URL
- API key
- Model deployment (e.g., gpt-4o-global)
The easiest way to run this application is using Docker:
- Clone the repository:
git clone https://github.com/yourusername/hotel-finder-query-constructor.git
cd hotel-finder-query-constructor
- Set up environment variables:
cp variables.env.template variables.env
Edit variables.env
with your Elasticsearch and OpenAI configuration:
ES_URL=https://your-cluster.region.elastic.co:9243
ES_API_KEY=your-api-key-here
ELSER_INFERENCE_ID=.elser-2-elasticsearch
# OpenAI/Azure Configuration for AI Summary Chat
OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
OPENAI_API_KEY=your-azure-openai-api-key-here
OPENAI_MODEL=gpt-4o-global
OPENAI_API_VERSION=2025-01-01-preview
- Run the containerized application:
./run-container.sh
- Access the application:
Open your browser and go to
http://localhost:8080
For detailed Docker instructions, see README-Docker.md.
If you prefer to run the application locally without Docker:
- Clone the repository:
git clone https://github.com/yourusername/hotel-finder-query-constructor.git
cd hotel-finder-query-constructor
- Create a
variables.env
file with your Elasticsearch and OpenAI configuration:
cat > variables.env << EOL
ES_URL=your_elasticsearch_url
ES_API_KEY=your_elasticsearch_api_key
ELSER_INFERENCE_ID=.elser-2-elasticsearch
# OpenAI/Azure Configuration for AI Summary Chat
OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
OPENAI_API_KEY=your-azure-openai-api-key-here
OPENAI_MODEL=gpt-4o-global
OPENAI_API_VERSION=2025-01-01-preview
EOL
Replace the placeholder values with your actual credentials.
Note: The
variables.env
file contains sensitive information and should not be committed to version control. It is automatically added to.gitignore
.
- Set up and activate the environment:
Run the following command to set up the Python virtual environment, install dependencies, validate your configuration, and activate the environment in your current shell:
source setup_env.sh
Important: You must use
source setup_env.sh
(not./setup_env.sh
) so that the virtual environment is activated in your current shell session.
When setup completes, your shell prompt should show (venv)
indicating the environment is active.
When you're done, you can deactivate the virtual environment by running:
deactivate
Before using the UI, you must ingest hotel data into your Elasticsearch hotels
index. Use your preferred ingestion method or script to populate the index as needed.
Note: The previous ingestion scripts (
ingest.py
,elasticsearch_ingest.py
) have been removed. Please use your own ingestion process or contact the project maintainer for guidance.
./run-container.sh
Access at: http://localhost:8080
- Start the Flask application:
python search_ui.py
- Open your browser and navigate to
http://127.0.0.1:5001
- Enter your search query (hotel name, description, location, amenities, etc.)
- Adjust the weights for different search components using the sliders:
- E5 Semantic Search (default: 2.0)
- ELSER Semantic Search (default: 1.5)
- Text Match (default: 1.0)
- Optionally enable semantic reranking with configurable parameters
- Click "Search" or press Enter
- View the results with highlighted matches
- Click "Show Generated Query" to see the Elasticsearch query structure
For results with explain data enabled:
- Click "🤖 Query Advisor" next to any result to open the AI chat pane
- Read the AI summary explaining which document fields contributed most to the score
- Ask follow-up questions like:
- "How can I make the title field more important?"
- "What weights should I adjust to improve this result?"
- "Why did this result score higher than others?"
- Get UI-specific recommendations based on the available tuning controls
- Resize the chat pane by dragging the handle on the left edge
- Close the chat when done to clear the session
The AI assistant understands all UI capabilities and provides actionable recommendations for:
- Weight adjustments (E5, ELSER, Text Match)
- Field boosts (title, description, features, etc.)
- Retriever type selection (Linear vs RRF)
- Location and price filtering
- Multi-match type configuration
For results with explain data enabled:
- Click "📊 Visual Score Breakdown" next to any result to generate an AI-powered visual explanation
- View interactive charts and progress bars showing how each field contributed to the score
- See color-coded breakdowns for different types of matches (semantic vs keyword)
- Get visual suggestions for improving search performance with specific UI adjustments
- Identify which semantic models were used (E5, ELSER, or both)
- Toggle between different explanation views (Summary, Visual, Raw JSON)
The visual breakdown includes:
- Overall score visualization with contributing factors
- Field-specific progress bars showing relative importance
- Semantic model identification and explanation
- Interactive suggestions for UI parameter adjustments
- Responsive design that works on all screen sizes
The search covers the following hotel fields:
- HotelName
- Description
- Address
- cityName
- HotelFacilities
- Attractions
The project consists of two main components:
search_ui.py
: Flask application handling the backend logic and AI chat integrationtemplates/index.html
: Frontend interface with Bootstrap styling and resizable chat pane
This project includes Docker support for easy deployment:
- Dockerfile: Multi-stage build for production-ready container
- docker-compose.yml: Easy orchestration with environment variables
- run-container.sh: Helper script for building and running
- README-Docker.md: Detailed Docker documentation