Search Elastic
The elastic search module works alongside the Search Crawler to extract pages from the site into an elastic search instance to enable site wide search
The module registers itself to listen for the search crawler events and creates locale based indexes in the elastic repo for any pages it receives
When indexing the pages, if there is a primary data type then this will also be indexed against the page in primaryObject, this can then be used in query values as explained below
The indexing process is controlled by execution of the search crawler via the site automations
The module contains a Readme.txt file which gives help for the initial setup of elastic but the creation of the indexes/content are all automated.
Installation
The basic setup steps are
- Install the following socialstack modules
- Api/SearchCrawler
- Api/SearchElastic
- UI/SiteSearch
- Mark any pages not to be indexed
- Install Elastic Search (see Readme.txt in the repo for help and guidance)
- Configure the sizing/scale in the elasticsearch.yml file (mainly vm memory usage)
- Start Elastic Search for the first time and get the master password and certificate fingerprint
- Add the url, credentials and fingerprint values to the module configuration via the ss admin panel
- Run the automation to index the site, the indexing progress is shown via the console
The module also contains a postman collection which can be used to quick debug/verify the indexed content
Once indexed there is a UI/SiteSearch module which can be used as the basis of the site search
Endpoints
GET /v1/sitesearch/reset
This removes any indexes from elastic to allow a clean start
POST /v1/sitesearch/query
This is the core search endpoint which currently accepts the following values
- queryString
- The query value entered by the user and/or the UI/SiteSearch component, elastic search uses the Lucene query language so you can build complex queries
- https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
- e.g.
Africa AND primaryObject.name:BotswanaprimaryObject.price:(>=1000 AND <5000)
- tags
- This expects a list of comma separated tags, if any are supplied the query will only return results which contain all the pased tag values
- contentTypes
- This expects a list of comma separated content types, if any are supplied the query will only return results which contain all the passed content types, these are normally the primary data object for the page
- pageSize
- This expects the page size and will default to 10 if not populated
- startFrom
- This expects the starting row and will default to 0