Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requires additional hook? #7

Open
stankut opened this issue Jul 16, 2018 · 1 comment
Open

Requires additional hook? #7

stankut opened this issue Jul 16, 2018 · 1 comment

Comments

@stankut
Copy link

stankut commented Jul 16, 2018

First of all, thank you for your contribution.

Secondly i have had some problems with this module and it only started working after i have added new hook in my custom module.

function MYMODULE_search_api_solr_query_alter(\Solarium\Core\Query\QueryInterface $solarium_query, \Drupal\search_api\Query\QueryInterface $query) {
  $solarium_query->addParam('spellcheck', 'on');
}

Is there something i missed while configuring it, or it does not work by itself?

Thirdly, are you planning to add it to contrib modules? The spelling suggestions is something many people might need.

@DrColossos
Copy link

DrColossos commented Sep 13, 2018

Had the same issues, but solved it a little more complex, mainly because "spellcheck on" did not work at all

function MODULE_search_api_solr_converted_query_alter(\Solarium\QueryType\Select\Query\Query $solarium_query, \Drupal\search_api\Query\QueryInterface $query) {

	if( $query->getOption('search_api_spellcheck', FALSE) ) {
		$original_keys = $query->getOriginalQuery()->getKeys();

		if( empty($original_keys) ) {
			return;
		}

		array_pop($original_keys);
		$solarium_query->getSpellcheck()->setQuery(implode(' ', $original_keys));
		$solarium_query->getSpellcheck()->setCount(10);
		$solarium_query->getSpellcheck()->setOnlyMorePopular(true);
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants