term_vector
Вектора терминов содержат информацию о терминах, полученных в процессе анализа, включая:
- список терминов.
- положение (или порядок) каждого термина.
- начальное и конечное смещение символов, сопоставляющие термин его источнику в исходной строке.
- платные нагрузки (если они доступны) — пользовательские двоичные данные, связанные с каждым положением термина.
Эти векторы терминов могут храниться для последующего извлечения по определённому документу.
Параметр term_vector принимает:
| | Векторы терминов не хранятся. (по умолчанию) |
| | Хранятся только термины в поле. |
| | Хранятся термины и позиции. |
| | Хранятся термины и смещения символов. |
| | Хранятся термины, позиции и смещения символов. |
| | Хранятся термины, позиции и платные нагрузки. |
| | Хранятся термины, позиции, смещения и платные нагрузки. |
Для быстрого выделения векторов требуется with_positions_offsets. API векторов терминов может извлечь всё сохранённое.
Установление with_positions_offsets удвоит размер индекса поля.
resp = client.indices.create(
index="my-index-000001",
mappings={
"properties": {
"text": {
"type": "text",
"term_vector": "with_positions_offsets"
}
}
},
)
print(resp)
resp1 = client.index(
index="my-index-000001",
id="1",
document={
"text": "Quick brown fox"
},
)
print(resp1)
resp2 = client.search(
index="my-index-000001",
query={
"match": {
"text": "brown fox"
}
},
highlight={
"fields": {
"text": {}
}
},
)
print(resp2) response = client.indices.create(
index: 'my-index-000001',
body: {
mappings: {
properties: {
text: {
type: 'text',
term_vector: 'with_positions_offsets'
}
}
}
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 1,
body: {
text: 'Quick brown fox'
}
)
puts response
response = client.search(
index: 'my-index-000001',
body: {
query: {
match: {
text: 'brown fox'
}
},
highlight: {
fields: {
text: {}
}
}
}
)
puts response const response = await client.indices.create({
index: "my-index-000001",
mappings: {
properties: {
text: {
type: "text",
term_vector: "with_positions_offsets",
},
},
},
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: 1,
document: {
text: "Quick brown fox",
},
});
console.log(response1);
const response2 = await client.search({
index: "my-index-000001",
query: {
match: {
text: "brown fox",
},
},
highlight: {
fields: {
text: {},
},
},
});
console.log(response2); PUT my-index-000001
{
"mappings": {
"properties": {
"text": {
"type": "text",
"term_vector": "with_positions_offsets"
}
}
}
}
PUT my-index-000001/_doc/1
{
"text": "Quick brown fox"
}
GET my-index-000001/_search
{
"query": {
"match": {
"text": "brown fox"
}
},
"highlight": {
"fields": {
"text": {}
}
}
} | По умолчанию для поля |
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/term-vector.html