Coder Social home page Coder Social logo

isabella232 / workplace-search-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elastic/workplace-search-ruby

0.0 0.0 0.0 264 KB

Elastic Workplace Search Official Ruby Client

Home Page: https://www.elastic.co/workplace-search

License: Apache License 2.0

Ruby 98.07% Shell 1.93%

workplace-search-ruby's Introduction

⚠️ This client is deprecated ⚠️

As of Enterprise Search version 7.10.0, we are directing users to the new Enterprise Search Ruby Client and deprecating this client.

This client will be compatible with all Enterprise Search 7.x releases, but will not be compatible with 8.x releases. Our development effort on this project will be limited to bug fixes. All future enhancements will be focused on the Enterprise Search Ruby Client.

Thank you! - Elastic

Master build

A first-party Ruby client for Elastic Workplace Search.

Contents


Getting started 🐣

To install the gem, execute:

gem install elastic-workplace-search

Or place gem 'elastic-workplace-search', '~> 0.4.1 in your Gemfile and run bundle install.

Usage

In your Elastic Workplace Search dashboard navigate to Sources/Add a Shared Content Source/Custom API Source to create a new source. Name your source (e.g. Workplace Search Ruby Client) and once it's created you'll get an access token and a key. You'll need these in the following steps.

Create a new instance of the Elastic Workplace Search client with your access token:

Elastic::WorkplaceSearch.access_token = '' # your access token
client = Elastic::WorkplaceSearch::Client.new

Change API endpoint

client = Elastic::WorkplaceSearch::Client.new
Elastic::WorkplaceSearch.endpoint = 'https://your-server.example.com/api/ws/v1'

Specifying an HTTP Proxy

client = Elastic::WorkplaceSearch::Client.new(proxy: 'http://localhost:8888')

Documents

Indexing Documents

This example shows how to use the index_documents method:

content_source_key = '' # your content source key
documents = [
  {
    'id' => 'INscMGmhmX4',
    'url' => 'http://www.youtube.com/watch?v=v1uyQZNg2vE',
    'title' => 'The Original Grumpy Cat',
    'body' => 'this is a test'
  },
  {
    'id' => 'JNDFojsd02',
    'url' => 'http://www.youtube.com/watch?v=tsdfhk2j',
    'title' => 'Another Grumpy Cat',
    'body' => 'this is also a test'
  }
]

begin
  document_receipts = client.index_documents(content_source_key, documents)
  # handle results
rescue Elastic::WorkplaceSearch::ClientException => e
  # handle error
end

Destroying Documents

content_source_key = '' # your content source key
document_ids = ['INscMGmhmX4', 'JNDFojsd02']

begin
  destroy_document_results = client.destroy_documents(content_source_key, document_ids)
  # handle destroy document results
rescue Elastic::WorkplaceSearch::ClientException => e
  # handle error
end

Permissions

Listing all permissions

content_source_key = '' # your content source key

client.list_all_permissions(content_source_key)

Listing all permissions with paging

content_source_key = '' # your content source key

client.list_all_permissions(content_source_key, current: 2, size: 20)

Retrieve a User's permissions

content_source_key = '' # your content source key
user = 'enterprise_search'

client.get_user_permissions(content_source_key, user)

Add permissions to a User

content_source_key = '' # your content source key
user = 'enterprise_search'
permissions = ['permission1']

client.add_user_permissions(content_source_key, user, permissions: permissions)

Update a User's permissions

content_source_key = '' # your content source key
user = 'enterprise_search'
permissions = ['permission2']

client.update_user_permissions(content_source_key, user, permissions: permissions)

Remove permissions from a User

content_source_key = '' # your content source key
user = 'enterprise_search'
permissions = ['permission2']

client.remove_user_permissions(content_source_key, user, permissions: permissions)

Running tests

Run tests via rspec:

$ ENDPOINT=http://localhost:3002/api/ws/v1 bundle exec rspec

FAQ 🔮

Where do I report issues with the client?

If something is not working as expected, please open an issue.

Contribute 🚀

We welcome contributors to the project. Before you begin, a couple notes...

License 📗

Apache 2.0 © Elastic

Thank you to all the contributors!

workplace-search-ruby's People

Contributors

brianvans avatar goodroot avatar jasonstoltz avatar marshalium avatar omegahm avatar picandocodigo avatar qhoxie avatar sethmlarson avatar yakhinvadim avatar zumwalt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.