No matter, what profile, a developer or a QA, we are working on or at what stage of software release we are contributing, changing or accessing the files in production is something we can never escape from. But does production environments have useful IDEs or any editor to make our life easier??
Even though I am a Front End developer and I could not escape from accessing the files even after deploying the build. Changing the files and testing if it will work always helps. Here comes, VIM, the editor which no matter how much we try, we cannot ignore it.
Here, without getting a lot deeper, I have tried to list down the most common and useful operations that we would like to do on a file,using VIM.
All commands starting with a colon(:) are used in Escape mode. i.e press escape key to go into the mode and then type command.
1. Open / Create a file in Vim
shwetas@dell:~ $ vi the-coders-stop.js
2. Edit an opened file
Once File opened. Press i
This will open the file in edit mode. With insert mode displaying at the bottom.
3. Jump to a line number in file
In esc mode, :[line number]
e.g. :1 for line number one or :100 for line 100
4. Copy and Paste text in edit mode
Copy => Select text and press Ctrl + Insert
Paste => Shift + Insert
5. Delete number of lines from a point
Press esc and then [number of lines]dd
e.g in esc mode, 200dd will delete the next 200 lines
6. Delete entire content of the file
In `esc` mode,
i) Jump to line number 1 using point 3. i.e :1
ii) Delete the maximum number of lines you think the file has using point 5.
7. Close an opened file without any unsaved changes
In esc mode, type :q
8. Close opened or the newly created file with the changes done
In esc mode, :wq
9. Close the opened file without the unsaved changes
In esc mode, :q!
10. Search a text
type /[the text] and press Enter.
Keep pressing n to go to next occurence and shift+n to the previous.
Thanks for reading!! I hope it helps. Please share and leave your valuable comments and feedbacks below.
Elasticsearch aggregation give us the ability to ask questions to our data. The ability to group and find out statistics (such as sum, average, min, max) on our data by using a simple search query. In this post, we will see some very simple examples to understand how powerful and easy it is to use Elasticsearch aggregation. I will also share a postman collection link at the bottom of this post in case you want to try out these queries on your own.
Let’s say we have a car store and to formulate some reports we are interested in the following:
What is the average price of sold cars having manufacturer Audi ?
Find all cars made by Ford and average price of ford cars sold in Jul 2020
What is the total price of all cars sold in Jul 2020 ?
Which are the most popular car manufacturers?
How much sales were made each month ?
So let’s get started right away and look at our sample data on which we will be performing aggregation.
The query is very simple, we are just asking elasticsearch to first filter the records which have manufacturer Audi and then on all the records in the result do an average aggregation on the field price. Now lets see the response from elasticsearch:
If you compare this query with the first one, the only difference is that we have added one extra date filter inside the aggs block. This is how we can filter results before performing aggregation on them.
Also if you look carefully, there is one more difference i.e in the first query we have used a
There are many occasions when aggregations are required but search hits are not. For these cases the hits can be ignored by setting size=0
You can verify this by looking at the response of the first query, in that only the aggregation result was returned and we do not see the actual documents which are used to evaluate that result. Now let’s see the result of our second query:
Don’t worry if the query looks complex. We are just doing nested aggregation. First we group all the data in monthly buckets and then on each bucket we perform a metric aggregation to sum the price. Think of this as a pipeline of aggregations.
Wow! that was accurate and definitely not very difficult to achieve.
All right that was it for this post. Hope you had fun and experienced power of Elasticsearch aggregations. If you enjoyed the post, please like and share it so that it also reaches other valuable readers. If you have any doubts or feedbacks, please scroll to the bottom and leave a comment. Again, thanks for reading 🙂