90 lines
1.7 KiB
Plaintext
90 lines
1.7 KiB
Plaintext
// This file is autogenerated, DO NOT EDIT
|
|
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
|
|
|
[source, js]
|
|
----
|
|
const response = await client.indices.create({
|
|
index: "retrievers_example_nested",
|
|
settings: {
|
|
number_of_shards: 1,
|
|
},
|
|
mappings: {
|
|
properties: {
|
|
nested_field: {
|
|
type: "nested",
|
|
properties: {
|
|
paragraph_id: {
|
|
type: "keyword",
|
|
},
|
|
nested_vector: {
|
|
type: "dense_vector",
|
|
dims: 3,
|
|
similarity: "l2_norm",
|
|
index: true,
|
|
index_options: {
|
|
type: "flat",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
topic: {
|
|
type: "keyword",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response);
|
|
|
|
const response1 = await client.index({
|
|
index: "retrievers_example_nested",
|
|
id: 1,
|
|
document: {
|
|
nested_field: [
|
|
{
|
|
paragraph_id: "1a",
|
|
nested_vector: [-1.12, -0.59, 0.78],
|
|
},
|
|
{
|
|
paragraph_id: "1b",
|
|
nested_vector: [-0.12, 1.56, 0.42],
|
|
},
|
|
{
|
|
paragraph_id: "1c",
|
|
nested_vector: [1, -1, 0],
|
|
},
|
|
],
|
|
topic: ["ai"],
|
|
},
|
|
});
|
|
console.log(response1);
|
|
|
|
const response2 = await client.index({
|
|
index: "retrievers_example_nested",
|
|
id: 2,
|
|
document: {
|
|
nested_field: [
|
|
{
|
|
paragraph_id: "2a",
|
|
nested_vector: [0.23, 1.24, 0.65],
|
|
},
|
|
],
|
|
topic: ["information_retrieval"],
|
|
},
|
|
});
|
|
console.log(response2);
|
|
|
|
const response3 = await client.index({
|
|
index: "retrievers_example_nested",
|
|
id: 3,
|
|
document: {
|
|
topic: ["ai"],
|
|
},
|
|
});
|
|
console.log(response3);
|
|
|
|
const response4 = await client.indices.refresh({
|
|
index: "retrievers_example_nested",
|
|
});
|
|
console.log(response4);
|
|
----
|