Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

WEBVTT

00:04.240 --> 00:05.490


Okay.

00:06.600 --> 00:07.020


All right.

00:07.020 --> 00:08.310


We've covered inserting documents.

00:08.310 --> 00:09.630


We've covered updating documents.

00:09.630 --> 00:12.410


So for completion sake, let's talk about deleting documents.

00:12.420 --> 00:14.160


And really, it could not be easier.

00:15.640 --> 00:20.710


It turns out there's a rest verb for delete and all we have to do is use it so the
command will look

00:20.710 --> 00:21.460


something like this.

00:21.610 --> 00:25.090


If you know the document idea of the document you want to delete, just delete.

00:25.120 --> 00:29.410


Followed by the hostname that we're talking to for Elasticsearch, followed by the
index name in this

00:29.410 --> 00:30.190


case movies.

00:30.580 --> 00:32.540


And then the document that you want to delete.

00:33.280 --> 00:36.650


So let's say we want to delete documented five eight, five, five, nine.

00:36.670 --> 00:38.260


That's what the command would look like for that.

00:38.890 --> 00:40.070


It's just that simple.

00:40.090 --> 00:42.340


So this is going to be the quickest lecture in the world, guys.

00:42.340 --> 00:46.750


Let's just try it out hands on real quick and let's go delete something.

00:48.400 --> 00:51.610


All right, we're logged back in, so let's go ahead and delete The Dark Knight,
shall we?
00:51.640 --> 00:52.270
Not that we should.

00:52.270 --> 00:55.990


It's a really good movie, but let's make this a little bit more of a real world
scenario.

00:56.000 --> 00:59.680


You probably don't know the document ID for The Dark Knight off the top of your
head.

00:59.680 --> 00:59.950


Right.

00:59.950 --> 01:03.310


So oftentimes doing this will be sort of a two step approach.

01:03.310 --> 01:07.540


First, figuring out the document idea, the document that you want to delete, and
then issuing the

01:07.540 --> 01:09.780


actual delete command to delete that document ID.

01:10.510 --> 01:16.040


So first, let's search for The Dark Knight and we can do that like this curl does
get it right.

01:16.060 --> 01:20.650


7.020.1 cool and hundred slash movies, which is our index name.

01:20.650 --> 01:25.030


Again, underscore search question mark Q equals dark.

01:25.030 --> 01:28.330


So for the first time, we're doing a query for a search term here.

01:30.540 --> 01:34.290


And we didn't specify a pretty format, but we can still work out the results here.

01:34.650 --> 01:39.330


The Dark Knight, it looks like, is document ID 58559 based on those results.

01:39.330 --> 01:42.120


So with that number in hand, we can go ahead and delete it.

01:43.320 --> 01:54.060


Let's say curl bash x, delete 120 7.0.0.1 colon 1800 slash movies slash underscore
doc slash ideas

01:54.060 --> 01:55.800


five eight, five, five, nine.

01:56.880 --> 01:58.380


And we'll ask for pretty results.

01:59.880 --> 02:02.370


And it says it was successful so it was deleted.
02:02.760 --> 02:04.970
Let's try searching for it again and see what comes back.

02:07.940 --> 02:08.360


Nothing.

02:08.360 --> 02:09.620


No hits because it's gone.

02:09.650 --> 02:09.980


Cool.

02:10.550 --> 02:10.850


All right.

02:10.850 --> 02:12.260


So that's how deletion works again.

02:12.290 --> 02:13.250


Easiest thing in the world.

02:13.490 --> 02:17.960


And let's move on and do something more interesting with a little hands on exercise
next.

You might also like