From the course: Practical GitHub Code Search
Syntax operators - GitHub Tutorial
From the course: Practical GitHub Code Search
Syntax operators
- You can construct queries with a variety of operators that can help you narrow your searches. Let's take a look at some of them. You can use comparison operators like greater than, greater than or equals to, less than, or less than and equals to. You can also do ranges by using the two different dots and you can use a star right here. So the first one will be at least 10 or more items, up to 10 items or 10 to a hundred items. And you can also use dates as well as times in these formats right here. Plus you can exclude with minus or the not keyword and not should be capitalized here. You also have the ability to create quotations when you want to be a little more specific. So let's take a look at some examples of this. All right, so here I am back on github.com. You could just hit this little icon if you ever want to get to the main level here. And I'm going to do a search right here. So I'll hit the slash and I want to type in the word syntax. So I'm going to look for a syntax highlighter for my website. So when I type that in, I get 10,000 results. That's quite a bit. Now I can't sort right here, so if I want to, I can say just give me the ones with the most stars. This isn't a permanent search and it isn't anything that I can save. So if I want to come back and look for this a little bit later, I may want to add some additional qualifiers here. Now notice that if I add quotations here, it's not going to just look for either syntax or highlighter, but it's going to look for those words together which sometimes gives you a little bit of a better search. So now I have 10,000. That's still quite a bit. Let's see if we can narrow that a little bit more. So I'm going to say I want to see the ones that have at least a thousand stars, 'cause this appears to be a pretty popular topic. And that gives me just 48 results. That's much better. Now if I take a look at these, I can see that there's a lot of interesting stuff, but there's weird things like Postgres CLI without auto-completion and syntax highlighting. That doesn't quite seem what I'm looking for. Or a terminal client for MySQL. And there's some other things in here. So let's see what else we can do to narrow this down a little better. I'm going to add language and I'll put JavaScript here. Now you can actually choose that from this list right here. But notice how well it gives you the hints when you type in those things. So I'm just going to click on JavaScript, let's hit return. And now we got 10 results. Let's take a look at what we got here. And this is sort of cool. This turns your source code into syntax highlighted images, but that isn't quite what I'm looking for. So I can add a not sort of query here. I'll say not. And then I will put in here images. And see what happens then. So now I have nine results. I've kind of gotten rid of that one and I think there's one here for Python or there's something here for Python. So I'm going to add that here and I'll just say, or Python. Okay, that should be a little bit better. So I got nine results now, so that's interesting. So I could still, maybe I should add not instead of or, not Python. Let's try that. Yeah, now we have eight results, so that's great. So let's see. In addition to that, I'm going to say that I want to make sure that this has been updated recently. So I'm going to add another thing here called pushed. And I'm going to say I'm going to want stuff that's been pushed since the beginning of the year. So 2023 01 01, or I could just go maybe a few months. But I'll just choose that. I don't know if this is going to give me any. Yeah, actually it did go down all the way to four results. And I can keep on using these different syntax operators to get me very specific results. And what I like to do is go ahead and save this so that I can always come back and see if there's any interesting new syntax highlighter. I may want to decrease the amount of stars because if it's new, it's not going to get that many stars. So let's go ahead and just make that, let's be more gentle here. Let's try a hundred and see how many we get. 21 results. Okay, that still seems manageable and still sorted by most stars. And so let's go ahead and save. And I'm going to say search syntax. I'll just say syntax highlighters here. All right, so it keeps the query right here. So I'm going to say create saved search and then I can look at the ones that I have going and I can close this out and I can always come back to that search and take a look at at least things with a hundred stars that are syntax highlighter. That might be a good search for later. Now you can ask that the results be sorted by a specific qualifier. So you can say sort and then specify either something like ascending or descending or sort by date and index or update it. So let's take a look at how we may use something like that. So I'm going to go hit this Mona Lisa Octocat icon just to get to the main search, as well. And that'll clear everything out. So this time I'm going to look for React UI components and that might be something we put in quotes. Let's see what we get when we just search for that. 892 results. That's quite a bit. So let's go ahead and say, I want to sort basically I want only the ones that have greater than a thousand stars and then I'm going to sort them by date and then add the ascending qualifier here. So now that's only five results. That's much better. And I can keep on refining any of my searches and saving them. Learning how to use these qualifiers is going to make it much easier for you to find things that you're looking for a lot quicker.