{"id":19219347,"url":"https://github.com/look/query-parser","last_synced_at":"2025-05-13T00:43:24.015Z","repository":{"id":66441573,"uuid":"91419690","full_name":"look/query-parser","owner":"look","description":"tutorial for building a query parser using Ruby, Parslet, and Elasticsearch","archived":false,"fork":false,"pushed_at":"2020-08-28T21:49:07.000Z","size":40968,"stargazers_count":42,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-10T18:03:35.957Z","etag":null,"topics":["elasticsearch","parslet","query-parser","ruby","tutorial"],"latest_commit_sha":null,"homepage":"http://www.recursion.org/query-parser/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/look.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-05-16T05:55:58.000Z","updated_at":"2023-10-20T15:25:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d6bccfd-8638-445f-84b5-e301ee5a6887","html_url":"https://github.com/look/query-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/look%2Fquery-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/look%2Fquery-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/look%2Fquery-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/look%2Fquery-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/look","download_url":"https://codeload.github.com/look/query-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253850850,"owners_count":21973668,"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":["elasticsearch","parslet","query-parser","ruby","tutorial"],"created_at":"2024-11-09T14:30:56.151Z","updated_at":"2025-05-13T00:43:23.994Z","avatar_url":"https://github.com/look.png","language":"Ruby","readme":"# Build a query parser example code\n\nThis is example code for my tutorial [Build a query parser](http://www.recursion.org/query-parser/).\n\n## How the code is organized\n\nEach query parser is self-contained to make the tutorial easier to follow. This does mean there's a lot of duplication. In order to keep the classes separate, each query parser is contained in its own module.\n\nThe sequence of query parsers is:\n\n1. [TermParser](https://github.com/look/query-parser/blob/master/term_parser.rb)\n2. [BooleanTermParser](https://github.com/look/query-parser/blob/master/boolean_term_parser.rb)\n3. [PhraseParser](https://github.com/look/query-parser/blob/master/phrase_parser.rb)\n4. [HeuristicParser](https://github.com/look/query-parser/blob/master/heuristic_parser.rb)\n\n## Installing and running\n\n### Prerequisites\n\nYou will need Ruby (tested with 2.4) to run the query parsers and Java (tested with 1.8) to run Elasticsearch if you want to try out the parsers for real. I use RVM and jEnv to manage the versions, but you do not have to.\n\n### Install dependencies\n\n```\nbundle install\n```\n\n### Run unit tests\n\n```\nbundle exec rake test\n```\n\n### Run integration tests\n\nThe integration tests require Elasticsearch to be started.\n\n```\nelasticsearch/bin/elasticsearch\n```\n\nIn another terminal:\n\n```\nbundle exec rake integration_test\n```\n\n### Query generation console\n\nThe `parse` program allows you to test out the different parser and see the parse tree and Elasticsearch DSL that is generated based on a query string you provide.\n\nTo run it:\n\n```\nbundle exec bin/parse\n```\n\nThe program defaults to the `HeuristicParser` because it is the most featureful. To try one of the others, provide it as a command-line argument:\n\n```\nbundle exec bin/parse BooleanTermParser\n```\n\n## License\n\nThe source code in this repository is released into the public domain.\n\nThe tutorial is under copyright and cannot be republished without my permission.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flook%2Fquery-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flook%2Fquery-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flook%2Fquery-parser/lists"}