|
22 | 22 | "cell_type": "markdown", |
23 | 23 | "metadata": {}, |
24 | 24 | "source": [ |
25 | | - "### Install packages and import modules\n" |
| 25 | + "### Install packages and import modules" |
26 | 26 | ] |
27 | 27 | }, |
28 | 28 | { |
|
38 | 38 | }, |
39 | 39 | "outputs": [], |
40 | 40 | "source": [ |
41 | | - "#r \"nuget: Elastic.Clients.Elasticsearch\"\n", |
| 41 | + "#r \"nuget: Elastic.Clients.Elasticsearch, 8.15.10\"\n", |
42 | 42 | "#r \"nuget: System.Net.Http.Json, 8.0.1\"\n", |
43 | 43 | "\n", |
44 | 44 | "#!import ./Utils.cs\n", |
|
51 | 51 | "source": [ |
52 | 52 | "## Initialize the Elasticsearch client\n", |
53 | 53 | "\n", |
54 | | - "Now, we need to initialize the Elasticsearch client. We will use the [Elasticsearch client for .NET](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html) to connect to Elasticsearch.\n" |
| 54 | + "Now, we need to initialize the Elasticsearch client. We will use the [Elasticsearch client for .NET](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html) to connect to Elasticsearch." |
55 | 55 | ] |
56 | 56 | }, |
57 | 57 | { |
|
254 | 254 | "using Elastic.Clients.Elasticsearch.IndexManagement;\n", |
255 | 255 | "using Elastic.Clients.Elasticsearch.Mapping;\n", |
256 | 256 | "\n", |
257 | | - "\n", |
258 | | - "var indexDescriptor = new CreateIndexRequestDescriptor<Book>(\"book_index\")\n", |
259 | | - " .Mappings(m => m\n", |
| 257 | + "var indexResponse = await client.Indices.CreateAsync<Book>(\"book_index\", d =>\n", |
| 258 | + " d.Mappings(m => m\n", |
260 | 259 | " .Properties(pp => pp\n", |
261 | 260 | " .Text(p => p.Title)\n", |
262 | | - " .DenseVector(\n", |
263 | | - " Infer.Property<Book>(p => p.TitleVector),\n", |
264 | | - " d => d.Dims(textEmeddingDimension).Index(true).Similarity(DenseVectorSimilarity.Cosine))\n", |
| 261 | + " .DenseVector(Infer.Property<Book>(p => p.TitleVector),\n", |
| 262 | + " d => d\n", |
| 263 | + " .Dims(textEmeddingDimension)\n", |
| 264 | + " .Index(true)\n", |
| 265 | + " .Similarity(DenseVectorSimilarity.Cosine))\n", |
265 | 266 | " .Text(p => p.Summary)\n", |
266 | 267 | " .Date(p => p.publish_date)\n", |
267 | 268 | " .IntegerNumber(p => p.num_reviews)\n", |
268 | 269 | " .Keyword(p => p.Publisher)\n", |
| 270 | + " .Keyword(p => p.Authors)\n", |
269 | 271 | " )\n", |
270 | | - " );\n", |
271 | | - "\n", |
272 | | - "var indexResponse = await client.Indices.CreateAsync<Book>(indexDescriptor);\n", |
| 272 | + " ));\n", |
273 | 273 | "\n", |
274 | 274 | "DumpRequest(indexResponse);" |
275 | 275 | ] |
|
384 | 384 | " .IndexMany<Book>(books, (bd, b) => bd.Index(\"book_index\"))\n", |
385 | 385 | ");\n", |
386 | 386 | "\n", |
387 | | - "// bulkResponse.Display();" |
| 387 | + "bulkResponse.Display();" |
388 | 388 | ] |
389 | 389 | }, |
390 | 390 | { |
|
485 | 485 | { |
486 | 486 | "cell_type": "code", |
487 | 487 | "execution_count": null, |
488 | | - "metadata": {}, |
| 488 | + "metadata": { |
| 489 | + "dotnet_interactive": { |
| 490 | + "language": "csharp" |
| 491 | + }, |
| 492 | + "polyglot_notebook": { |
| 493 | + "kernelName": "csharp" |
| 494 | + } |
| 495 | + }, |
489 | 496 | "outputs": [], |
490 | 497 | "source": [ |
491 | 498 | "var searchQuery = \"javascript books\";\n", |
|
0 commit comments