{"id":18071943,"url":"https://github.com/stereobooster/search_syntax","last_synced_at":"2025-04-05T17:41:54.334Z","repository":{"id":62559690,"uuid":"552530458","full_name":"stereobooster/search_syntax","owner":"stereobooster","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-12T13:55:16.000Z","size":288,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T12:15:51.419Z","etag":null,"topics":["filter","filter-lists","match","matching-engine","query","query-parser","querystrings","ransack","search","search-engine","sort"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/stereobooster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-16T19:51:47.000Z","updated_at":"2024-09-26T13:35:16.000Z","dependencies_parsed_at":"2023-01-22T17:15:19.794Z","dependency_job_id":null,"html_url":"https://github.com/stereobooster/search_syntax","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stereobooster%2Fsearch_syntax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stereobooster%2Fsearch_syntax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stereobooster%2Fsearch_syntax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stereobooster%2Fsearch_syntax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stereobooster","download_url":"https://codeload.github.com/stereobooster/search_syntax/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378087,"owners_count":20929291,"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":["filter","filter-lists","match","matching-engine","query","query-parser","querystrings","ransack","search","search-engine","sort"],"created_at":"2024-10-31T09:18:06.386Z","updated_at":"2025-04-05T17:41:54.316Z","avatar_url":"https://github.com/stereobooster.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# search_syntax\n\nParser for \"advanced search\" query language. Inspired by [GitHub's search syntax](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax)\n\nThere is no wide accepted terminology for this kind of query language. Sometimes it's called: [query string](http://recursion.org/query-parser), [search query](https://tgvashworth.com/2016/06/27/twitter-search-query-parser.html), [advanced search query](https://github.com/mixmaxhq/search-string), [generic query](https://github.com/tomprogers/common-query-parser).\n\nPackage provides only parser. AST produced by parser can be converted to a specific \"backend\", for example: [ransack](https://activerecord-hackery.github.io/ransack/getting-started/search-matches/), [MySQL Full-Text Search](https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html), [PostgreSQL Full-Text Search](https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES), [Meilisearch](https://docs.meilisearch.com/reference/api/search.html#body), [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html), [Solr](https://solr.apache.org/guide/6_6/the-standard-query-parser.html), [Lucene](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html) ([Lucene vs Solr](https://www.lucenetutorial.com/lucene-vs-solr.html)), [Sphinx](https://sphinxsearch.com/docs/current/extended-syntax.html).\n\nTransforming AST is out of scope of this package, except for Ransack, which serves as an example of implementation.\n\n## Disclaimer\n\nSo far parser only supports bare strings, **quoted strings** (`\"some string\"`) and parameters (`param:1`).\n\nParser **doesn't** support negation (`not`/`-`), boolean operations (`and`/`\u0026`/`or`/`|`) and groupping (`(a | b)`).\n\nThis probably will change as soon as I understand how to add those \"advanced\" features without making it less user-friendly for non-techy people. See [Language design](docs/language-design.md) for explanations.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```sh\n$ bundle add search_syntax\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n```sh\n$ gem install search_syntax\n```\n\n## Usage\n\n### With ransack\n\n```diff\ndef index\n-  @q = Person.ransack(params[:q])\n+  query_parser = SearchSyntax::Ransack.new(text: :name_or_email_cont, params: Person.column_names - [\"id\"])\n+  @q = Person.ransack(query_parser.parse(params[:search]))\n  @people = @q.result(distinct: true)\nend\n```\n\n### Standalone\n\nsee `lib/search_syntax/ransack.rb` for an example of how to use parser\n\n## Similar packages\n\n- [search_cop](https://github.com/mrkamel/search_cop)\n- [easy-filter](https://github.com/Noriller/easy-filter)\n- [human-ql](https://github.com/dekellum/human-ql)\n- [logical_query_parser](https://github.com/kanety/logical_query_parser)\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\nTo regenrate parser\n\n```sh\n$ bin/tt lib/search_syntax/search_syntax_grammar.tt\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/stereobooster/search_syntax. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/stereobooster/search_syntax/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the SearchSyntax project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/stereobooster/search_syntax/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstereobooster%2Fsearch_syntax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstereobooster%2Fsearch_syntax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstereobooster%2Fsearch_syntax/lists"}