Skip to content

refactor(query): extract query pipeline mutation logic to reduce complexity#392

Open
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
SaitejaKommi:refactor/query-pipeline-complexity
Open

refactor(query): extract query pipeline mutation logic to reduce complexity#392
SaitejaKommi wants to merge 1 commit intoopenfoodfacts:mainfrom
SaitejaKommi:refactor/query-pipeline-complexity

Conversation

@SaitejaKommi
Copy link
Copy Markdown

@SaitejaKommi SaitejaKommi commented Apr 20, 2026

Summary

This PR reduces the excessive complexity in query.py by separating query pipeline mutation logic from lower-level Elasticsearch object creation responsibilities.

The refactor improves modular boundaries by moving parsing and tree transformation behavior into a dedicated pipeline module, while keeping runtime behavior fully preserved.


Related Issue

Fixes #393


What Changed

  • Created query_pipeline.py to encapsulate parsing and tree mutation workflow
  • Moved pipeline responsibilities such as:
    • compute_facets_filters
    • resolve_unknown_operation
    • check_query
    • parse_query
  • Simplified query.py to focus on orchestration and execution flow
  • Kept query.py as the bridge between pipeline processing and ElasticsearchQueryBuilder
  • Preserved existing behavior with no intended logic changes

Affected Files

  • query.py
  • query_pipeline.py

Testing

Verification gateway executed successfully:

  • Backend unit tests ✅
  • Backend integration tests (Elasticsearch verified context) ✅
  • Frontend component tests ✅

Notes

This is a structural refactor focused on reducing complexity and improving maintainability through clearer separation of concerns.

…lexity

Moves string and parsing mutation steps (e.g. padding, boosting syntax, parsing fields) into a separate \query_pipeline.py\ to simplify \query.py\. \query.py\ now focuses primarily on Elasticsearch mapping and orchestration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (ready for dev)

Development

Successfully merging this pull request may close these issues.

Code Smell: Query pipeline complexity concentrated in single module

1 participant