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
[NodeSearchBundle][SearchBundle] Multi domain/language search population fix #1635
Conversation
$localeAnalysis = clone($analysis); | ||
$language = $this->analyzerLanguages[$locale]['analyzer']; | ||
// Multilanguage check | ||
if ( count(preg_grep('/[a-z]{2}_?+[a-zA-Z]{2}/', [$locale])) > 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cv65kr can you remove the space before "count" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandergo90 sure, fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you sqaush your commits to 1 commit ? I will be testing your PR later this evening :)
@@ -318,7 +326,7 @@ public function setAnalysis(Index $index, AnalysisFactoryInterface $analysis) | |||
* | |||
* @return Mapping | |||
*/ | |||
protected function createDefaultSearchFieldsMapping(Index $index, $lang = 'en') | |||
protected function createDefaultSearchFieldsMapping(Index $index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you undo this change? I know it looks stupid but this is necessary to avoid BC breaks on older projects that still require $lang in this method.
@@ -334,7 +342,7 @@ protected function createDefaultSearchFieldsMapping(Index $index, $lang = 'en') | |||
* @param Index $index | |||
* @param string $lang | |||
*/ | |||
protected function setMapping(Index $index, $lang = 'en') | |||
protected function setMapping(Index $index, $lang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you undo this change? I know it looks stupid but this is necessary to avoid BC breaks on older projects that still require $lang in this method.
@@ -77,6 +77,8 @@ public function getClient() | |||
*/ | |||
public function createDocument($uid, $document, $indexName = '', $indexType = '') | |||
{ | |||
$indexName = strtolower($indexName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing strtolower here?
cd0584f
to
fccc38b
Compare
hey @cv65kr you seem to have made a mistake in your rebase/squash procedure and your commit now contains commits from other people not in this branch yet. |
@Numkil I saw that, but i had to leave ;) i will try to fix that today |
cd0584f
to
8cae086
Compare
No hurries I will review it when you are finished. |
290be4b
to
d567167
Compare
@Numkil done. |
$localeAnalysis = clone($analysis); | ||
$language = $this->analyzerLanguages[$locale]['analyzer']; | ||
// Multilanguage check | ||
if (count(preg_grep('/[a-z]{2}_?+[a-zA-Z]{2}/', [$locale])) > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use preg_match instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
// Create index with analysis | ||
$this->setAnalysis($index, $localeAnalysis->setupLanguage($language)); | ||
} else { | ||
$index->create([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a very clear warning happening here that says something like,
"hey we did not crash but something is wrong here, we could not set up any analysis for this language".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Numkil, You mean exception?
// Create index with analysis | ||
$this->setAnalysis($index, $localeAnalysis->setupLanguage($language)); | ||
} else { | ||
$index->create([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best course of action is to somehow show a warning in the command output. Otherwise it will not be clear for developers why their search might not be behaving as expected without manually checking the index metadata. If a simple message is shown in the console command output then at least users will immediately know that they forgot to define an analyzer language
@Numkil something like that? |
@cv65kr yes this is awesome! I saw one little typo where you typed answear instead of answer but if you fix that I will merge this PR tonight or tomorrow. Thank you for your help and quick responses! |
@Numkil ohhh, already fixed :) |
@cv65kr thanks for the contribution. |
…pport bundles 3.6 websites on servers with ES6 (#1877) * [NodeSearchBundle]: fix request scope * [NodeSearchBundle] Make NodeSearcher properties protected for extending * [NodeSearchBundle]: add possibility to index multiple regions [NodeSearchBundle]: make contexts default array, and merge default * [KunstmaanNodeSearchBundle]: upgrade elastica to 5.1 Change ruflin elastica version [KunstmaanNodeSearchBundle]: upgrade elastica to 5.1 Add changelog * move boost from mapping to query + allow text as type for elasticsearch 5.0 * [NodeSearchBundle] Bugfix for indexing StructuredNodes and children (#1550) [NodeSearchBundle] Bugfix for indexing StructuredNodes and children * [NodeSearchBundle] Bugfix for indexing StructuredNodes and children * [NodeSearchBundle][SearchBundle] Multi domain/language search population fix (#1635) * squash commits * Analyzer info in command * Typo fix * typo * [NodeSearchBundle]: check if we have html * [NodeSearchBundle] shards and replicas configurable [NodeSearchBundle] default values shards/replicas * [SearchBundle][FIX] Populate command failing * [SearchBundle] Convert analyzer languages config to lowercase to prevent config mismatch because of case sensitivity * [SearchBundle] SetupIndex command failing when overwriting nodeconfiguration with own file. * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle] add punctuation to kuma_ngram tokenizer * [NodeSearchBundle] added extra properties for elasticsearch mapping (#1794) * [KunstmaanNodeSearchBundle] add keyword as data type (#1793) [KunstmaanNodeSearchBundle]: change data types Revert keyword to string for compability with 2.4 * [NodeSearchBundle] Elastic search version 6 support * [NodeSearchBundle] Elastic search version 6 support * [NodeSearchBundle] backport fixes * [allbundles] bump phpversions
* [SeoBundle]: change meta length (#1520) [SeoBundle]: change translations * [SeoBundle] Refactor seo description to be longer according to google's new length (#1797) * [NodeSearchBundle] [SearchBundle] ElasticSearch Backport so we can support bundles 3.6 websites on servers with ES6 (#1877) * [NodeSearchBundle]: fix request scope * [NodeSearchBundle] Make NodeSearcher properties protected for extending * [NodeSearchBundle]: add possibility to index multiple regions [NodeSearchBundle]: make contexts default array, and merge default * [KunstmaanNodeSearchBundle]: upgrade elastica to 5.1 Change ruflin elastica version [KunstmaanNodeSearchBundle]: upgrade elastica to 5.1 Add changelog * move boost from mapping to query + allow text as type for elasticsearch 5.0 * [NodeSearchBundle] Bugfix for indexing StructuredNodes and children (#1550) [NodeSearchBundle] Bugfix for indexing StructuredNodes and children * [NodeSearchBundle] Bugfix for indexing StructuredNodes and children * [NodeSearchBundle][SearchBundle] Multi domain/language search population fix (#1635) * squash commits * Analyzer info in command * Typo fix * typo * [NodeSearchBundle]: check if we have html * [NodeSearchBundle] shards and replicas configurable [NodeSearchBundle] default values shards/replicas * [SearchBundle][FIX] Populate command failing * [SearchBundle] Convert analyzer languages config to lowercase to prevent config mismatch because of case sensitivity * [SearchBundle] SetupIndex command failing when overwriting nodeconfiguration with own file. * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle] add punctuation to kuma_ngram tokenizer * [NodeSearchBundle] added extra properties for elasticsearch mapping (#1794) * [KunstmaanNodeSearchBundle] add keyword as data type (#1793) [KunstmaanNodeSearchBundle]: change data types Revert keyword to string for compability with 2.4 * [NodeSearchBundle] Elastic search version 6 support * [NodeSearchBundle] Elastic search version 6 support * [NodeSearchBundle] backport fixes * [allbundles] bump phpversions * update changelog * [AdminlistBundle] fixed type from string to array (#1925)
…#1936) * [SeoBundle]: change meta length (Kunstmaan#1520) [SeoBundle]: change translations * [SeoBundle] Refactor seo description to be longer according to google's new length (Kunstmaan#1797) * [NodeSearchBundle] [SearchBundle] ElasticSearch Backport so we can support bundles 3.6 websites on servers with ES6 (Kunstmaan#1877) * [NodeSearchBundle]: fix request scope * [NodeSearchBundle] Make NodeSearcher properties protected for extending * [NodeSearchBundle]: add possibility to index multiple regions [NodeSearchBundle]: make contexts default array, and merge default * [KunstmaanNodeSearchBundle]: upgrade elastica to 5.1 Change ruflin elastica version [KunstmaanNodeSearchBundle]: upgrade elastica to 5.1 Add changelog * move boost from mapping to query + allow text as type for elasticsearch 5.0 * [NodeSearchBundle] Bugfix for indexing StructuredNodes and children (Kunstmaan#1550) [NodeSearchBundle] Bugfix for indexing StructuredNodes and children * [NodeSearchBundle] Bugfix for indexing StructuredNodes and children * [NodeSearchBundle][SearchBundle] Multi domain/language search population fix (Kunstmaan#1635) * squash commits * Analyzer info in command * Typo fix * typo * [NodeSearchBundle]: check if we have html * [NodeSearchBundle] shards and replicas configurable [NodeSearchBundle] default values shards/replicas * [SearchBundle][FIX] Populate command failing * [SearchBundle] Convert analyzer languages config to lowercase to prevent config mismatch because of case sensitivity * [SearchBundle] SetupIndex command failing when overwriting nodeconfiguration with own file. * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle][FIX] SetupIndex command failing * [SearchBundle] add punctuation to kuma_ngram tokenizer * [NodeSearchBundle] added extra properties for elasticsearch mapping (Kunstmaan#1794) * [KunstmaanNodeSearchBundle] add keyword as data type (Kunstmaan#1793) [KunstmaanNodeSearchBundle]: change data types Revert keyword to string for compability with 2.4 * [NodeSearchBundle] Elastic search version 6 support * [NodeSearchBundle] Elastic search version 6 support * [NodeSearchBundle] backport fixes * [allbundles] bump phpversions * update changelog * [AdminlistBundle] fixed type from string to array (Kunstmaan#1925)
Now we can use language names like "en", "en_US", "en_us", also fixes error mentioned in #1246 ticket.
--edited by numkil
Also with new feature to check for unavailable language analyzers and prompt the user.