I'm going to do curl again on localhost. This time, I'm going to specify to search all indices of the type "episode." Here's my search endpoint. I'm going to specify my parameter with a q=, and then I want to look for the title being set to Homer. Again, I'll pipe that to jQ.
In our results here, it goes to Elasticsearch and finds all documents of type "episode" containing Homer in the title field. If I scroll back through here, you can see the title here is Homer.
Here's another one titled Homer, and so on. If I go back to the beginning of my search results, it tells me that there were a total of 43 documents in my cluster that have Homer in the title.
Let's search for all documents in the cluster that have Homer in the title from Season 5. We'll hit our server again, localhost on port 9200. We're going to go to all indices, hit the episode type using the search endpoint.
Now, watch this. I've got my q=%2b, which is the URL-encoded version of the plus sign. I'm going to specify title, and then %3a, which is my colon, specify my search term, which is Homer.
Now I'll do a regular +, and then another %2b to specify the URL encoded +, type the word season, and then a colon again, which is %3a, and then number 5 to specify Season 5.
Again, we'll pipe that to jQ, run that. If I did it right, here's Homer from Season 5. This one's Homer from Season 5. It looks like they're all Homer from Season 5. If we go to the top, there were a total of six documents that matched that query.
Let's do one more. Let's find any episode with Homer or Bart in the title and an IMDb rating over eight. We're going to do curl again, localhost, port 9200, and then we'll specify...
This time we're going to do an underscore search, hit the search endpoint right away, which searches everything in the cluster, throw our parameters in there with q=, and then, again, we'll do %2b for our + sign, our title, and then we're going to do a %3a for our colon, and then %28, which is a parenthesis.
We'll do Homer%2b for +, followed by the word Bart because we want to search for Bart as well, %29 to close our parenthesis, +%2b for another + sign, and then our field IMDb rating, which is IMDb_rating, and then a colon, which is %3a, then >%3e8, and then we'll pipe that to jQ.
When that comes back, we have "Radio Bart," which has an IMDb rating of 8.5, "Bart After Dark" with 8.2, "Homer the Bad Man" with an IMDb rating of 9. That worked.
When we scroll back up and look at this, that's kind of less than usable. This is certainly not anything that you would turn over to your end users and try to teach them how to URL-encode percent and plus signs and expect them to deliver, or expect them to be functional with this.
It's a good way for you to troubleshoot or test your query whenever you're just working from the command line, but for delivering a polished application to your users, Elasticsearch has the Query DSL language that we'll jump into in the next lesson.