Problem/Motivation

We working on a project that needs to segregate the response from SOLR coming from separate cores into separate blocks. This is a great module for doing a direct search with SOLR server, but doesn't provide a way to layout the results.

Proposed resolution

Create a block plugin, that can accept configurations for cores/fields on the basis of which we want to segregate result sets.

Comments

piyuesh23 created an issue. See original summary.

dishabhadra’s picture

Assigned: Unassigned » dishabhadra
dishabhadra’s picture

StatusFileSize
new1.46 KB

Created a Block Plugin for solr core.
But configuration are not done.

swarad07’s picture

StatusFileSize
new1.57 KB
new817 bytes

Helping out with the issue of configurations not saving, it was a small issue of not using getConfiguration().

dishabhadra’s picture

StatusFileSize
new2.55 KB

I applied #4 and #3 patches. They worked fine.
I created a build function and attaching the patch for the same.

piyuesh23’s picture

Status: Active » Needs work

Good start with the patch. Adding few comments inline below:

  1. +++ b/src/Plugin/Block/CustomSolrSearchBlock.php
    @@ -0,0 +1,81 @@
    + * Provides a 'Result' Block
    

    We should be more descriptive here while defining what this block does.

  2. +++ b/src/Plugin/Block/CustomSolrSearchBlock.php
    @@ -0,0 +1,81 @@
    + *   id = "custom_solr_search_block",
    

    Should be renamed to custom_solr_search_result_block

  3. +++ b/src/Plugin/Block/CustomSolrSearchBlock.php
    @@ -0,0 +1,81 @@
    +class CustomSolrSearchBlock extends BlockBase {
    

    Classname should be CustomSolrSearchResultBlock.

  4. +++ b/src/Plugin/Block/CustomSolrSearchBlock.php
    @@ -0,0 +1,81 @@
    +    $servers = \Drupal::service('custom_solr_search.solr_servers')->getServers();
    

    No point of having $servers = array('all' => 'All') above since we overriding it below.

  5. +++ b/src/Plugin/Block/CustomSolrSearchBlock.php
    @@ -0,0 +1,81 @@
    +    $form['custom_block_servers'] = [
    

    Can we stick to one standard of defining the arrays. Its defined using PHP7 convention here [] while the result array on L#68 has array().

    I personally would stick with array().

  6. +++ b/src/Plugin/Block/CustomSolrSearchBlock.php
    @@ -0,0 +1,81 @@
    +    $arg = explode('/', $path);
    

    Using the plural form would be more correct semantically ($args).

  7. +++ b/src/Plugin/Block/CustomSolrSearchBlock.php
    @@ -0,0 +1,81 @@
    +    $results = \Drupal::service('custom_solr_search.search')->basicSearch($keyword, 0, 5, $server);
    

    We should be injecting the service rather than trying to call it directly here.

    The class should implement ContainerFactoryPluginInterface.

piyuesh23’s picture

piyuesh23’s picture

Status: Needs work » Needs review
StatusFileSize
new4.53 KB
new7.09 KB

Fixing the issues mentioned above.

Next steps:

Create tpl file & hook_theme for the dummy theme in use right now.

piyuesh23’s picture

StatusFileSize
new7.11 KB

Adding patch to handle view layer.

piyuesh23’s picture

piyuesh23’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
piyuesh23’s picture

Status: Needs review » Closed (fixed)