PageSourceSearch

https://neogrok-demo-web.fly.dev/_app/immutable/nodes/14.C5bLcCqJ.js

js neogrok-demo-web.fly.dev collected 2026-10-03 08:26:54 UTC 13,966 bytes, 49 lines download raw bytes

1import{A as e,J as t,M as ee,P as n,Q as r,W as te,X as ne,Y as i,ft as a,g as re,pt as o}from"../chunks/CMbF87Pw.js";import"../chunks/Cqy7GszY.js";import{t as s}from"../chunks/BWT_7hlo.js";import{n as c,t as l}from"../chunks/DECgegqb.js";import{t as u}from"../chunks/BHM_n7OE.js";var ie=ee(`<div class="space-y-2 max-w-prose mx-auto"><h1 class="text-2xl text-center">Query syntax</h1> <p>The query syntax of neogrok is controlled by <!>, the code
2    search engine for which neogrok is a frontend. Because zoekt does not have
3    good documentation covering this syntax, we describe it here.</p> <section class="space-y-2"><!> <p>In zoekt, all queries are parsed by Go&apos;s regexp package, the syntax
4      of which is documented <!>. There
5      is no way to disable this functionality; queries that want to use regex
6      control characters literally must escape them.</p> <p>Queries cannot control the <!> that zoekt uses; they are hardcoded. As can be seen <!> the flags are <code>ClassNL</code>, <code>PerlX</code>, and <code>UnicodeGroups</code>. Together, these flags notably allow multiline
7      regex matches using character classes like <code>[[:space:]]</code>, but <em>not</em> using the dot.</p></section> <section class="space-y-2"><!> <p>If your query contains no spaces, its behavior is pretty intuitive. <!> displays all matches for the regex <!>. That query contains a single <em>expression</em>, namely a <em>regex</em> expression. (We&apos;ll introduce
8      more kinds of expressions below.)</p> <p>But what about <!>? This query has two
9      expressions, which makes its behavior more complicated: it returns all
10      matches for the regex <!> <em>or</em> the regex <!>, but only in files that have matches for both <!> <em>and</em> <!>.</p> <p>First of all, if you wanted this query to behave as if it had only one
11      expression, literally matching <!>, you can
12      either wrap it in double quotes, like <!>, or by escaping the space, like <!>; both of those queries are equivalent.
13      (Single quotes have no special meaning in this regard. <!> contains two expressions, the first being <!> and the second being <!>.)</p> <section class="space-y-2"><!> <p>As described above, expressions are <em>conjunctive</em> by default: a
14        file must have at least one match for each expression to be included in
15        the query results. Expressions may be made <em>disjunctive</em> by
16        joining them with the special expression infix operator <code>or</code>. <!> returns all matches for <!> or <!> in all files
17        that have matches for at least one of <!> or <!>. (To
18        use <code>or</code> as a literal expression and not as an operator,
19        double quote it: <!> has three conjunctive
20        expressions.)</p> <p>Expressions can be logically grouped with parentheses: <!> produces results from files with matches for both <!> and at least one of <!> or <!>. These groupings can be nested arbitrarily.</p> <p>To complete the boolean logic, expressions can be negated with a leading
21        dash. <!> returns all matches for <!> in files that do not have matches for <!>. <!> returns all matches for <!> in files that do
22        not have matches for either <!> or <!>. <!> returns all matches for <!> in files that do not
23        have matches for <em>both</em> <!> and <!>.</p></section></section> <section class="space-y-2"><!> <p>In addition to the default regex expressions you&apos;ve already seen,
24      special kinds of expressions can be created by prefixing them with certain
25      flags, which are themselves composed of a few characters ending with a
26      colon.</p> <p>Consider that regex expressions can produce matches both in the content of
27      a file and in the <em>name</em> of the file: <!> matches both file names and file contents (though
28      the search engine tends to rank files containing file name matches higher than
29      those containing only content matches, so you may have to scroll down or increase
30      the number of files displayed to see the content matches for this query). If
31      you only want the expression to match file names, use an expression prefixed
32      with <code>file:</code>, like <!>. ( <code>f:</code> is an equivalent abbreviation for <code>file:</code>).</p> <p>The inverse of <code>file:</code>&apos;s specialization of regex
33      expressions is <code>content:</code> or <code>c:</code>. <!> produces only matches that occur in
34      the content of files.</p> <p>There are a few more kinds of prefix expressions than those two.
35      They&apos;re all tabulated below.</p> <p>Finally, note that the boolean logic described above applies to prefix
36      expressions just like normal ones: <!> shows matches for <!> except for those in files
37      whose names match <!>.</p></section></div> <div class="max-w-4xl mx-auto pt-2 overflow-x-auto"><table class="border border-collapse text-sm text-center"><!><thead>
37<tr class="border bg-slate-100 dark:bg-slate-800"><th class="p-1">Prefix(es)</th><th class="p-1">Description</th><th class="p-1">Examples</th></tr></thead><tbody><tr class="border"><td class="p-1"><code>file:</code>, <code>f:</code></td><td class="p-1">Regex match file names only, instead of the default file names and
38          file contents</td><td class="p-1"><!> <br/> <!> <br/> <!></td></tr><tr class="border"><td class="p-1"><code>content:</code>, <code>c:</code></td><td class="p-1">Regex match file contents only, instead of the default file names and
39          file contents</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>repo:</code>, <code>r:</code></td><td class="p-1">Regex match repository names; by default all repositories are searched</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>branch:</code>, <code>b:</code></td><td class="p-1">Regex match branch names; by default all branches are searched</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>lang:</code></td><td class="p-1">Constrain files to those in the given language (or language alias) as
40          defined by <!> and computed probabilistically from file name and contents at index time
41          by <!>. This is <em>not</em> a regex or a substring, though it is case-insensitive; each
42          expression can only contain one language.</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>sym:</code></td><td class="p-1">Regex match symbol definitions, as determined by <!> at index time, if it
43          was present during indexing</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>case:</code></td><td class="p-1">Unlike most other expressions, does not do anything on its own, but
44          rather modifies other expressions in the query. <code>case:yes</code> makes other expressions case-sensitive; <code>case:no</code> makes them case-insensitive, and <code>case:auto</code> (the default behavior) makes them case-sensitive
45          if they have any uppercase characters and case-insensitive otherwise</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>archived:</code></td><td class="p-1"><code>archived:no</code> excludes archived repositories while <code>archived:yes</code> excludes non-archived repositories. The default
46          is to exclude neither.</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>fork:</code></td><td class="p-1"><code>fork:no</code> excludes repositories that are forks of another
47          while <code>fork:yes</code> excludes repositories that are not forks of
48          another. The default is to exclude neither.</td><td class="p-1"><!></td></tr><tr class="border"><td class="p-1"><code>public:</code></td><td class="p-1"><code>public:no</code> excludes public repositories while <code>public:yes</code> excludes private repositories. The default is to
49          exclude neither.</td><td class="p-1"><!></td></tr></tbody></table></div>`,1);function d(ee){var d=ie();re(`1kix6wo`,e=>{te(()=>{t.title=`Query syntax - neogrok`})});var f=ne(d),p=r(i(f),2),ae=r(i(p));s(ae,{to:`https://github.com/sourcegraph/zoekt`,children:(t,ee)=>{a();var r=n(`zoekt`);e(t,r)},$$slots:{default:!0}}),a(),o(p);var m=r(p,2),h=i(m);u(h,{id:`regex`,children:(t,ee)=>{a();var r=n(`Everything is regex`);e(t,r)},$$slots:{default:!0}});var g=r(h,2),oe=r(i(g));s(oe,{to:`https://pkg.go.dev/regexp/syntax#hdr-Syntax`,children:(t,ee)=>{a();var r=n(`here`);e(t,r)},$$slots:{default:!0}}),a(),o(g);var se=r(g,2),ce=r(i(se));s(ce,{to:`https://pkg.go.dev/regexp/syntax#Flags`,children:(t,ee)=>{a();var r=n(`regex flags`);e(t,r)},$$slots:{default:!0}});var le=r(ce,2);s(le,{to:`https://github.com/sourcegraph/zoekt/blob/58cf4748830ac0eded1517cc8c2454694c531fbd/query/parse.go#L231`,children:(t,ee)=>{a();var r=n(`here,`);e(t,r)},$$slots:{default:!0}}),a(11),o(se),o(m);var _=r(m,2),ue=i(_);u(ue,{id:`expressions`,children:(t,ee)=>{a();var r=n(`Queries are composed of one or more space-separated expressions`);e(t,r)},$$slots:{default:!0}});var v=r(ue,2),de=r(i(v));l(de,{query:`foo`});var fe=r(de,2);c(fe,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}}),a(5),o(v);var y=r(v,2),pe=r(i(y));l(pe,{query:`foo bar`});var me=r(pe,2);c(me,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var he=r(me,4);c(he,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}});var b=r(he,2);c(b,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var ge=r(b,4);c(ge,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}}),a(),o(y);var x=r(y,2),S=r(i(x));c(S,{children:(t,ee)=>{a();var r=n(`/foo bar/`);e(t,r)},$$slots:{default:!0}});var _e=r(S,2);l(_e,{query:`"foo bar"`});
49var C=r(_e,2);l(C,{query:`foo\\ bar`});var w=r(C,2);l(w,{query:`'foo bar'`});var T=r(w,2);c(T,{children:(t,ee)=>{a();var r=n(`/'foo/`);e(t,r)},$$slots:{default:!0}});var ve=r(T,2);c(ve,{children:(t,ee)=>{a();var r=n(`/bar'/`);e(t,r)},$$slots:{default:!0}}),a(),o(x);var E=r(x,2),D=i(E);u(D,{id:`boolean-logic`,children:(t,ee)=>{a();var r=n(`Multiple expressions are combined with boolean logic`);e(t,r)},$$slots:{default:!0}});var O=r(D,2),k=r(i(O),7);l(k,{query:`foo or bar`});var A=r(k,2);c(A,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var j=r(A,2);c(j,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}});var M=r(j,2);c(M,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var N=r(M,2);c(N,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}});var ye=r(N,4);l(ye,{query:`foo "or" bar`}),a(),o(O);var P=r(O,2),F=r(i(P));l(F,{query:`foo (bar or baz)`});var I=r(F,2);c(I,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var L=r(I,2);c(L,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}});var be=r(L,2);c(be,{children:(t,ee)=>{a();var r=n(`/baz/`);e(t,r)},$$slots:{default:!0}}),a(),o(P);var R=r(P,2),xe=r(i(R));l(xe,{query:`foo -bar`});var Se=r(xe,2);c(Se,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var Ce=r(Se,2);c(Ce,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}});var we=r(Ce,2);l(we,{query:`foo -(bar or baz)`});var Te=r(we,2);c(Te,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var Ee=r(Te,2);c(Ee,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}});var De=r(Ee,2);c(De,{children:(t,ee)=>{a();var r=n(`/baz/`);e(t,r)},$$slots:{default:!0}});var Oe=r(De,2);l(Oe,{query:`foo -(bar baz)`});var ke=r(Oe,2);c(ke,{children:(t,ee)=>{a();var r=n(`/foo/`);e(t,r)},$$slots:{default:!0}});var Ae=r(ke,4);c(Ae,{children:(t,ee)=>{a();var r=n(`/bar/`);e(t,r)},$$slots:{default:!0}});var je=r(Ae,2);c(je,{children:(t,ee)=>{a();var r=n(`/baz/`);e(t,r)},$$slots:{default:!0}}),a(),o(R),o(E),o(_);var Me=r(_,2),Ne=i(Me);u(Ne,{id:`prefix-expressions`,children:(t,ee)=>{a();var r=n(`Certain prefixes have special effects on expressions`);e(t,r)},$$slots:{default:!0}});var z=r(Ne,4),Pe=r(i(z),3);l(Pe,{query:`README`});var Fe=r(Pe,4);l(Fe,{query:`file:README`}),a(5),o(z);var B=r(z,2),Ie=r(i(B),7);l(Ie,{query:`content:README`}),a(),o(B);var Le=r(B,4),Re=r(i(Le));l(Re,{query:`-f:test assert`});var ze=r(Re,2);c(ze,{children:(t,ee)=>{a();var r=n(`/assert/`);e(t,r)},$$slots:{default:!0}});var Be=r(ze,2);c(Be,{children:(t,ee)=>{a();var r=n(`/test/`);e(t,r)},$$slots:{default:!0}}),a(),o(Le),o(Me),o(f);var Ve=r(f,2),He=i(Ve),Ue=i(He);u(Ue,{element:`caption`,id:`prefix-table`,children:(t,ee)=>{a();var r=n(`Available prefixes`);e(t,r)},$$slots:{default:!0}});var We=r(Ue,2),V=i(We),Ge=r(i(V),2),Ke=i(Ge);l(Ke,{query:`f:README`});var qe=r(Ke,4);l(qe,{query:`f:README neogrok`});var Je=r(qe,4);l(Je,{query:`f:"evil file with spaces"`}),o(Ge),o(V);var H=r(V),Ye=r(i(H),2),Xe=i(Ye);l(Xe,{query:`c:README`}),o(Ye),o(H);var U=r(H),Ze=r(i(U),2),Qe=i(Ze);l(Qe,{query:`r:linux driver`}),o(Ze),o(U);var W=r(U),$e=r(i(W),2),et=i($e);l(et,{query:`b:prerelease foo`}),o($e),o(W);var G=r(W),K=r(i(G)),tt=r(i(K));s(tt,{to:`https://github.com/github/linguist/blob/master/lib/linguist/languages.yml`,children:(t,ee)=>{a();var r=n(`linguist`);e(t,r)},$$slots:{default:!0}});var nt=r(tt,2);s(nt,{to:`https://github.com/go-enry/go-enry/`,children:(t,ee)=>{a();var r=n(`go-enry`);e(t,r)},$$slots:{default:!0}}),a(3),o(K);var rt=r(K),it=i(rt);l(it,{query:`lang:typescript type`}),o(rt),o(G);var q=r(G),J=r(i(q)),at=r(i(J));s(at,{to:`https://ctags.io/`,children:(t,ee)=>{a();var r=n(`universal ctags`);e(t,r)},$$slots:{default:!0}}),a(),o(J);var Y=r(J),ot=i(Y);l(ot,{query:`sym:\\bmain\\b`}),o(Y),o(q);var X=r(q),st=r(i(X),2),ct=i(st);l(ct,{query:`case:no TEST`}),o(st),o(X);var Z=r(X),lt=r(i(Z),2),ut=i(lt);l(ut,{query:`archived:no readme`}),o(lt),o(Z);var Q=r(Z),dt=r(i(Q),2),ft=i(dt);l(ft,{query:`fork:no readme`}),o(dt),o(Q);var pt=r(Q),$=r(i(pt),2),mt=i($);l(mt,{query:`public:no readme`}),o($),o(pt),o(We),o(He),o(Ve),e(ee,d)}export{d as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.