{"title":"Full-text search","description":"Search text across Altertable tables with SQL-native full-text search for faster discovery across lakehouse data.","order":670,"askSuggestions":["When should I use full-text search instead of LIKE?","How do I search log messages within a time range?"],"navigation":true,"routeId":"lakehouseFullTextSearch","body":{"code":"var Component=(()=>{var m=Object.create;var o=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),y=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},a=(t,e,r,s)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of p(e))!g.call(t,i)&&i!==r&&o(t,i,{get:()=>e[i],enumerable:!(s=x(e,i))||s.enumerable});return t};var b=(t,e,r)=>(r=t!=null?m(f(t)):{},a(e||!t||!t.__esModule?o(r,\"default\",{value:t,enumerable:!0}):r,t)),v=t=>a(o({},\"__esModule\",{value:!0}),t);var c=w((E,l)=>{l.exports=_jsx_runtime});var D={};y(D,{default:()=>u,frontmatter:()=>I});var n=b(c()),I={title:\"Full-text search\",routeId:\"lakehouseFullTextSearch\",description:\"Search text across Altertable tables with SQL-native full-text search for faster discovery across lakehouse data.\",order:670,askSuggestions:[\"When should I use full-text search instead of LIKE?\",\"How do I search log messages within a time range?\"]};function h(t){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...t.components},{DocsPreviewDocument:r,DocsPreviewSection:s}=e;return r||d(\"DocsPreviewDocument\",!0),s||d(\"DocsPreviewSection\",!0),(0,n.jsxs)(r,{anchors:\"full-text-search create-an-index query-with-filters when-to-use-it learn-more\",children:[(0,n.jsxs)(s,{sectionId:\"full-text-search\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"full-text-search\",children:\"Full-text search\"}),`\n`,(0,n.jsx)(e.p,{children:\"Full-text search indexes text columns so queries can find records by words, phrases, and approximate text matches without scanning every value as plain strings.\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Use it for log messages, trace messages, support tickets, documents, event properties, or any table where users search by text rather than exact IDs. The built-in \",(0,n.jsx)(e.code,{children:\"opentelemetry\"}),\" catalog uses full-text indexes on message fields so logs and spans can be searched quickly.\"]}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"create-an-index\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"create-an-index\",children:\"Create an index\"}),`\n`,(0,n.jsx)(e.p,{children:\"Create a full-text index on the column you search most often:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-sql\",children:`CREATE INDEX logs_message_fts\nON opentelemetry.main.logs\nUSING TNVYX(message);\n`})}),`\n`,(0,n.jsx)(e.p,{children:\"Index names must be unique in the table. Build indexes on columns with meaningful free-form text; low-cardinality fields such as status codes are usually better handled with normal filters.\"}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"query-with-filters\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,n.jsx)(e.h2,{id:\"query-with-filters\",children:\"Query with filters\"}),`\n`,(0,n.jsx)(e.p,{children:\"Combine text search with time and service filters so the engine can narrow the scan before ranking or returning matches:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-sql\",children:`SELECT\n  timestamp,\n  service_name,\n  severity_text,\n  message\nFROM opentelemetry.main.logs\nWHERE timestamp >= now() - INTERVAL '1 day'\n  AND service_name = 'api'\n  AND message @@ 'payment timeout'\nORDER BY timestamp DESC\nLIMIT 100;\n`})}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"when-to-use-it\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,n.jsx)(e.h2,{id:\"when-to-use-it\",children:\"When to use it\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Use full-text search when exact equality, \",(0,n.jsx)(e.code,{children:\"LIKE\"}),\", or JSON field filters are too narrow or too slow for the question. Keep structured predicates in the query whenever possible; they make text search more selective and easier to reason about.\"]}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"learn-more\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,n.jsx)(e.h2,{id:\"learn-more\",children:\"Learn more\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/opentelemetry\",children:\"OpenTelemetry\"})}),\": logs and traces stored in the lakehouse.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/query/sql-explorer\",children:\"SQL Explorer\"})}),\": test search queries interactively.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/sql-engine\",children:\"SQL engine\"})}),\": DuckDB SQL support in Altertable.\"]}),`\n`]})]})]})}function u(t={}){let{wrapper:e}=t.components||{};return e?(0,n.jsx)(e,{...t,children:(0,n.jsx)(h,{...t})}):h(t)}function d(t,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+t+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return v(D);})();\n;return Component;"},"_id":"docs/lakehouse/features/full-text-search.mdx","_raw":{"sourceFilePath":"docs/lakehouse/features/full-text-search.mdx","sourceFileName":"full-text-search.mdx","sourceFileDir":"docs/lakehouse/features","contentType":"mdx","flattenedPath":"docs/lakehouse/features/full-text-search"},"type":"Docs","path":"/lakehouse/features/full-text-search","level":3,"parent":"lakehouse/features"}