Giter Club home page Giter Club logo

docmanager's Introduction

This is a backend for Transparency Toolkit's other tools (LookingGlass, Harvester, Catalyst). It indexes data, stores the documents, and processes queries all in one place. All the specifications for what data sources are available and what fields they have are also handled by DocManager.

Installation

Dependencies

  • elasticsearch 5.4.0
  • ruby 2.4.1
  • rails 5
  • postgresql

Setup Instructions

  1. Install the dependencies and configure
  1. Run
  • Start elasticsearch (exact method depends on installation method)
  • rails server

Software and Config File Structure

Project and Data Source Configuration Files

Configuration files for data sources and projects are stored in the dataspec_files directory. This has three directories with three types of sub-files-

  • projects: A project is a collection of all data on a particular topic (or that you want stored in the same elasticsearch index). It is only possible to access one project at a time, but you can switch between multiple projects. Each project can have multiple data sources. The configuration files specifying what data sources a project includes, what it is called, etc. are in the projects directory.
  • data_sources: Each data source needs a config file to specify what fields it has, where each should show up on the various apps, it's name, etc. The correct data source file is automatically loaded into the other apps when needed and all supported data sources have pre-written config files.
  • fields_for_all_sources: These config files specify what fields every data source has, such as those Harvester uses for managing versions and threads. The fields in this directory will be loaded into every data source automatically.

These files are automatically loaded into DocManager and used by the apps that query it. But the specific project you want to access/use may need to be set in configuration options in the other apps.

Code Outline

The code is divided into the following components:

  • analyzers: Config files that elasticsearch uses to determine how it should index data in various languages.
  • controllers: Handle incoming requests to the API. These don't have much content themselves, but mostly include other functions for managing indexing, queries, and dataspecs.
  • dataspec: Load in the project and data source config files, generate models for new data sources using metaprogramming, and retrieves the appropriate source and project objects when requested.
  • index: Indexes the data in elasticsearch, including preprocessing tasks like setting a unique ID (that is consistent across reindexes), tracking different versions of the same data, handling different formats of date fields, and generally managing messy data. Also handles data deletion.
  • models: Specify the fields that should be saved in the database for projects and data sources. Most of the management and creation of these sources is initially handled in the modules in the dataspec directory.
  • queries: Process and run elasticsearch queries. Includes everything from getting the documents to load and showing the total number to actual search queries.

docmanager's People

Contributors

bnvk avatar shidash avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

docmanager's Issues

Set Catalyst Defaults

Add the default values for fields that should be searched for each document type by default to the dataspec.

Upgrade to Elasticsearch 7

This is a major upgrade because document types were removed (and these are used heavily within TT). Most likely the document types should be separate indexes or in the same index but managed as part of the document ID.

Document IDs not Tied to Title

Currently, changing the title of a document or other field used in the ID on pre-publication archive may result in creation of a second document on the public instance. The document ID should either be passed to the public instance (and constant) or a based on a non-user-changeable (but unique) field.

Delete Document Removes File

Deleting a document should also delete the file as long as it isn't associated with any other documents too (check for this). This behavior may need to be changed depending on how distributed storage works.

Track Deleted Documents

Track documents that have been deleted (maybe by hash?) so that they can also be removed on public instance.

Move Instance-Specific Dataspecs

Remove the instance-specific dataspecs from the DM repository and move them to another repository with instructions on how to use them. These will probably still be used from time to time, but we should move towards users creating custom dataspecs via the UI on the hosted system rather than having to work with the raw JSON files.

Deduplicate Dataspecs

Currently there are duplicate copies of dataspecs to match what the publication step generates. Deduplicate these.

Check if document already published

Currently the publish function only sends documents updated since it was last run. But someone could choose a different set of documents or fields to publish. So, instead, the following should be checked-

  1. Publication date
  2. Document published
  3. Fields document published with

The publication date should be used if the document was already published WITH the same fields. If it hasn't been updated and is same field combo, document should not be published.

If it doesn't match and the document matches publication query, it should be resent. If the document wasn't published, it should be republished.

Use Language in Project Spec

Ensure that-

  1. The language for the index is saved with the project spec
  2. This language is actually set as the index language

Probably there also needs to be a function to change the index language when this updates, but this may be rare. More likely is someone will want a second index for another language.

rake command failing

Hi, after running the rake db:create db:migrate, I get the following error:

rake aborted!
NoMethodError: undefined method client= for Elasticsearch::Persistence:Module
/opt/DocManager/config/initializers/elasticsearch.rb:2:in <main>

Just wondering if this is an issue due to version or am I missing anything in previous steps. Thanks for all your help.

Remove Deleted Documents

Deleted documents (maybe since last batch) tracked with #10 should be removed from public instance when republish is run. Since they are deleted, it is difficult to know if they match the conditions for publication. So perhaps all deleted should be removed each time publish is run.

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.