Skip to content

Implement Advanced Search System with Elasticsearch and Semantic Search#378

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-253
Draft

Implement Advanced Search System with Elasticsearch and Semantic Search#378
Copilot wants to merge 3 commits intomainfrom
copilot/fix-253

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 29, 2025

This PR implements a comprehensive advanced search system for QUL that enables searching across the vast Quranic resources using multiple search paradigms including Elasticsearch integration and semantic search techniques.

Key Features Implemented

8 Search Types:

  • Text Search: Full-text search across Arabic texts and translations with support for multiple script types
  • Morphology Search: Search by grammatical categories (nouns, verbs, particles, pronouns, adjectives)
  • Semantic Search: Meaning-based search with synonym expansion (e.g., "mercy" finds verses about forgiveness)
  • Root Search: Search by Arabic trilateral roots to find all derived words
  • Lemma Search: Search by word base forms (lemmas)
  • Stem Search: Search by morphological word stems
  • Pattern Search: Regular expression support for complex pattern matching
  • Script-Specific Search: Search within specific Arabic script types (QPC Hafs, Uthmani, Indo-Pak, etc.)
  • Combined Search: Multi-type search with intelligent deduplication

Advanced Filtering:

  • Chapter-specific search
  • Language filtering for translations
  • Arabic script type selection
  • Content type filtering (include/exclude translations and tafsirs)
  • Morphological category filtering

Architecture

Backend Components:

  • Search::AdvancedSearchService: Core search logic with type-specific handlers
  • Api::V1::SearchController: RESTful API endpoints with comprehensive parameter validation
  • AdvancedSearchController: Web interface controller with Turbo support

Frontend Components:

  • AdvancedSearchComponent: ViewComponent-based search interface
  • advanced_search_controller.js: Stimulus controller for real-time interactivity
  • Advanced search views with Turbo frame support for fast result loading

API Endpoints:

  • POST /api/v1/search/advanced: Main search endpoint
  • GET /api/v1/search/morphology_categories: Available morphological categories
  • GET /api/v1/search/arabic_scripts: Supported Arabic script types
  • GET /api/v1/search/suggestions: Real-time search suggestions

Technical Implementation

The system integrates with existing QUL data models (Verse, Word, Translation, Morphology::Word, Root, Lemma, Stem) and provides:

  • Performance Optimization: Elasticsearch configuration with database fallback
  • Smart Query Processing: Automatic search type detection and semantic expansion
  • Result Highlighting: Advanced text highlighting with search term emphasis
  • Error Handling: Comprehensive validation and graceful error recovery
  • Testing: Complete test coverage for services and API endpoints

Usage Examples

# Semantic search
curl -X POST /api/v1/search/advanced -d '{"search": {"query": "mercy", "type": "semantic"}}'

# Morphology search for nouns
curl -X POST /api/v1/search/advanced -d '{"search": {"query": "noun", "type": "morphology"}}'

# Root search with chapter filtering
curl -X POST /api/v1/search/advanced -d '{"search": {"query": "كتب", "type": "root", "chapter_id": 2}}'

The implementation provides both programmatic API access and a modern web interface accessible at /advanced_search, enabling developers to build intelligent applications while offering users an intuitive search experience.

Fixes #253.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.bitbucket.org
    • Triggering command: curl --fail --location --max-redirs 10 --connect-timeout 30 --retry-delay 2 --retry 3 -sS REDACTED (dns block)
  • https://api.github.com/repos/rvm/rvm/tags
    • Triggering command: curl --fail --location --max-redirs 10 --connect-timeout 30 --retry-delay 2 --retry 3 -sS REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@zeet-co
Copy link
Copy Markdown

zeet-co bot commented Aug 29, 2025

We're building your pull request over on Zeet.
Click me for more info about your build and deployment.
Once built, this branch can be tested at: https://quranic-universal-library-my2s-co-b8c3e2.tarteel-v3.tarteel.io before merging 😉

Co-authored-by: naveed-ahmad <701567+naveed-ahmad@users.noreply.github.com>
… demo

Co-authored-by: naveed-ahmad <701567+naveed-ahmad@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement Advanced Search System Implement Advanced Search System with Elasticsearch and Semantic Search Aug 29, 2025
Copilot AI requested a review from naveed-ahmad August 29, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Advanced Search System

2 participants