<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dapr Search JavaScript SDK on Dapr Docs</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-search/</link><description>Recent content in Dapr Search JavaScript SDK on Dapr Docs</description><generator>Hugo</generator><language>en</language><atom:link href="https://docs.dapr.io/developing-applications/sdks/js/js-search/index.xml" rel="self" type="application/rss+xml"/><item><title>How to: Index and search documents with the Dapr JavaScript SDK</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-search/js-search-howto/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.dapr.io/developing-applications/sdks/js/js-search/js-search-howto/</guid><description>&lt;p>Use &lt;code>DaprClient.search&lt;/code> to manage indexes and search JSON documents through a Dapr search component. This guide uses Meilisearch and covers index creation, document writes, full-text search, filtering, sorting, pagination, retrieval, and deletion. All examples work over HTTP or gRPC.&lt;/p>
&lt;h2 id="prerequisites">Prerequisites&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://docs.dapr.io/getting-started/install-dapr-cli/">Dapr CLI&lt;/a>&lt;/li>
&lt;li>An initialized &lt;a href="https://docs.dapr.io/getting-started/install-dapr-selfhost/">Dapr environment&lt;/a> with Dapr runtime 1.19 or later&lt;/li>
&lt;li>&lt;a href="https://nodejs.org/">Node.js&lt;/a> 18 or later&lt;/li>
&lt;li>&lt;a href="https://docs.docker.com/get-docker/">Docker&lt;/a> to run Meilisearch locally&lt;/li>
&lt;li>The &lt;a href="https://www.npmjs.com/package/@dapr/dapr">&lt;code>@dapr/dapr&lt;/code>&lt;/a> package, version 3.19.0 or later&lt;/li>
&lt;/ul>
&lt;p>In your application directory, initialize an npm project if you do not already have one, then install the SDK:&lt;/p></description></item><item><title>Search client usage</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-search/js-search-client-usage/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.dapr.io/developing-applications/sdks/js/js-search/js-search-client-usage/</guid><description>&lt;p>Search is available through &lt;code>DaprClient.search&lt;/code> in JavaScript SDK 3.19.0 or later and requires Dapr runtime 1.19 or later. HTTP and gRPC use the alpha Search API and expose the same methods and JavaScript result shapes.&lt;/p>
&lt;h2 id="client-lifetime-and-configuration">Client lifetime and configuration&lt;/h2>
&lt;p>Reuse a long-lived &lt;code>DaprClient&lt;/code>. Await outstanding operations before calling &lt;code>await client.stop()&lt;/code> during application shutdown.&lt;/p>
&lt;p>HTTP is the default protocol. To explicitly configure gRPC:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">CommunicationProtocolEnum&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">DaprClient&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="nx">from&lt;/span> &lt;span class="s2">&amp;#34;@dapr/dapr&amp;#34;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">client&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">new&lt;/span> &lt;span class="nx">DaprClient&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">daprHost&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s2">&amp;#34;127.0.0.1&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">daprPort&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s2">&amp;#34;50001&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">communicationProtocol&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="nx">CommunicationProtocolEnum&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">GRPC&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">daprApiToken&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="nx">process&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">env&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">DAPR_API_TOKEN&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For HTTP, use &lt;code>CommunicationProtocolEnum.HTTP&lt;/code> and the sidecar&amp;rsquo;s HTTP port (default &lt;code>&amp;quot;3500&amp;quot;&lt;/code>). Port values are strings. When host and port are not explicitly supplied, the SDK can use &lt;code>DAPR_HTTP_ENDPOINT&lt;/code> or &lt;code>DAPR_GRPC_ENDPOINT&lt;/code> for the selected protocol, or fall back to the host and port defaults and &lt;code>DAPR_HTTP_PORT&lt;/code> or &lt;code>DAPR_GRPC_PORT&lt;/code>. The API token defaults to &lt;code>DAPR_API_TOKEN&lt;/code>. See &lt;a href="https://docs.dapr.io/developing-applications/sdks/js/js-client/#environment-variables">client configuration&lt;/a>.&lt;/p></description></item></channel></rss>