Sreejith rajan
Sreejith rajan

Reputation: 23

Drupal8 partial keyword searching

I integrated Drupal 8 autocomplete module in my project. Its working fine. At the end search suggestion liss, there is a link for view all results. When I click on the link, it goes to localhost/sampleapp/search/node?keys=test. I got all the results for the keyword "test". But the problem is when the keyword is tes instead of test, I got no results. For example localhost /sampleapp/search/node?keys=tes

Upvotes: 2

Views: 1608

Answers (2)

Rookie Rod
Rookie Rod

Reputation: 364

Acquia Search supports Solr N-Gram (partial-word search) text fields for Drupal 8 websites using the Search API module.

  • In the admin menu, go to Configuration > Search and metadata > Search API.
  • Identify the search index that you want to modify, and then click it.
  • Click the Fields tab.
  • For each field that you want to configure for partial-word searching, click Type, and then click Fulltext NGram.
  • Click Save.

https://docs.acquia.com/acquia-search/relevant-results/partial/

Upvotes: 2

Ahmed Maruf
Ahmed Maruf

Reputation: 511

You can alter the queries provided by default. A similar action you can look into this as reference:

<?php 
// Add alter hook to be able to change suggestions in your own module.
$alter_data = array(
    'query' => $query,
    'response' => $response,
    'incomplete_key' => $incomplete_key,
    'search' => $search,
);
drupal_alter('search_api_solr_autocomplete_suggestions', $alter_data, $suggestions);
?>

Hope this help.

Thanks.

Upvotes: 0

Related Questions