{"id":13641871,"url":"https://github.com/netgen/query-translator","last_synced_at":"2025-04-12T18:45:38.129Z","repository":{"id":19155584,"uuid":"85931619","full_name":"netgen/query-translator","owner":"netgen","description":"Query Translator is a search query translator with AST representation","archived":false,"fork":false,"pushed_at":"2024-02-21T11:35:27.000Z","size":518,"stargazers_count":206,"open_issues_count":3,"forks_count":10,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-03T20:12:57.790Z","etag":null,"topics":["ast","edismax","elasticsearch","generator","parser","php","query","search","solr","tokenizer","translator"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netgen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-23T09:33:35.000Z","updated_at":"2025-02-24T01:15:45.000Z","dependencies_parsed_at":"2024-06-18T14:06:38.519Z","dependency_job_id":null,"html_url":"https://github.com/netgen/query-translator","commit_stats":{"total_commits":136,"total_committers":8,"mean_commits":17.0,"dds":0.06617647058823528,"last_synced_commit":"d38e4e4d947aa205ff81594d302b1080e96b79f6"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netgen%2Fquery-translator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netgen%2Fquery-translator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netgen%2Fquery-translator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netgen%2Fquery-translator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netgen","download_url":"https://codeload.github.com/netgen/query-translator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248617382,"owners_count":21134190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","edismax","elasticsearch","generator","parser","php","query","search","solr","tokenizer","translator"],"created_at":"2024-08-02T01:01:25.180Z","updated_at":"2025-04-12T18:45:38.109Z","avatar_url":"https://github.com/netgen.png","language":"PHP","readme":"# Query Translator\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/netgen/query-translator/tests.yml?branch=master\u0026\u0026style=flat-square)](https://github.com/netgen/query-translator/actions?query=workflow%3ATests)\n[![Code Coverage](https://img.shields.io/codecov/c/github/netgen/query-translator.svg?style=flat-square)](https://codecov.io/gh/netgen/query-translator)\n[![Downloads](https://img.shields.io/packagist/dt/netgen/query-translator.svg?style=flat-square)](https://packagist.org/packages/netgen/query-translator)\n[![Latest stable](https://img.shields.io/packagist/v/netgen/query-translator.svg?style=flat-square)](https://packagist.org/packages/netgen/query-translator)\n[![License](https://img.shields.io/packagist/l/netgen/query-translator.svg?style=flat-square)](https://packagist.org/packages/netgen/query-translator)\n[![PHP](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg?style=flat-square)](https://secure.php.net/)\n\nQuery Translator takes a search string as user input and converts it into something a search backend\ncan understand. Technically, it's a search query\n[translator](https://en.wikipedia.org/wiki/Translator_(computing)) with\n[abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) representation. From the\nproduced syntax tree, translation target can be anything you need. Usually it's a search backend,\nlike Solr and Elasticsearch, or a database abstraction layer.\n\nA set of interfaces for implementing a language processor is provided, with a single implemented\nlanguage named [Galach](lib/Languages/Galach). Galach implements a syntax that is based on what\nseems to be the unofficial standard for search query as user input. Quick cheat sheet:\n\n`word` `\"phrase\"` `(group)` `+mandatory` `-prohibited` `AND` `\u0026\u0026` `OR` `||` `NOT` `!` `#tag` `@user`\n`domain:term`\n\n### Error handling\n\nUser input means you have to expect errors and handle them gracefully. Because of that, the parser\nis completely resistant to errors. Syntax tree will contain detailed information about corrections\napplied to make sense of the user input. This can be useful to clean up the input or implement rich\ninput interface, with features like suggestions, syntax highlighting and error feedback.\n\n### Customization\n\nThe implementation was made with customization in mind. You can change the special characters which\nwill be used as part of the syntax, pick out elements of the language you want to use, implement\nyour own term clauses, or change how the syntax tree is converted to the target output.\n\n### Some use cases\n\n- User-level query language on top of your search backend\n- Common query language on top of different search backends\n- Control over options of the query language that is already provided by the search backend\n- Better error handling than provided by the search backend\n- Analysis and manipulation of the query before sending to the backend\n- Customized query language (while remaining within the base syntax)\n- Implementing rich input interface (with suggestions, syntax highlighting, error feedback)\n\nNote: This implementation is intended as a\n[library](https://en.wikipedia.org/wiki/Library_(computing)), meaning it doesn't try to solve\nspecific use cases for query translation. Instead, it's meant to be a base that you can use in\nimplementing such a use case.\n\n### How to use\n\nFirst add the library to your project:\n\n```\ncomposer require netgen/query-translator:^1.0\n```\n\nAfter that, make use of the features provided out of the box. If those are not enough, use extension\npoints to customize various parts of the translator to fit your needs. See\n[Galach documentation](lib/Languages/Galach) to find out more.\n\n## Run the demo\n\nDemo is available as a separate repository at [netgen/query-translator-demo](https://github.com/netgen/query-translator-demo).\n\nSteps for running the demo:\n\n1. Create the demo project using composer `composer create-project netgen/query-translator-demo`\n2. Position into the demo project directory `cd query-translator-demo`\n3. Start the web server with `src` as the document root `php -S localhost:8005 -t src`\n4. Open [http://localhost:8005](http://localhost:8005) in your browser ![Query Translator demo](https://raw.githubusercontent.com/netgen/query-translator-demo/master/src/animation.gif)\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetgen%2Fquery-translator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetgen%2Fquery-translator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetgen%2Fquery-translator/lists"}