PageSourceSearch

https://zed.brimdata.io/assets/js/a9b882ae.319435b8.js

js brimdata.io collected 2026-10-03 19:38:40 UTC 7,540 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkzed_docs=self.webpackChunkzed_docs||[]).push([[3978],{3905:function(e,t,n){n.d(t,{Zo:function(){return u},kt:function(){return d}});var r=n(67294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var i=r.createContext({}),s=function(e){var t=r.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},u=function(e){var t=s(e.components);return r.createElement(i.Provider,{value:t},e.children)},c={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,i=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),m=s(n),d=a,g=m["".concat(i,".").concat(d)]||m[d]||c[d]||o;return n?r.createElement(g,l(l({ref:t},u),{},{components:n})):r.createElement(g,l({ref:t},u))}));function d(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,l=new Array(o);l[0]=m;var p={};for(var i in t)hasOwnProperty.call(t,i)&&(p[i]=t[i]);p.originalType=e,p.mdxType="string"==typeof e?e:a,l[1]=p;for(var s=2;s<o;s++)l[s]=n[s];return r.createElement.apply(null,l)}return r.createElement.apply(null,n)}m.displayName="MDXCreateElement"},26292:function(e,t,n){n.r(t),n.d(t,{assets:function(){return u},contentTitle:function(){return i},default:function(){return d},frontMatter:function(){return p},metadata:function(){return s},toc:function(){return c}});var r=n(83117),a=n(80102),o=(n(67294),n(3905)),l=["components"],p={},i=void 0,s={unversionedId:"language/operators/where",id:"version-v1.11.0/language/operators/where",title:"where",description:"Operator",source:"@site/versioned_docs/version-v1.11.0/language/operators/where.md",sourceDirName:"language/operators",slug:"/language/operators/where",permalink:"/docs/v1.11.0/language/operators/where",draft:!1,editUrl:"https://github.com/brimdata/zed/edit/main/docs/language/operators/where.md",tags:[],version:"v1.11.0",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"uniq",permalink:"/docs/v1.11.0/language/operators/uniq"},next:{title:"yield",permalink:"/docs/v1.11.0/language/operators/yield"}},u={},c=[{value:"Operator",id:"operator",level:3},{value:"Synopsis",id:"synopsis",level:3},{value:"Description",id:"description",level:3},{value:"Examples",id:"examples",level:3}],m={toc:c};function d(e){var t=e.components,n=(0,a.Z)(e,l);return(0,o.kt)("wrapper",(0,r.Z)({},m,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h3",{id:"operator"},"Operator"),(0,o.kt)("p",null,"\u2003"," ",(0,o.kt)("strong",{parentName:"p"},"where")," ","\u2014"," select values based on a Boolean expression"),(0,o.kt)("h3",{id:"synopsis"},"Synopsis"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"[where] <expr>\n")),(0,o.kt)("h3",{id:"description"},"Description"),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"where")," operator filters its input by applying a Boolean expression ",(0,o.kt)("inlineCode",{parentName:"p"},"<expr>"),"\nto each input value and dropping each value for which the expression evaluates\nto ",(0,o.kt)("inlineCode",{parentName:"p"},"false")," or to an error."),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"where")," keyword is optional since it is an\n",(0,o.kt)("a",{parentName:"p",href:"/docs/v1.11.0/language/dataflow-model#implied-operators"},"implied operator"),"."),(0,o.kt)("p",null,'The "where" keyword requires a regular Zed expression and does not support\n',(0,o.kt)("a",{parentName:"p",href:"/docs/v1.11.0/language/search-expressions"},"search expressions"),".  Use the\n",(0,o.kt)("a",{parentName:"p",href:"/docs/v1.11.0/language/operators/search"},"search operator")," if you want search syntax."),(0,o.kt)("p",null,'When Zed queries are run interactively, it is highly convenient to be able to omit\nthe "where" keyword, but when where filters appear in Zed source files,\nit is good practice to include the optional keyword.'),(0,o.kt)("h3",{id:"examples"},"Examples"),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"An arithmetic comparison")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-command"},"echo '1 2 3' | zq -z 'where this >= 2' -\n")),(0,o.kt)("p",null,"=>"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-output"},"2\n3\n")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},'The "where" keyword may be dropped')),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-command"},"echo '1 2 3' | zq -z 'this >= 2' -\n")),(0,o.kt)("p",null,"=>"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-output"},"2\n3\n")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"A filter with Boolean logic")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-command"},"echo '1 2 3' | zq -z 'where this >= 2 AND this <= 2' -\n")),(0,o.kt)("p",null,"=>"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-output"},"2\n")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"A filter with array containment logic")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-command"},"echo '1 2 3 4' | zq -z 'where this in [1,4]' -\n")),(0,o.kt)("p",null,"=>"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-output"},"1\n4\n")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"A filter with inverse containment logic")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-command"},"echo '1 2 3 4' | zq -z 'where ! (this in [1,4])' -\n")),(0,o.kt)("p",null,"=>"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-output"},"2\n3\n")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"Boolean functions may be called")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-command"},"echo '1 \"foo\" 10.0.0.1' | zq -z 'where is(<int64>)' -\n")),(0,o.kt)("p",null,"=>"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-output"},"1\n")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"Boolean functions with Boolean logic")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-command"},"echo '1 \"foo\" 10.0.0.1' | zq -z 'where is(<int64>) or is(<ip>)' -\n")),(0,o.kt)("p",null,"=>"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-mdtest-output"},"1\n10.0.0.1\n")))}d.isMDXComponent=!0}}]);

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.