|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 5 | + <meta http-equiv="Content-Language" content="en-us" /> |
| 6 | + <meta http-equiv="imagetoolbar" content="false" /> |
| 7 | + <meta name="MSSmartTagsPreventParsing" content="true" /> |
| 8 | + <title>Improvements to the Search API</title> |
| 9 | + <link rel="alternate" type="application/atom+xml" title="API Changes" href="/changes.atom" /> |
| 10 | + <link href="/css/reset.css" rel="stylesheet" type="text/css" /> |
| 11 | + <link href="/css/960.css" rel="stylesheet" type="text/css" /> |
| 12 | + <link href="/css/uv_active4d.css" rel="stylesheet" type="text/css" /> |
| 13 | + <link href="/shared/css/documentation.css" media="screen" rel="stylesheet" type="text/css"> |
| 14 | + <link href="/shared/css/pygments.css" media="screen" rel="stylesheet" type="text/css"> |
| 15 | + <script src="/shared/js/jquery.js" type="text/javascript"></script> |
| 16 | + <script src="/shared/js/documentation.js" type="text/javascript"></script> |
| 17 | +</head> |
| 18 | +<body class="api"> |
| 19 | + <div id="header-wrapper"> |
| 20 | + <div id="header"> |
| 21 | + <div> |
| 22 | + <a class="logo" href="/"><img src="/images/logo_developer.png" height="45" alt="GitHub:Developer" /></a> |
| 23 | + <ul class="nav"> |
| 24 | + <li class="api-status"></li> |
| 25 | + <li><a href="/v3/">API v3</a></li> |
| 26 | + <li><a href="/changes/">Changes</a></li> |
| 27 | + <li><a |
| 28 | + href="https://github.com/contact">Support</a></li> |
| 29 | + <li><a href="/changes.atom"> |
| 30 | + <img src="/images/feed-icon-28x28.png" width="16" height="16" alt="GitHub API Changes Feed" /> |
| 31 | + </a></li> |
| 32 | + </ul> |
| 33 | + </div> |
| 34 | + </div><!-- #header --> |
| 35 | + </div><!-- #header-wrapper --> |
| 36 | + |
| 37 | + <div id="wrapper"> |
| 38 | + <div class="content"> |
| 39 | + <div class="change" id="/changes/2013-08-20-search-api-improvements/"> |
| 40 | +<h2 class="title"> |
| 41 | + <a href="/changes/2013-08-20-search-api-improvements/">Improvements to the Search API</a> |
| 42 | +</h2> |
| 43 | + |
| 44 | +<div class="meta"> |
| 45 | + <ul> |
| 46 | + <li class="published"> |
| 47 | + <span class="octicon octicon-calendar"></span> |
| 48 | + August 20, 2013 |
| 49 | + |
| 50 | + </li> |
| 51 | + <li class="who_when"> |
| 52 | + <img height="16" width="16" src="https://secure.gravatar.com/avatar/592e1e6f041f9a4ec51846fd82013aea?s=20&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png" /> |
| 53 | + <a href="https://github.com/jasonrudolph">jasonrudolph</a> |
| 54 | + </li> |
| 55 | +</ul> |
| 56 | +</div> |
| 57 | + |
| 58 | + |
| 59 | +<p>Today we’re shipping two improvements to the <a href="/changes/2013-07-19-preview-the-new-search-api/">new Search API</a>.</p> |
| 60 | + |
| 61 | +<h2 id="more-text-match-metadata">More Text Match Metadata</h2> |
| 62 | + |
| 63 | +<p>When searching for code, the API previously provided <a href="/v3/search/#text-match-metadata">text match metadata</a> (i.e., “highlights”) for file content. |
| 64 | +Now, you can also <a href="/v3/search/#highlighting-code-search-results">get this metadata</a> for matches that occur within the file path.</p> |
| 65 | + |
| 66 | +<p>For example, when <a href="https://github.com/search?q=%40octokit%2Foctokit.rb+in%3Apath+client&type=Code">searching for files that have “client” in their path</a>, the results include this match for <code>lib/octokit/client/commits.rb</code>:</p> |
| 67 | + |
| 68 | +<pre class="json"> |
| 69 | +{ |
| 70 | + "name": "commits.rb", |
| 71 | + "path": "lib/octokit/client/commits.rb", |
| 72 | + "text_matches": [ |
| 73 | + { |
| 74 | + "object_url": "https://api.github.com/repositories/417862/contents/lib/octokit/client/commits.rb?ref=8d487ab06ccef463aa9f5412a56f1a2f1fa4dc88", |
| 75 | + "object_type": "FileContent", |
| 76 | + "property": "path", |
| 77 | + "fragment": "lib/octokit/client/commits.rb", |
| 78 | + "matches": [ |
| 79 | + { |
| 80 | + "text": "client", |
| 81 | + "indices": [ 12, 18 ] |
| 82 | + } |
| 83 | + ] |
| 84 | + } |
| 85 | + ] |
| 86 | + // ... |
| 87 | +} |
| 88 | +</pre> |
| 89 | + |
| 90 | +<h2 id="better-text-match-metadata">Better Text Match Metadata</h2> |
| 91 | + |
| 92 | +<p>Before today, the API applied HTML entity encoding to all <code>fragment</code> data. |
| 93 | +For example, imagine your search returns an issue like <a href="https://github.com/rails/rails/issues/11889">rails/rails#11889</a>:</p> |
| 94 | + |
| 95 | +<p><img src="https://f.cloud.github.com/assets/2988/994632/a84f2888-09af-11e3-9417-4bd92f1f1ed6.png" alt="Example Issue Title"></p> |
| 96 | + |
| 97 | +<p>The response would include a <code>text_matches</code> array with the following object:</p> |
| 98 | + |
| 99 | +<pre class="json"> |
| 100 | +{ |
| 101 | + "fragment": "undefined method `except' for #&lt;Array:XXX&gt;", |
| 102 | + // ... |
| 103 | +} |
| 104 | +</pre> |
| 105 | + |
| 106 | +<p>Inside the <code>fragment</code> value, we see HTML-encoded entities (e.g., <code>&lt;</code>). |
| 107 | +Since we’re returning JSON (not HTML), API clients might not expect any HTML-encoded text. |
| 108 | +As of today, the API returns these fragments <em>without</em> this extraneous encoding.</p> |
| 109 | + |
| 110 | +<pre class="json"> |
| 111 | +{ |
| 112 | + "fragment": "undefined method `except' for #<Array:XXX>", |
| 113 | + // ... |
| 114 | +} |
| 115 | +</pre> |
| 116 | + |
| 117 | +<h2 id="preview-period">Preview Period</h2> |
| 118 | + |
| 119 | +<p>We’re about halfway through the <a href="/changes/2013-07-19-preview-the-new-search-api/#preview-period">preview period</a> for the new Search API. |
| 120 | +We appreciate everyone that has provided feedback so far. Please <a href="https://github.com/contact?form%5Bsubject%5D=New+Search+API">keep it coming</a>!</p> |
| 121 | +</div> |
| 122 | + |
| 123 | + </div> |
| 124 | + |
| 125 | + <div id="js-sidebar" class="sidebar-shell"> |
| 126 | + <div class="js-toggle-list sidebar-module expandable"> |
| 127 | + <ul> |
| 128 | + <li class="js-topic"> |
| 129 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/">Overview</a></h3> |
| 130 | + <ul class="js-guides"> |
| 131 | + <li><a href="/v3/libraries/">Libraries</a></li> |
| 132 | + <li><a href="/v3/media/">Media Types</a></li> |
| 133 | + <li><a href="/v3/meta/">Meta</a></li> |
| 134 | + <li><a href="/v3/oauth/">OAuth</a></li> |
| 135 | + <li><a href="/v3/rate_limit/">Rate Limit</a></li> |
| 136 | + <li><a href="/v3/troubleshooting/">Troubleshooting</a></li> |
| 137 | + </ul> |
| 138 | + </li> |
| 139 | + <li class="js-topic"> |
| 140 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/guides/">Guides</a></h3> |
| 141 | + <ul class="js-guides"> |
| 142 | + <li><a href="/guides/getting-started/">Getting Started</a></li> |
| 143 | + <li><a href="/guides/basics-of-authentication/">Basics of Authentication</a></li> |
| 144 | + <li><a href="/guides/rendering-data-as-graphs/">Rendering Data as Graphs</a></li> |
| 145 | + </ul> |
| 146 | + </li> |
| 147 | + <li class="js-topic"> |
| 148 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/activity/">Activity</a></h3> |
| 149 | + <ul class="js-guides"> |
| 150 | + <li><a href="/v3/activity/events/">Events</a></li> |
| 151 | + <li><a href="/v3/activity/events/types/">Event Types</a></li> |
| 152 | + <li><a href="/v3/activity/feeds/">Feeds</a></li> |
| 153 | + <li><a href="/v3/activity/notifications/">Notifications</a></li> |
| 154 | + <li><a href="/v3/activity/starring/">Starring</a></li> |
| 155 | + <li><a href="/v3/activity/watching/">Watching</a></li> |
| 156 | + </ul> |
| 157 | + </li> |
| 158 | + <li class="js-topic"> |
| 159 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/gists/">Gists</a></h3> |
| 160 | + <ul class="js-guides"> |
| 161 | + <li><a href="/v3/gists/comments/">Comments</a></li> |
| 162 | + </ul> |
| 163 | + </li> |
| 164 | + <li class="js-topic"> |
| 165 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/git/">Git Data</a></h3> |
| 166 | + <ul class="js-guides"> |
| 167 | + <li><a href="/v3/git/blobs/">Blobs</a></li> |
| 168 | + <li><a href="/v3/git/commits/">Commits</a></li> |
| 169 | + <li><a href="/v3/git/refs/">References</a></li> |
| 170 | + <li><a href="/v3/git/tags/">Tags</a></li> |
| 171 | + <li><a href="/v3/git/trees/">Trees</a></li> |
| 172 | + </ul> |
| 173 | + </li> |
| 174 | + <li class="js-topic"> |
| 175 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/issues/">Issues</a></h3> |
| 176 | + <ul class="js-guides"> |
| 177 | + <li><a href="/v3/issues/assignees/">Assignees</a></li> |
| 178 | + <li><a href="/v3/issues/comments/">Comments</a></li> |
| 179 | + <li><a href="/v3/issues/events/">Events</a></li> |
| 180 | + <li><a href="/v3/issues/labels/">Labels</a></li> |
| 181 | + <li><a href="/v3/issues/milestones/">Milestones</a></li> |
| 182 | + </ul> |
| 183 | + </li> |
| 184 | + <li class="js-topic"> |
| 185 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/orgs/">Orgs</a></h3> |
| 186 | + <ul class="js-guides"> |
| 187 | + <li><a href="/v3/orgs/members/">Members</a></li> |
| 188 | + <li><a href="/v3/orgs/teams/">Teams</a></li> |
| 189 | + </ul> |
| 190 | + </li> |
| 191 | + <li class="js-topic"> |
| 192 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/pulls/">Pull Requests</a></h3> |
| 193 | + <ul class="js-guides"> |
| 194 | + <li><a href="/v3/pulls/comments/">Review Comments</a></li> |
| 195 | + </ul> |
| 196 | + </li> |
| 197 | + <li class="js-topic"> |
| 198 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/repos/">Repositories</a></h3> |
| 199 | + <ul class="js-guides"> |
| 200 | + <li><a href="/v3/repos/collaborators/">Collaborators</a></li> |
| 201 | + <li><a href="/v3/repos/comments/">Comments</a></li> |
| 202 | + <li><a href="/v3/repos/commits/">Commits</a></li> |
| 203 | + <li><a href="/v3/repos/contents/">Contents</a></li> |
| 204 | + <li><a href="/v3/repos/downloads/">Downloads</a></li> |
| 205 | + <li><a href="/v3/repos/forks/">Forks</a></li> |
| 206 | + <li><a href="/v3/repos/keys/">Keys</a></li> |
| 207 | + <li><a href="/v3/repos/hooks/">Hooks</a></li> |
| 208 | + <li><a href="/v3/repos/merging/">Merging</a></li> |
| 209 | + <li><a href="/v3/repos/statistics/">Statistics</a></li> |
| 210 | + <li><a href="/v3/repos/statuses/">Statuses</a></li> |
| 211 | + </ul> |
| 212 | + </li> |
| 213 | + <li class="js-topic"> |
| 214 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/users/">Users</a></h3> |
| 215 | + <ul class="js-guides"> |
| 216 | + <li><a href="/v3/users/emails/">Emails</a></li> |
| 217 | + <li><a href="/v3/users/followers/">Followers</a></li> |
| 218 | + <li><a href="/v3/users/keys/">Keys</a></li> |
| 219 | + </ul> |
| 220 | + </li> |
| 221 | + <li class="js-topic"> |
| 222 | + <h3><a href="#" class="js-expand-btn collapsed"> </a><a href="/v3/search/">Search</a></h3> |
| 223 | + <ul class="js-guides"> |
| 224 | + <li><a href="/v3/search/#search-repositories">Repositories</a></li> |
| 225 | + <li><a href="/v3/search/#search-code">Code</a></li> |
| 226 | + <li><a href="/v3/search/#search-issues">Issues</a></li> |
| 227 | + <li><a href="/v3/search/#search-users">Users</a></li> |
| 228 | + <li><a href="/v3/search/legacy/">Legacy Search</a></li> |
| 229 | + </ul> |
| 230 | + </li> |
| 231 | + <li class="js-guides"><h3><a href="/v3/gitignore/">Gitignore</a></h3></li> |
| 232 | + <li class="js-guides"><h3><a href="/v3/markdown/">Markdown</a></h3></li> |
| 233 | + </ul> |
| 234 | + </div> <!-- /sidebar-module --> |
| 235 | + <div class="sidebar-module"> |
| 236 | + <p>This website is a <a href="https://github.com/github/developer.github.com" target="_blank">public GitHub repository</a>. Please help us by forking the project and adding to it.</p> |
| 237 | + </div> |
| 238 | + </div><!-- /sidebar-shell --> |
| 239 | + |
| 240 | + </div><!-- #wrapper --> |
| 241 | + |
| 242 | + <div id="footer" > |
| 243 | + <div class="upper_footer"> |
| 244 | + <div class="footer_inner clearfix"> |
| 245 | + |
| 246 | + <ul class="footer_nav"> |
| 247 | + <h4>GitHub</h4> |
| 248 | + <li><a href="https://github.com/about">About</a></li> |
| 249 | + <li><a href="https://github.com/blog">Blog</a></li> |
| 250 | + <li><a href="https://github.com/features">Features</a></li> |
| 251 | + <li><a href="https://github.com/contact">Contact & Support</a></li> |
| 252 | + <li><a href="https://github.com/training">Training</a></li> |
| 253 | + <li><a href="http://status.github.com/">Site Status</a></li> |
| 254 | + </ul> |
| 255 | + |
| 256 | + <ul class="footer_nav"> |
| 257 | + <h4>Tools</h4> |
| 258 | + <li><a href="http://mac.github.com/">GitHub for Mac</a></li> |
| 259 | + <li><a href="http://mobile.github.com/">Issues for iPhone</a></li> |
| 260 | + <li><a href="https://gist.github.com">Gist: Code Snippets</a></li> |
| 261 | + <li><a href="http://enterprise.github.com/">GitHub Enterprise</a></li> |
| 262 | + <li><a href="http://jobs.github.com/">Job Board</a></li> |
| 263 | + </ul> |
| 264 | + |
| 265 | + <ul class="footer_nav"> |
| 266 | + <h4>Extras</h4> |
| 267 | + <li><a href="http://shop.github.com/">GitHub Shop</a></li> |
| 268 | + <li><a href="http://octodex.github.com/">The Octodex</a></li> |
| 269 | + </ul> |
| 270 | + |
| 271 | + <ul class="footer_nav"> |
| 272 | + <h4>Documentation</h4> |
| 273 | + <li><a href="http://help.github.com/">GitHub Help</a></li> |
| 274 | + <li><a href="http://developer.github.com/">Developer API</a></li> |
| 275 | + <li><a href="http://github.github.com/github-flavored-markdown/">GitHub Flavored Markdown</a></li> |
| 276 | + <li><a href="http://pages.github.com/">GitHub Pages</a></li> |
| 277 | + </ul> |
| 278 | + |
| 279 | + </div><!-- /.site --> |
| 280 | + </div><!-- /.upper_footer --> |
| 281 | + |
| 282 | + <div class="lower_footer"> |
| 283 | + <ul class="footer-cell"> |
| 284 | + <li><a href="http://help.github.com/terms-of-service/">Terms of Service</a></li> |
| 285 | + <li><a href="http://help.github.com/privacy-policy/">Privacy</a></li> |
| 286 | + <li><a href="http://help.github.com/security/">Security</a></li> |
| 287 | + </ul> |
| 288 | + |
| 289 | + <span class="footer-cell"> |
| 290 | + <a href="https://github.com" class="mega-icon mega-icon-invertocat"></a> |
| 291 | + </span> |
| 292 | + |
| 293 | + <span class="footer-cell"> |
| 294 | + Design © <span class="js-year">2013</span> GitHub, Inc. All rights reserved. |
| 295 | + <p> |
| 296 | + Except where otherwise noted, content on this site is licensed under a |
| 297 | + <a href="http://creativecommons.org/licenses/by/3.0/us/">Creative Commons CC-BY license</a>. |
| 298 | + </p> |
| 299 | + </span> |
| 300 | + </div> |
| 301 | + |
| 302 | + </div><!-- /#footer --> |
| 303 | + <script type="text/javascript"> |
| 304 | + var _gauges = _gauges || []; |
| 305 | + (function() { |
| 306 | + var t = document.createElement('script'); |
| 307 | + t.type = 'text/javascript'; |
| 308 | + t.async = true; |
| 309 | + t.id = 'gauges-tracker'; |
| 310 | + t.setAttribute('data-site-id', '4f2038e0cb25bc1b55000003'); |
| 311 | + t.src = '//secure.gaug.es/track.js'; |
| 312 | + var s = document.getElementsByTagName('script')[0]; |
| 313 | + s.parentNode.insertBefore(t, s); |
| 314 | + })(); |
| 315 | + </script> |
| 316 | +</body> |
| 317 | +</html> |
0 commit comments