Search engine for agencies' published content
- Ruby
Use rvm to install the version of Ruby specified in .ruby-version.
The required services (MySQL, Elasticsearch, etc.) can be run using Docker. Please refer to searchgov-services for detailed instructions on centralized configuration for services.
The Elasticsearch services provided by searchgov-services is configured to run on the default port, 9200. To use a different host (with or without port) or set of hosts, set the ES_HOSTS environment variable. For example, use following command to run the specs using Elasticsearch running on localhost:9207:
ES_HOSTS=localhost:9207 bundle exec rspec spec
Verify that Elasticsearch 7.17.x is running on the expected port (port 9200 by default):
$ curl localhost:9200
{
"name" : "002410188f61",
"cluster_name" : "es7-docker-cluster",
"cluster_uuid" : "l3cAhBd4Sqa3B4SkpUilPQ",
"version" : {
"number" : "7.17.7",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "78dcaaa8cee33438b91eca7f5c7f56a70fec9e80",
"build_date" : "2022-10-17T15:29:54.167373105Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
bundle install.- Copy
config/secrets_example.ymltoconfig/secrets.ymland fill in your own secrets. To generate a random long secret, userake secret. - Run
bundle exec rake i14y:setupto create the neccessary indexes, index templates, and dynamic field templates.
If you ever want to start from scratch with your indexes/templates, you can clear everything out:
bundle exec rake i14y:clear_all
- Run the Rails server on port 8081 for compatibility with the search-gov app:
$ rails s -p 8081
You should see the default Rails index page on http://localhost:8081/.
We use Rubocop for static code analysis. Settings specific to I14Y are configured via .rubocop.yml. Settings that can be shared among all Search.gov repos should be configured via the searchgov_style gem.
$ curl -u dev:devpwd -XPOST http://localhost:8081/api/v1/collections \
-H "Content-Type:application/json" -d \
'{"handle":"test_collection","description":"my test collection","token":"test_collection_token"}'
Use the collection handle and token for authorization:
curl http://localhost:8081/api/v1/documents \
-XPOST \
-H "Content-Type:application/json" \
-u test_collection:test_collection_token \
-d '{"document_id":"1",
"title":"a doc about rutabagas",
"path": "http://www.foo.gov/rutabagas.html",
"created": "2020-05-12T22:35:09Z",
"description":"Lots of very important info on rutabagas",
"content":"rutabagas",
"promote": false,
"language" : "en",
"tags" : "tag1, another tag"
}'
$ curl -u dev:devpwd http://localhost:8081/api/v1/collections/search?handles=test_collection&query=rutabaga
# Fire up Elasticsearch in search-services
$ docker-compose up elasticsearch7
$ bundle exec rake i14y:setup
$ rake