0

I see that the results page only shows results if the "keys" parameter matches a complete word. how Can i configure the core search engine to also show results for incomplete words?

I am using core search module .

1 Answer 1

-1

Actually there's a quick way to set this up with the Search API and the Search API Database Search modules. No need for Solr.

Enable both the modules and go to the Search API configuration page (admin/config/search/search_api)Add a server and give it a recognizable name (such as "MySQL"), make sure it's enabled.

Choose the following service class: Database service (normally the only option. If you don't see it, make sure that the "Search API Database Search" module is enabled).

Selecting this service class will provide you the option Search on parts of a word (make sure you enable it). Now hit "Create server".

Next, go back to the Search API configuration page, and add an index. Again give it a recognizable name, such as "Contentindex", and make sure it's enabled. Select the server you recently created (in this example "MySQL"). Datasource options: check the content types you want to index (the description of this field may be a bit confusing, but make no mistake: you should check the content types you want to index, not the ones you want to leave out).

You could check "Index items immediately", but that depends on the size of your content. This option is alright for smaller websites. In the other case: let cron take care of it. Hit "Create index".

Next, you want to enable the fields (in the fields tab) to that very index, e.g.: content type, title, status and author - and hit "Save changes" (we'll take care of the related fields later).

Then you want to configure the filters (in the filter tab). Here you can enable the bundle filter, if you want to finetune the content types once again (probably won't need to). Down below you'll find the highlight filter, to highlight the search word in the results. Now return to the fields tab and unfold the "Add related fields" tab. Add all the fields of which you want to get the content indexed, and hit Save.

Finally go to the "view" tab of the index, and index now all the items. The last step is to create search results page and search block in Views, which only takes a few minutes.

Make sure the submodule Search Views is enabled and create a view page which will show "Contentindex" (select the name you gave to your index configuration instead of "content" which is selected by default.

Add all the fields (make sure your format is "fields") that every search result should consist of (title [link to content], body, …).

You'll notice that these fields look like this Indexed Node: Title Add an exposed filter: Search: Fulltext search; and select the following in its settings: Contains any of these words, and use as: Search keys.

You're done!

3
  • How does this actually solve the problem though? It sounds like this person wants to not do a strict search by keyword and have it be more 'loose' or fuzzy. Solr is the perfect tool for that.
    – Kevin
    Commented Nov 12, 2018 at 19:42
  • this solution is not for drupal 8
    – user52318
    Commented Nov 13, 2018 at 6:44
  • I mean, Search API exists for Drupal 8 but doesn't solve your question at all. For this you need something like Solr.
    – Kevin
    Commented Nov 17, 2018 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.