{"id":33976750,"url":"https://github.com/zk2/human-to-tsquery","last_synced_at":"2026-03-17T20:07:31.752Z","repository":{"id":57091451,"uuid":"230282601","full_name":"zk2/human-to-tsquery","owner":"zk2","description":"Convert human request to postgres ts_query","archived":false,"fork":false,"pushed_at":"2025-02-03T19:19:15.000Z","size":70,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-14T14:43:46.020Z","etag":null,"topics":["php","postgresql","tsquery"],"latest_commit_sha":null,"homepage":null,"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/zk2.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,"zenodo":null}},"created_at":"2019-12-26T15:03:47.000Z","updated_at":"2024-12-30T15:35:25.000Z","dependencies_parsed_at":"2024-02-07T10:28:31.789Z","dependency_job_id":"cacdce4b-7d2f-48c6-97a0-f21397ac52c7","html_url":"https://github.com/zk2/human-to-tsquery","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"33359d63978f9ff2994887dc67e7f47c2e62b687"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/zk2/human-to-tsquery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk2%2Fhuman-to-tsquery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk2%2Fhuman-to-tsquery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk2%2Fhuman-to-tsquery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk2%2Fhuman-to-tsquery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zk2","download_url":"https://codeload.github.com/zk2/human-to-tsquery/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk2%2Fhuman-to-tsquery/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30630110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["php","postgresql","tsquery"],"created_at":"2025-12-13T02:02:31.981Z","updated_at":"2026-03-17T20:07:31.747Z","avatar_url":"https://github.com/zk2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"zk2\\human-to-tsquery\n================\n\n[![Build Status](https://travis-ci.com/zk2/human-to-tsquery.svg?branch=master)](https://travis-ci.org/zk2/human-to-tsquery)\n\n[![Latest Stable Version](https://poser.pugx.org/zk2/human-to-tsquery/v/stable)](https://packagist.org/packages/zk2/human-to-tsquery)\n[![Total Downloads](https://poser.pugx.org/zk2/human-to-tsquery/downloads)](https://packagist.org/packages/zk2/human-to-tsquery)\n[![Latest Unstable Version](https://poser.pugx.org/zk2/human-to-tsquery/v/unstable)](https://packagist.org/packages/zk2/human-to-tsquery)\n[![License](https://poser.pugx.org/zk2/human-to-tsquery/license)](https://packagist.org/packages/zk2/human-to-tsquery)\n[![composer.lock](https://poser.pugx.org/zk2/human-to-tsquery/composerlock)](https://packagist.org/packages/zk2/human-to-tsquery)\n\nHuman query to ts_query for PostgreSQL full text search (https://www.postgresql.org/docs/12/textsearch.html). Provides a clement parser and associated tools for a convert human query to query which can be used ih Postgres Full Text Search. Lenient in that is will produce a parse tree for any input, given a default operator and by generally ignoring any unparsable syntax.\n\nThe query language supports the following features at a high level:\n\n   - Boolean operators: AND (infix), OR (infix), \"-\" (prefix) with an implied default operator and precedence rules, e.g. \"boy OR girl -infant\"\n\n   - Proximity Near Operator (Nx) - `television N2 violence` - Finds words within x number of words from each other, regardless of the order in which they occur.\n\n   - Proximity Within Operator (Wx)\t- `Franklin W2 Roosevelt` - Finds words within x number of words from each other, in the order they are entered in the search.\n\n   - Optional parenthesis for explicitly denoting precedence.\n\n   - Quoted phrases (for proximity matching)\n\nDocumentation\n-------------\n\n    // Some function, which getting SQL query and return single string result\n    $closure = function (string $sql) use ($connection) {\n        return $connection-\u003efetchOne($sql);\n    };\n    $humanToTsQuery = new HumanToTsQuery('Opel AND (auto car (patrol OR diesel OR \"electric car\") AND -sale)');\n    $tsQuery = $humanToTsQuery-\u003egetQuery($closure);\n    var_dump($tsQuery); // \"opel \u0026 (auto \u0026 car \u0026 (patrol | diesel | (electr \u003c-\u003e car)) \u0026 !sale)\"\n\n    $humanToTsQuery = new HumanToTsQuery('indigenous N2 (\"debt financing\" OR lalala) AND (\"New York\" OR Boston)');\n    $tsQuery = $humanToTsQuery-\u003egetQuery($closure);\n    var_dump($tsQuery); // \"(indigen \u003c2\u003e ((debt \u003c-\u003e financ) | lalala ) | ((debt \u003c-\u003e financ) | lalala ) \u003c2\u003e indigen | indigen \u003c1\u003e ((debt \u003c-\u003e financ) | lalala ) | ((debt \u003c-\u003e financ) | lalala ) \u003c1\u003e indigen) \u0026 ((new \u003c-\u003e york) | boston )\"\n\n    $humanToTsQuery = new HumanToTsQuery('(indigenous OR texas) W2 (\"debt financing\" OR lalala) AND (\"New York\" OR Boston)');\n    $tsQuery = $humanToTsQuery-\u003egetQuery($closure);\n    var_dump($tsQuery); // \"((indigen | texa ) \u003c2\u003e ((debt \u003c-\u003e financ) | lalala ) | (indigen | texa ) \u003c1\u003e ((debt \u003c-\u003e financ) | lalala )) \u0026 ((new \u003c-\u003e york) | boston )\"\n\nRunning the Tests\n-----------------\n\nInstall the [Composer](http://getcomposer.org/) `dev` dependencies:\n\n    composer install --dev\n\nThen, run the test suite using\n[PHPUnit](https://github.com/sebastianbergmann/phpunit/):\n\n    vendor/bin/phpunit\n\nLicense\n-------\n\nThis bundle is released under the MIT license. See the complete license in the bundle:\n\n    LICENSE\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk2%2Fhuman-to-tsquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzk2%2Fhuman-to-tsquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk2%2Fhuman-to-tsquery/lists"}