I have implemented an Algolia search in my drupal instance and would like to use the node url alias (/some-example-path) rather than node id (/node/{nodeId}). Is there a quick and easy way to do this using the Search API?


Use PathAuto module

The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change.

For learn how work with it read How to Use Pathauto in Drupal 8

  • Thank you, I currently have Pathauto setup to allow for these, but the problem I am having is sending the url alias from drupal to algolia for indexing. I do not see an available field for these values to send to algolia. I am using the search api plugin to select the node fields I send. Mar 28 '17 at 21:32
  • @travisbrkr1234 which module you are using to integrate drupal with algolia?
    – Yuseferi
    Mar 28 '17 at 21:46
  • I am using the Search API module to configure the index (drupal.org/project/search_api) and (drupal.org/project/search_api_algolia) to send the fields to algolia. Mar 28 '17 at 23:55
  • I suppose the better question would be: should I be extending the search api module to allow me to index the url aliases? or is there some way I can configure the content types to include a field that is the alias? Mar 31 '17 at 22:06
  • I ended up writing my own interceptor for the indexing service. I iterate through the associated nodes and pull the title from the node, clean it up and append it to a url string. Apr 27 '17 at 16:07

I wrote an interceptor for the indexing service. I iterate through the associated nodes and pull the title from the node, clean the title text of any entities/special characters and append it to a "url string".


Using Search API in Drupal 8, you could write a custom processor to create dynamic custom fields which will then be indexed by Algolia, Solr or whatever Search API supports.

Documentation: https://www.drupal.org/docs/8/modules/search-api/developer-documentation/create-custom-fields-using-a-custom-processor


For D7: Under the Configuration -> Search and Metadata -> Search_API and then go to the Algolia Index and Filters tab (path will be like: /admin/config/search/search_api/index/algoliaindex/workflow, where algoliaindex is the machine name of your Algolia index), then under Data Alterations->Enabled data alterations check the URL field box. This will add a field to your Algolia index called search_api_url.

TIP: If you want to be able to search for text anywhere in the node (not just in indexed fields, you can also check the Complete entity view option. Under Processors for Complete entity view use the HTML filter. Under Processor settings at the bottom of the page, for HTML filter->Fields to run on check Entity HTML output and delete all contents from the Tag boosts field (otherwise it will index the boosts as well and you'll have to change your displayed search index values on the front-end). This will then add a plain-text version of the node as a field in your index called search_api_viewed that you can display in your search results.

screenshot of Search_API->Filters configuration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.