Posts

Showing posts from May, 2021

What are delegate, delegate method, SimpleDelegator in ruby

 delegate methods in Rails, exposing only necessary methods of containing objects, thereby, making them more easily accessible. class Parent   def initialize     @child = Child.new   end end class Child   def initialize     @data = []   end   def insert(data)     @data << data   end   def fetch(key)     @data[key]   end end parent = Parent.new if you try this parent.insert("imrahul") then you will get response undefined method `insert' for #<Parent:0x000055f4915673a0 @child=#<Child:0x000055f491567350 @data=[]>> (NoMethodError)   This code will work if we overide methods of child class class Parent   def initialize     @child = Child.new   end   def insert(data)     @child.insert(data)   end   def fetch(index)     @child.fetch(index)   end end class Child   def initialize     @data = []   end   def insert(data)     @data << data   end   def fetch(key)     @data[key]   end end parent = Parent.new parent.insert("imrahul") So this is how dele

Completely uninstall elasticsearch in Linux

sudo apt-get remove elasticsearch sudo apt-get --purge autoremove elasticsearch sudo dpkg --remove elasticsearch sudo dpkg --purge elasticsearch sudo dpkg --purge --force-all elasticsearch sudo rm -rf /var/lib/elasticsearch/ sudo rm -rf /etc/elasticsearch If still facing any issues then you have to delete source file too. cd /etc/apt/sources.list.d/ sudo rm -rf elastic-*   Install Elasticsearch in ubuntu 20, 18, 16

Install Elastic search 5.x in ubuntu 20, 18, 16

Look for OpenJDK in APT sudo apt search openjdk Install OpenJDK 8 sudo apt-get install openjdk-8-jdk Add the proper GPG key for ElasticSearch wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - Make sure to install/update transport sudo apt-get install apt-transport-https Save the repo definition echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list Update APT and install ElasticSearch from APT sudo apt-get update && sudo apt-get install elasticsearch Reload the daemon sudo /bin/systemctl daemon-reload Allow ElasticSearch to start on boot sudo /bin/systemctl enable elasticsearch.service Lets fire up ElasticSearch... sudo systemctl start elasticsearch.service Lets see if we have some logs sudo ls -la /var/log/elasticsearch/ Have a look at the logs and make sure that ElasticSearch has properly initiated sudo cat /var/log/elasticsearch/elasticsearch.