Skip to main content

Apache Solar Search

Apache Solr : -  Apache solr is a fast open-source Java search server.
Solr makes it easy to run a full-featured search server
Recent version -- Solr 8.11.1
default port: 8983
You can access your Solr admin panel by typing localhost:8983 in your browser.

Basic Solr Concepts:- Solr is able to achieve fast search responses because, instead of searching the text directly, it searches an index instead.


Solr is powered by Lucene, a powerful open-source full-text search library,


Limitation of default drupal Search:- 
1- default drupal search is for smaller sites only,
2- does’t deal with large content like 10k+, 
3- Limited operated
4- SQL is not designed as a searching language,
5- It runs and searches directly on the same databases,
6- RDBMS , is incapable to search well,


Benefits of using apache solr:- 
1- index and make searchable really a large amount of data from 10k up to millions,
2- Provide faceted search-based navigation like filter data based on author, date, tags, content type etc…
3-Provide Search autocomplete, Spelling suggestions, and content recommendation,
4- Provide fast search experience,
5- Expose all attributes of the node to search,
6- Place search function on a completely separate server,

Install the solr on the server,

Steps to Configure the Solr & Drupal :

Step1- Installed the apache solr if using own server (ignore if using any third part server like acquia search)
Step2- Install Search API Solr module in Drupal 8
Step3 - Configure Apache Solr with the Drupal Search API Solr Module
- Create a core in Apache Solr
- create a Solr server and index in your Drupal website
          - create a Search API index
          - Also add field for indexing
Step4- Download the config.zip file from the search API UI, and extract & move these files to solr config folder.
Step5- Index the data, It will store the data in the solr
Commands to execute the solr


 $ sudo service solr stop  
 $ sudo service solr start  
 $ sudo service solr status  

Some Drupal Modules To work with Solr:
drupal/search_api_solr
apachesolr_entity_jit_index:When create/update entity at that time it index it on the solr.
Apache Solr Views : It provides the views plugins and handlers needed to be able to create a view that fetches its results from Apachesolr index, without hitting the database.

Faceted search with Solr in Drupal 8:

Facet is a module, in Drupal 8, that provides a facility to arrange all the search results as per the category. Basically, it is an arrangement of search results based on categories, content type on indexed terms and content type.

Faceted search provides the search like Amazon, Flipkart and so on as per the category, types and all.
There are various reasons a Facet can be used:
  • It provides a drill-down search facility.
  • It can be used with default search and Solr as well.
  • It shows a number of item count for each category.
  • Facet provides a wide range of configurable setting in UI and so on.
Solr supports a range of Faceting:
1. Field faceting - Retrieve the counts for all terms or just the top terms in any given field. The field must be indexed.
2. Range faceting – It can be used on any date field or numeric field that supports range queries. There are some parameters for range Faceting. 
3. Interval faceting - It allows users to set variable intervals and count the number of documents that have values within those intervals in the specified field.
4. Query faceting - This faceting returns a number of documents in the current search results that also match the given facet query.
5. Pivot faceting - It allows to break down the values by category and sub-categories.

Part 2  

Comments

Popular posts from this blog

Mysql Interview Questions

Current mysql version : 8 ( last was 5.7 ,  5.7 to directly 8 ) SHOW FULL PROCESSLIST is used to see all the query executing when refresh the site. 1 second == 1000 mili second, 0-500 ms responce time of any query is ok How to Read the MySQL Slow Query Log :   The MySQL slow query log is where the MySQL database server registers all queries that exceed a given threshold of execution time. This can often be a good starting place to see which queries are slowest and how often they are slow. MySQL on your server is configured to log all queries taking longer than 0.1 seconds. /var/log/mysql/mysql-slow.log Use EXPLAIN or EXPLAIN EXTENDED to explain the query how it is executed. MySQL  describe  or  ANALYZE  command shows the structure of the table. Best practice in respect of performance : 1 - always use index, 2 - index types , primary index and combined field index like fname & lname in one index not two index, 3 - one index sc...

Drupal 8 : Link actions,Link menus,Link Tasks,Routings

Drupal 8 : Link actions,Link menus,Link Tasks,Routings Link actions Local actions have also been moved out of the hook_menu() system in Drupal 8 .Use actions to define local operations such as adding new items to an administrative list (menus, contact categories, etc). Local actions are defined in a YAML format, named after the module they are defined by. Such as menu_ui.links.action.yml for this example from menu_ui module: menu_ui.link_add:   route_name: menu_ui.link_add   title: 'Add link'   appears_on:     - menu_ui.menu_edit Here, menu_ui.link_add: It is the Unique name of the link action Most likely start with module name, route_name : Name of the route it means when click the link it redirect to this route, appears_on :  An array of route names for this action to be display on. Now how to know the Route name of any internal/external admin pages like below, By through the drupal console we achieve it, drupal debug:router...

Get The field values of node in Drupal 8

use Drupal \ node \ NodeInterface ; /** * Implements hook_ENTITY_TYPE_insert() for node entities. * * This tests saving a node on node insert. * * @see \Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert() */ function node_test_node_insert ( NodeInterface $node ) { // Set the node title to the node ID and save. if ( $node - > getTitle ( ) == 'new' ) { $node - > setTitle ( 'Node ' . $node - > id ( ) ) ; $node - > setNewRevision ( FALSE ) ; $node - > save ( ) ; } } Now There is so many functions are there to get the values, For All the functions available visit the API code, https://api.drupal.org/api/drupal/core%21modules%21node%21src%21NodeInterface.php/interface/NodeInterface/8.2.x Some of as below, Node edit form, Drupal 8 Automatically Load the whole object no need to load the entity like below, if ($event->getFormId() == 'node_alexa_audio_clips_edit_form') { $node = \Drupal::ro...