- Install Drupal 7.x
- Copy 'elasticsearch' and 'pathauto' folders to root/sites/all/modules
- Log in to Drupal as an administrator
- Install
Token
module from here - https://www.drupal.org/project/token - Go to modules page and activate 'Elasticsearch' module
- Go to Configuaration -> Search Settings and Activate Elasticsearch as a Search Module
- Also set it as the default search module
- elasticsearch_menu()
- mylog($logstring)
- search_it($query)
- perform_search()
- elasticsearch_search_execute($keys = NULL, $conditions = NULL)
- elasticsearch_search_info()
This is the Drupal Hook which registers hostname
/elasticsearch/search as a route in the Drupal ecosystem.
It returns an array containing the title, path, permissions, callback function and callback type associated with this route.
Currently, it registers hostname
/elasticsearch/search as a route which is visible on the Navigation Bar of any user.
A logging utlity which logs into a file named log.txt
in the Elasticsearch module folder. This function can be used in other modules as well.
This function takes a string argument and returns a JSON formatted string. The argument string is sent as a query to the Elasticsearch instance. The parameters for the ES instance are host
http://localhost:9200 credentials
elastic:changeme method
POST.
This is the Drupal hook for the event search execute
. This function runs when a user has entered a query in the search box and pressed the search button. $keys is the user query, which is a string. $conditions are filters which a user applies when using advanced search.
This function calls the search_it
function to get the results from the ES store. It then conforms the data according to Drupal's rules of formatting search results.
The fields 'link','type', 'title', 'user', 'date, 'node, 'extra', 'score', 'snippet' are required by Drupal as essential fields of a valid search result and thus they are set, either with a value from ES store or NULL.
This is the Drupal hook which registers the current module as a Active Search Module
and allows replacing of default search results with our own, as long as they are in a valid format, as explained above.