Giter Club home page Giter Club logo

rummageable's Introduction

Rummageable (DEPRECATED)

This gem is deprecated. Please use gds-api-adapters.

Rummageable is a ruby gem to simplify communication with Rummager to create/update/remove items in the gov.uk search index.

It attempts to handle networking errors by retrying failed requests a few times before it'll give up, and will optionally log it's success/failure to a logger object (if you give it one).

Usage

To interact with Rummager, create an instance of the Rummageable::Index class:

index = Rummageable::Index.new('http://localhost:3009', 'index-name')

You can also pass a logger to new, and can control how aggressively Rummageable will retry your command in the event of an error. See the source for details.

Getting started

You can add individual indexable "things" to a Rummager index by passing a hash that represents the thing you want to index:

document = {
  'title' => 'Child benefit tax calculator',
  'link' => '/child-benefit-tax',
  'format' => 'smart-answer',
  'section' => nil,
  'subsection' => nil
}
index = Rummageable::Index.new('http://localhost:3009', 'index-name')
index.add(document)

The link key is special; you can use it to amend/delete the document's entry in the index later, with the Index#amend and Index#delete methods.

If you've got a large collection of documents the add_batch method will chop the collection up into manageable chunks and send them to Rummager for you.

index.add_batch(array_of_documents)

See the source of the Rummageable::Index class for other methods.

rummageable's People

Contributors

bradwright avatar chrisroos avatar craigw avatar daibach avatar davidslv avatar dhwthompson avatar elliotcm avatar floehopper avatar garethr avatar heathd avatar jabley avatar jamiecobbett avatar jordanhatch avatar jystewart avatar lazyatom avatar mattbostock avatar matthewford avatar threedaymonk avatar tijmenb avatar tomafro avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rummageable's Issues

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

There is even a License Finder to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.

How did I find you?

I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for missing ones as a public service :)
https://gist.github.com/bf4/5952053#file-license_issue-rb-L13 So far it's going pretty well

Deleting documents of type other than edition and best_bet

It might not be possible to delete documents unless they have the type of 'edition' or 'best_bet' via rummageable.

Calling #delete https://github.com/alphagov/rummageable/blob/master/lib/rummageable.rb#L39 forms the rummager document URL (without a request body).

The delete action in Rummager tries to find a document type in the request body, which will never happen using rummageable, and then sets the type based on this method which only allows 'edition' or 'best_bet'..

We (the service manual team) want to delete documents of type 'service_manual_guide'. I'm thinking our options are...

  1. Form a URL to delete from rummager in our publisher and bypass rummageable
  2. Do what was done for best_bet and just tack on additional types to allow through (doesn't seem very sustainable)
  3. Support a new way of passing type to rummager. eg. DELETE /mainstream/documents/%2Fservice-manual%2Fthe-slug?_type=service_manual_guide
  4. Send a request body along the lines of {"_type" : "service_manual_guide"} in the DELETE from rummageable. #delete already supports passing in a :type in the options but it's merged into the URL rather put into the request body. Perhaps we could call the option :forced_type? So the code in our publishers would look something like Rummageable::Index.new(Plek.current.find('rummager'), '/mainstream').delete('/service-manual/the-slug', forced_type: 'service_manual_guide')

I'm not sure which is best / the least dangerous. Personally, I prefer the last option. It feels to me as though rummager supports the desired behaviour and it's rummageable that doesn't support it?

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.