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

[NodeSearchBundle][SearchBundle] Multi domain/language search population fix #1635

Merged
merged 4 commits into from Nov 18, 2017

Conversation

cv65kr
Copy link
Contributor

@cv65kr cv65kr commented Nov 6, 2017

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets #1246

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.

@Numkil Numkil self-assigned this Nov 15, 2017
$localeAnalysis = clone($analysis);
$language = $this->analyzerLanguages[$locale]['analyzer'];
// Multilanguage check
if ( count(preg_grep('/[a-z]{2}_?+[a-zA-Z]{2}/', [$locale])) > 0 ) {
Copy link
Contributor

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" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandergo90 sure, fixed.

Copy link
Contributor

@Numkil Numkil left a 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)
Copy link
Contributor

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)
Copy link
Contributor

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);
Copy link
Contributor

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?

@Numkil
Copy link
Contributor

Numkil commented Nov 15, 2017

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.

@cv65kr
Copy link
Contributor Author

cv65kr commented Nov 15, 2017

@Numkil I saw that, but i had to leave ;) i will try to fix that today

@cv65kr cv65kr force-pushed the search-population-fix branch 2 times, most recently from cd0584f to 8cae086 Compare November 15, 2017 17:31
@Numkil
Copy link
Contributor

Numkil commented Nov 15, 2017

No hurries I will review it when you are finished.

@cv65kr cv65kr reopened this Nov 15, 2017
@cv65kr
Copy link
Contributor Author

cv65kr commented Nov 15, 2017

@Numkil done.
Going back to your question about strtolower, letters must be lowercase because elastic return exception if index name have a uppercase letters. Check out on my screenshot :)

elastic

$localeAnalysis = clone($analysis);
$language = $this->analyzerLanguages[$locale]['analyzer'];
// Multilanguage check
if (count(preg_grep('/[a-z]{2}_?+[a-zA-Z]{2}/', [$locale])) > 0) {
Copy link
Contributor

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?

Copy link
Contributor Author

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([]);
Copy link
Contributor

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".

Copy link
Contributor Author

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([]);
Copy link
Contributor

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

@cv65kr
Copy link
Contributor Author

cv65kr commented Nov 17, 2017

@Numkil something like that?

@Numkil
Copy link
Contributor

Numkil commented Nov 17, 2017

@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!

@cv65kr
Copy link
Contributor Author

cv65kr commented Nov 17, 2017

@Numkil ohhh, already fixed :)

@Numkil Numkil changed the base branch from 5.0 to 4.0 November 18, 2017 10:09
@Numkil Numkil changed the base branch from 4.0 to 5.0 November 18, 2017 10:12
@Numkil Numkil merged commit 2f4fd20 into Kunstmaan:5.0 Nov 18, 2017
@Numkil
Copy link
Contributor

Numkil commented Nov 18, 2017

@cv65kr thanks for the contribution.

@cv65kr
Copy link
Contributor Author

cv65kr commented Nov 18, 2017

@Numkil, no problem :) You can close #1246 because its solved by this PR.

Devolicious pushed a commit that referenced this pull request Apr 13, 2018
…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
Devolicious pushed a commit that referenced this pull request Apr 27, 2018
* [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)
JZuidema pushed a commit to e-sites/KunstmaanBundlesCMS that referenced this pull request Jun 22, 2018
…#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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants