Skip to content

laws-africa/indigo-search-psql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

indigo-search-psql

This is a plugin for Indigo that adds a search API to the published document API, based on PostgreSQL's vector search fields. It is a quick-and-easy way of supporting full-text search.

The API is available by default at /api/v2/search/<country>.

Usage

Install with pip install git+https://github.com/laws-africa/indigo-search-psql.git#egg=indigo-search-psql.

Add indigo_search_psql to your INSTALLED_APPS setting in your settings.py file, above indigo:

INSTALLED_APPS = [
    'indigo_search_psql',
    'indigo',
    ...
]

Include the URLs in your urls.py after the indigo URLS:

urlpatterns = [
    path('', include('indigo.urls')),
    path('api/', include('indigo_search_psql.urls')),
]

Run migrations to setup the database:

python manage.py migrate indigo_search_psql

And finally re-index all existing documents. This only needs to be done once. After this, updated documents are re-indexed automatically.

python manage.py index_for_psql_search

URLs

This adds a new URL to the API:

GET /api/v2/search/<country>?q=<search-term>
  • Where <country> is a two-letter country code
  • Parameter q: the search string
  • Content types: JSON

This API searches for works in a country. It returns all works that match the search term in either their title or their body. Results are returned in search rank order. Each result also has a numeric _rank and an HTML _snippet with highlighted results.

If more than one expression of a particular work matches the search, then only the most recent matching expression is returned.

Development

  1. Clone this repo
  2. Setup and activate a python3 virtualenv
  3. Install dependencies: pip install -e .

Running tests

Use python runtests.py to run tests.

License and Copyright

The project is licensed under a GNU GPL 3 license.

Indigo is Copyright 2015-2020 AfricanLII.

About

Plugin for Indigo that support PostgreSQL-driven full-text document search

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages