{"id":13879788,"url":"https://github.com/swiftype/swiftype-app-search-ruby","last_synced_at":"2025-07-16T15:33:05.456Z","repository":{"id":56896881,"uuid":"123193859","full_name":"swiftype/swiftype-app-search-ruby","owner":"swiftype","description":"Swiftype App Search Ruby Client","archived":true,"fork":false,"pushed_at":"2019-09-04T17:17:06.000Z","size":302,"stargazers_count":8,"open_issues_count":0,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-07T08:13:19.415Z","etag":null,"topics":["elastic","ruby-client","search","swiftype"],"latest_commit_sha":null,"homepage":"https://swiftype.com/app-search","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/swiftype.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}},"created_at":"2018-02-27T21:58:55.000Z","updated_at":"2023-03-20T08:42:52.000Z","dependencies_parsed_at":"2022-08-20T17:40:32.134Z","dependency_job_id":null,"html_url":"https://github.com/swiftype/swiftype-app-search-ruby","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftype%2Fswiftype-app-search-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftype%2Fswiftype-app-search-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftype%2Fswiftype-app-search-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftype%2Fswiftype-app-search-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiftype","download_url":"https://codeload.github.com/swiftype/swiftype-app-search-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"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":["elastic","ruby-client","search","swiftype"],"created_at":"2024-08-06T08:02:33.229Z","updated_at":"2024-11-24T08:31:47.606Z","avatar_url":"https://github.com/swiftype.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/swiftype/swiftype-app-search-ruby/blob/master/logo-app-search.png?raw=true\" alt=\"Elastic App Search Logo\"\u003e\u003c/p\u003e\n\n\u003e **⚠️ This repository is deprecated ⚠️**\n\u003e\n\u003e **Please visit [https://github.com/elastic/app-search-ruby](https://github.com/elastic/app-search-ruby) for the up to date version. Thank you! - Elastic**\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/swiftype/swiftype-app-search-ruby/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/swiftype/swiftype-app-search-ruby/all.svg?style=flat-square\" alt=\"GitHub release\" /\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003e A first-party Ruby client for building excellent, relevant search experiences with Elastic App Search.\n\n## Contents\n\n+ [Getting started](#getting-started-)\n+ [Usage](#usage)\n+ [Running Tests](#running-tests)\n+ [Debugging API Calls](#debugging-api-calls)\n+ [FAQ](#faq-)\n+ [Contribute](#contribute-)\n+ [License](#license-)\n\n***\n\n## Getting started 🐣\n\nTo install the gem, execute:\n\n```bash\ngem install swiftype-app-search\n```\n\nOr place `gem 'swiftype-app-search', '~\u003e 0.6.1'` in your `Gemfile` and run `bundle install`.\n\n## Usage\n\n### Setup: Configuring the client and authentication\n\nCreate a new instance of the Swiftype App Search Client. This requires your `[HOST_IDENTIFIER]`, which\nidentifies the unique hostname of the Swiftype API that is associated with your Swiftype account.\nIt also requires a valid `[API_KEY]`, which authenticates requests to the API. You can use any key type with the client, however each has a different scope. For more information on keys, check out the [documentation](https://swiftype.com/documentation/app-search/credentials).\n\nYou can find your `[API_KEY]` and your `[HOST_IDENTIFIER]` within the [Credentials](https://app.swiftype.com/as/credentials) menu:\n\n```ruby\nclient = SwiftypeAppSearch::Client.new(:host_identifier =\u003e 'host-c5s2mj', :api_key =\u003e 'private-mu75psc5egt9ppzuycnc2mc3')\n```\n\n### Using with App Search Managed Deploys\n\nThe client can be configured to use a managed deploy by using the\n`api_endpoint` parameter. Since managed deploys do not rely on a `[HOST_IDENTIFIER]`\n, it can be omitted.\n\n```ruby\nclient = SwiftypeAppSearch::Client.new(:api_key =\u003e 'private-mu75psc5egt9ppzuycnc2mc3', :api_endpoint =\u003e 'http://localhost:3002/api/as/v1/')\n```\n\n### API Methods\n\nThis client is a thin interface to the Swiftype App Search Api. Additional details for requests and responses can be\nfound in the [documentation](https://swiftype.com/documentation/app-search).\n\n#### Indexing: Creating or Updating a Single Document\n\n```ruby\nengine_name = 'favorite-videos'\ndocument = {\n  :id =\u003e 'INscMGmhmX4',\n  :url =\u003e 'https://www.youtube.com/watch?v=INscMGmhmX4',\n  :title =\u003e 'The Original Grumpy Cat',\n  :body =\u003e 'A wonderful video of a magnificent cat.'\n}\n\nclient.index_document(engine_name, document)\n```\n\n#### Indexing: Creating or Replacing Documents\n\n```ruby\nengine_name = 'favorite-videos'\ndocuments = [\n  {\n    :id =\u003e 'INscMGmhmX4',\n    :url =\u003e 'https://www.youtube.com/watch?v=INscMGmhmX4',\n    :title =\u003e 'The Original Grumpy Cat',\n    :body =\u003e 'A wonderful video of a magnificent cat.'\n  },\n  {\n    :id =\u003e 'JNDFojsd02',\n    :url =\u003e 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',\n    :title =\u003e 'Another Grumpy Cat',\n    :body =\u003e 'A great video of another cool cat.'\n  }\n]\n\nclient.index_documents(engine_name, documents)\n```\n\n#### Indexing: Updating Documents (Partial Updates)\n\n```ruby\nengine_name = 'favorite-videos'\ndocuments = [\n  {\n    :id =\u003e 'INscMGmhmX4',\n    :title =\u003e 'Updated title'\n  }\n]\n\nclient.update_documents(engine_name, documents)\n```\n\n#### Retrieving Documents\n\n```ruby\nengine_name = 'favorite-videos'\ndocument_ids = ['INscMGmhmX4', 'JNDFojsd02']\n\nclient.get_documents(engine_name, document_ids)\n```\n\n#### Listing Documents\n```ruby\nengine_name = 'favorite-videos'\n\nclient.list_documents(engine_name)\n```\n\n#### Destroying Documents\n\n```ruby\nengine_name = 'favorite-videos'\ndocument_ids = ['INscMGmhmX4', 'JNDFojsd02']\n\nclient.destroy_documents(engine_name, document_ids)\n```\n\n#### Listing Engines\n\n```ruby\nclient.list_engines\n```\n\n#### Retrieving Engines\n\n```ruby\nengine_name = 'favorite-videos'\n\nclient.get_engine(engine_name)\n```\n\n#### Creating Engines\n\n```ruby\nengine_name = 'favorite-videos'\n\nclient.create_engine(engine_name)\n```\n\n#### Destroying Engines\n\n```ruby\nengine_name = 'favorite-videos'\n\nclient.destroy_engine(engine_name)\n```\n\n#### Searching\n\n```ruby\nengine_name = 'favorite-videos'\nquery = 'cat'\nsearch_fields = { :title =\u003e {} }\nresult_fields = { :title =\u003e { :raw =\u003e {} } }\noptions = { :search_fields =\u003e search_fields, :result_fields =\u003e result_fields }\n\nclient.search(engine_name, query, options)\n```\n\n#### Multi-Search\n\n```ruby\nengine_name = 'favorite-videos'\n\nqueries = [{\n  :query =\u003e 'cat',\n  :options =\u003e { :search_fields =\u003e { :title =\u003e {} }}\n},{\n  :query =\u003e 'dog',\n  :options =\u003e { :search_fields =\u003e { :body =\u003e {} }}\n}]\n\nclient.multi_search(engine_name, queries)\n```\n\n#### Query Suggestion\n\n```ruby\nengine_name = 'favorite-videos'\n\noptions = {\n  :size =\u003e 3,\n  :types =\u003e {\n    :documents =\u003e {\n      :fields =\u003e ['title']\n    }\n  }\n}\n\nclient.query_suggestion(engine_name, 'cat', options)\n```\n\n#### Show Search Settings\n\n```ruby\nengine_name = 'favorite-videos'\n\nclient.show_settings(engine_name)\n```\n\n#### Update Search Settings\n\n```ruby\nengine_name = 'favorite-videos'\n\nsettings = {\n  \"search_fields\" =\u003e {\n    \"id\" =\u003e {\n      \"weight\" =\u003e 1\n    },\n    \"url\" =\u003e {\n      \"weight\" =\u003e 1\n    },\n    \"title\" =\u003e {\n      \"weight\" =\u003e 1\n    },\n    \"body\" =\u003e {\n      \"weight\" =\u003e 1\n    },\n  },\n  \"boosts\" =\u003e {\n    \"title\" =\u003e [\n      {\n        \"type\" =\u003e \"value\",\n        \"factor\" =\u003e 9.5,\n        \"operation\" =\u003e \"multiply\",\n        \"value\" =\u003e [\n          \"Titanic\"\n        ]\n      }\n    ]\n  }\n}\n\nclient.update_settings(engine_name, settings)\n```\n\n#### Reset Search Settings\n\n```ruby\nengine_name = 'favorite-videos'\n\nclient.reset_settings(engine_name)\n```\n\n## Running Tests\n\n```bash\nexport AS_API_KEY=\"[API_KEY]\"\nexport AS_HOST_IDENTIFIER=\"[HOST_IDENTIFIER]\"\nbundle exec rspec\n```\n\nYou can also run tests against a local environment by passing a `AS_API_ENDPOINT` environment variable\n\n```bash\nexport AS_API_KEY=\"[API_KEY]\"\nexport AS_API_ENDPOINT=\"http://[HOST_IDENTIFIER].api.127.0.0.1.ip.es.io:3002/api/as/v1\"\nbundle exec rspec\n```\n\n## Debugging API calls\n\nIf you need to debug an API call made by the client, there are a few things you could do:\n\n1. Setting `AS_DEBUG` environment variable to `true` would enable HTTP-level debugging and you would\n   see all requests generated by the client on your console.\n\n2. You could use our API logs feature in App Search console to see your requests and responses live.\n\n3. In your debug logs you could find a `X-Request-Id` header value. That could be used when talking\n   to Swiftype Customer Support to help us quickly find your API request and help you troubleshoot\n   your issues.\n\n## FAQ 🔮\n\n### Where do I report issues with the client?\n\nIf something is not working as expected, please open an [issue](https://github.com/swiftype/swiftype-app-search-ruby/issues/new).\n\n### Where can I learn more about App Search?\n\nYour best bet is to read the [documentation](https://swiftype.com/documentation/app-search).\n\n### Where else can I go to get help?\n\nYou can checkout the [Elastic App Search community discuss forums](https://discuss.elastic.co/c/app-search).\n\n## Contribute 🚀\n\nWe welcome contributors to the project. Before you begin, a couple notes...\n\n+ Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/swiftype/swiftype-app-search-ruby/issues).\n+ Please write simple code and concise documentation, when appropriate.\n\n## License 📗\n\n[MIT](https://github.com/swiftype/swiftype-app-search-ruby/blob/master/LICENSE.txt) © [Elastic](https://github.com/elastic)\n\nThank you to all the [contributors](https://github.com/swiftype/swiftype-app-search-ruby/graphs/contributors)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftype%2Fswiftype-app-search-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftype%2Fswiftype-app-search-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftype%2Fswiftype-app-search-ruby/lists"}