Coder Social home page Coder Social logo

search's Introduction

Search

This service is used on the informational sites to provide an API for search queries. It receives search requests from the browser, formats them into Elasticsearch queries which are then executed, and the results returned to the browser.

This application provides endpoints for:

  • querying an index using a search template;
  • querying a type of document in an index using a search template;
  • autocompletion of search results.

This service proxies search requests so that Elasticsearch doesn't have to be exposed directly to the internet. It limits the queries that are forwarded to Elasticsearch, and is intended to limit the attack surface area.

Configuration

  • port
    • The port number to listen on for HTTP requests.
    • Type: integer (0-65535)
    • Default: 8082
  • index
    • The URL for the Elasticsearch index to be queried.
    • Type: URL
    • Default: http://localhost:9200/livecontent

Monitoring

The healthcheck endpoint is GET /health. The endpoint returns a JSON response with the properties listed below. The status code is 200 if the service is healthy, and 503 otherwise.

  • ok
    • Indicates whether the search index is available and contains content.
    • Type: boolean
  • elasticsearch
    • Indicates whether Elasticsearch appears to be up. It is considered up if an HTTP response is received, even if the status code indicates an error. This is used to indicate connectivity to Elasticsearch only. See also: index.
    • Type: boolean
  • index
    • Indicates whether the index is available to the extent that a simple search query returns a 200 response code.
    • Type: boolean
  • shards
    • Indicates whether all the shards in the index are OK.
      This property is not present if index is false.
    • Type: boolean
  • documents
    • The number of documents in the index.
      This property is not present if index is false.
    • Type: boolean
  • message
    • The URL for the Elasticsearch index to be queried.
    • Type: boolean

The check-search script in this repository is a Nagios plugin that queries the healthcheck endpoint, returning the appropriate status code for Nagios. It also outputs a summary of the current status. The output information that shows up as performance data in Nagios, which includes the status of Elasticsearch; the availability of the index; document count and shard health.

Integration tests

The tests in the scot.mygov.search.it package are integration tests that depend on a running instance of Elasticsearch. These tests can be run using mvn verify. This starts up an Elasticsearch instance as part of the maven build, and stops it after running the integration tests.

Using Maven to run tests can be slow, because of the time it takes to start Elasticsearch. Instead, when developing tests, run the ./run-es script in the top-level directory to run an Elasticsearch instance. This allows integration tests to be run from the IDE. Press Ctrl+C to stop the instance, before running Maven again.

search's People

Contributors

kbaigrie avatar martiell avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

uk-gov-mirror

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.