{"id":13462949,"url":"https://github.com/wvanbergen/scoped_search","last_synced_at":"2025-05-14T13:08:53.347Z","repository":{"id":417723,"uuid":"37427","full_name":"wvanbergen/scoped_search","owner":"wvanbergen","description":"Easily search you ActiveRecord models with a simple query language that converts to SQL.","archived":false,"fork":false,"pushed_at":"2025-02-18T15:51:47.000Z","size":833,"stargazers_count":267,"open_issues_count":21,"forks_count":78,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-04T08:54:11.678Z","etag":null,"topics":[],"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/wvanbergen.png","metadata":{"files":{"readme":"README.rdoc","changelog":"CHANGELOG.rdoc","contributing":"CONTRIBUTING.rdoc","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":"2008-07-26T13:46:16.000Z","updated_at":"2025-03-13T21:49:43.000Z","dependencies_parsed_at":"2024-01-05T21:50:12.034Z","dependency_job_id":"915f0372-6eb4-4b4c-a02e-c244b074e210","html_url":"https://github.com/wvanbergen/scoped_search","commit_stats":{"total_commits":618,"total_committers":47,"mean_commits":"13.148936170212766","dds":0.5663430420711975,"last_synced_commit":"f9fab94e950ada77536958340d87161ae8a420c1"},"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvanbergen%2Fscoped_search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvanbergen%2Fscoped_search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvanbergen%2Fscoped_search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvanbergen%2Fscoped_search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wvanbergen","download_url":"https://codeload.github.com/wvanbergen/scoped_search/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248420130,"owners_count":21100318,"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":[],"created_at":"2024-07-31T13:00:41.790Z","updated_at":"2025-04-11T14:39:58.606Z","avatar_url":"https://github.com/wvanbergen.png","language":"Ruby","funding_links":[],"categories":["Active Record Plugins","Ruby","Search"],"sub_categories":["Rails Search"],"readme":"= Scoped search {\u003cimg src=\"https://secure.travis-ci.org/wvanbergen/scoped_search.png\" /\u003e}[http://travis-ci.org/wvanbergen/scoped_search]\n\nThe \u003cb\u003escoped_search\u003c/b\u003e gem makes it easy to search your ActiveRecord\nmodels. Searching is performed using a query string, which should be passed to\nthe named_scope \u003ctt\u003esearch_for\u003c/tt\u003e. Based on a definition in what fields to\nlook, it will build query conditions and return those as a named scope.\n\nScoped search is great if you want to offer a simple yet powerful search box to your users\nand build a query based on the search string they enter. It comes with a built-in search syntax\nauto-completer and a value auto-completer. It also comes with a set of helpers that makes it easy\nto create a clean web UI with sorting and an ajax auto-completer.\n\n== Preview\n\nA demo application using the scoped search can be found here: http://github.com/abenari/scoped_search_demo_app\nA running version of the demo application can be found here: http://scope-search-demo.heroku.com\nA Rails 3.2 demo with assets pipeline and twitter bootstrap: theme https://github.com/abenari/search-demo2\n\n== Installing\n\nAdd the following line in your Gemfile, and run \u003ctt\u003ebundle install\u003c/tt\u003e:\n\n  gem \"scoped_search\"\n\nScoped search 4.x supports Rails 4.2 to 5.0, with Ruby 2.0.0 or higher. Use\nprevious versions, e.g. 3.x to support older versions of Rails or Ruby.\n\n== Usage\n\nScoped search requires you to define the fields you want to search in:\n\n  class User \u003c ActiveRecord::Base\n    scoped_search on: [:first_name, :last_name]\n  end\n\nFor more information about options and using fields from relations, see the\nproject wiki on search definitions:\nhttp://github.com/wvanbergen/scoped_search/wiki/search-definition\n\nNow, the \u003cb\u003esearch_for\u003c/b\u003e scope is available for queries. You should pass a\nquery string to the scope. This can be empty or nil, in which case all no search\nconditions are set (and all records will be returned).\n\n  User.search_for('my search string').each { |user| ... }\n\nThe result is returned as \u003ctt\u003enamed_scope\u003c/tt\u003e. Because of this, you can\nactually chain the call with other scopes, or with will_paginate. An example:\n\n  class Project \u003c ActiveRecord::Base\n    scoped_search on: [:name, :description]\n    named_scope :public, conditions: { public: true }\n  end\n\n  # using chained named_scopes and will_paginate in your controller\n  Project.public.search_for(params[:q]).paginate(page: params[:page], include: :tasks)\n\n=== Search profiles\n\nIf you include a :profile option to the scoped_search call, the fields specified will only\nbe searched when you include this :profile into the search_for command as well:\n\n  class User \u003c ActiveRecord::Base\n    scoped_search on: :public_information\n    scoped_search on: :private_information, profile: :members\n  end\n\nThis will only search the :public_information column:\n\n  User.search_for('blah blah blah')\n\nAnd this will only search the :private_information column:\n\n  User.search_for('blah blah blah', profile: :members)\n\n=== More information\n\nMore information about usage can be found in the project wiki:\nhttp://github.com/wvanbergen/scoped_search/wiki/usage\n\n== Query language\n\nThe search query language is simple, but supports several constructs to support\nmore complex queries:\n\nwords::         require every word to be present, e.g.: \u003ctt\u003esome search keywords\u003c/tt\u003e\n\nphrases::       use quotes for multi-word phrases, e.g. \u003ctt\u003e\"police car\"\u003c/tt\u003e\n\nnegation::      look for \"everything but\", e.g. \u003ctt\u003epolice -uniform\u003c/tt\u003e, \u003ctt\u003e-\"police car\"\u003c/tt\u003e,\n                \u003ctt\u003epolice NOT car\u003c/tt\u003e\n\nlogical keywords:: make logical constructs using AND, OR, \u0026\u0026, ||, \u0026, | operators, e.g.\n                   \u003ctt\u003euniform OR car\u003c/tt\u003e, \u003ctt\u003escoped \u0026\u0026 search\u003c/tt\u003e\n\nparentheses:: to structure logic e.g. \u003ctt\u003e\"police AND (uniform OR car)\"\u003c/tt\u003e\n\ncomparison operators:: to search in numerical or temporal fields, e.g.\n                       \u003ctt\u003e\u003e 22\u003c/tt\u003e, \u003ctt\u003e\u003c 2009-01-01\u003c/tt\u003e\n\nexplicit fields::  search only in the given field. e.g. \u003ctt\u003eusername = root\u003c/tt\u003e,\n                   \u003ctt\u003ecreated_at \u003e 2009-01-01\u003c/tt\u003e\n\nNULL checks::   using the \u003ctt\u003eset?\u003c/tt\u003e and \u003ctt\u003enull?\u003c/tt\u003e operator with a field name, e.g.\n                \u003ctt\u003enull? graduated_at\u003c/tt\u003e, \u003ctt\u003eset? parent_id\u003c/tt\u003e\n\nA complex query example to look for Ruby on Rails programmers without cobol\nexperience, over 18 years old, with a recently updated record and a non-lame\nnickname:\n\n  (\"Ruby\" OR \"Rails\") -cobol, age \u003e= 18, updated_at \u003e 2009-01-01 \u0026\u0026 nickname !~ l33t\n\nFor more info, see the the project wiki: http://github.com/wvanbergen/scoped_search/wiki/query-language\n\n== Additional resources\n\n* Project wiki: https://github.com/wvanbergen/scoped_search/wiki\n* Issue tracker: https://github.com/wvanbergen/scoped_search/issues\n* RDoc documentations: http://www.rubydoc.info/gems/scoped_search\n* Source code: https://github.com/wvanbergen/scoped_search\n\n- See CHANGELOG.rdoc for the changes to this library over time.\n- See CONTRIBUTING.rdoc if you want to report bugs, or help out on this project.\n\n== License\n\nThis plugin is released under the MIT license (see LICENSE).\n\nThis plugin was originally developed for Floorplanner.com by Willem van Bergen\n(https://github.com/wvanbergen) with help from Wes Hays (https://github.com/weshays).\nThe current maintainer is Amos Benari (https://github.com/abenari).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwvanbergen%2Fscoped_search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwvanbergen%2Fscoped_search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwvanbergen%2Fscoped_search/lists"}