You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/ONSdigital/dp-census-alpha-search-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ONSdigital/dp-census-alpha-search-api

v0.0.0-20200828114157-9cc640957c20
Source
Go
Version published
Created
Source

dp-census-dataset-search-api

This is the census alpha search API application for census project. To provide a continuously improving working example of search features needed to answer questions posed during the 2021 census alpha project.

Requirements

In order to run the service locally you will need the following:

  • Go
  • Git
  • Java 8 or greater for elasticsearch
  • ElasticSearch (version 6.7 or 6.8)

Getting started

  • Clone the repo go get github.com/ONSdigital/dp-census-alpha-search-api
  • Run elasticsearch e.g. ./elasticsearch/bin/elasticsearch
  • Follow setting up data
  • Run make debug to start search API service

Follow swagger documentation on how to interact with local api, some examples are below:

curl -XOPTIONS localhost:10300/search -vvv
curl -XGET localhost:10300/search?q={term} -vvv
curl -XGET "localhost:10300/search?q={term}&offset=5&limit=5" -vvv
curl -XGET "localhost:10300/search?q={term}&topics={topic}" -vvv (see taxonomy endpoint for topic filter options)
curl -XGET "localhost:10300/search?q={term}&dimensions={dimension}" -vvv (see dimensions endpoint for dimension filter options)
curl -XGET "localhost:10300/search?q={term}&hierarchies={geographical hierarchy}" -vvv (see hierarchies endpoint for hierarchy filter options)


curl -XGET localhost:10300/area-profiles/{id} -vvv
curl -XGET localhost:10300/area-profiles/{id}/search?q={term} -vvv (can use the dimensions and topics filter as well as offset and limit params to page through results)

curl -XGET localhost:10300/taxonomy -vvv
curl -XGET localhost:10300/taxonomy/{topic} -vvv
curl -XGET localhost:10300/dimensions -vvv
curl -XGET localhost:10300/hierarchies -vvv

Setting up data

Once elasticsearch is running and you can connect to your instance. Follow the instructions here to load in some prepared cmd datasets.

Configuration

Environment variableDefaultDescription
BIND_ADDR:10300The host and port to bind to
AREA_PROFILE_SEARCH_INDEXarea-profilesThe index in which the area profile documents are stored in elasticsearch
DATASET_SEARCH_INDEXdatasetsThe index in which the dataset documents are stored in elasticsearch
POSTCODE_SEARCH_INDEXpostcodesThe index in which the postcode documents are stored in elasticsearch
ELASTIC_SEARCH_URLhttp://localhost:9200The host name for elasticsearch
MAX_SEARCH_RESULTS_OFFSET1000The maximum offset for the number of results returned by search query
SIGN_ELASTICSEARCH_REQUESTSfalseBoolean flag to identify whether elasticsearch requests via elastic API need to be signed if elasticsearch cluster is running in aws
DIMENSIONS_FILENAMEdata/dimensions.jsonThe json file that contains a list of dimensions that can be used to filter results from search endpoint
HIERARCHIES_FILENAMEdata/hierarchy.jsonThe json file that contains a list of geographical hierarchies that can be used to filter results from search endpoint
TAXONOMY_FILENAMEdata/taxonomy.jsonThe json file that contains a list of topics that can be used to filter results from search endpoint

Notes

See command list for a list of helpful commands to run alongside setting up data, useful to check what search indexes exist and their individual mappings and number of documents etc..

One can run the unit tests with make test

FAQs

Package last updated on 28 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts