index_options
Параметр index_options управляет информацией, добавляемой в инвертированный индекс для целей поиска и выделения. Эту конфигурацию поддерживают только типы полей, основанные на терминах, такие как text и keyword.
Параметр принимает одно из следующих значений. Каждое значение извлекает информацию из предыдущих перечисленных значений. Например, freqs содержит docs; positions содержит как freqs, так и docs.
-
docs - Индексируется только номер документа. Отвечает на вопрос Существует ли этот термин в этом поле?
-
freqs - Индексируются номер документа и частоты терминов. Частоты терминов используются для присвоения более высоких оценок повторяющимся терминам по сравнению с одиночными.
-
positions(по умолчанию) - Индексируются номер документа, частоты терминов и позиции терминов (или порядок). Позиции могут использоваться для запросов по близости или фразам.
-
offsets - Индексируются номер документа, частоты терминов, позиции и начальные и конечные смещения символов (которые сопоставляют термин обратно с исходной строкой). Смещения используются унифицированным выделением для ускорения выделения.
resp = client.indices.create(
index="my-index-000001",
mappings={
"properties": {
"text": {
"type": "text",
"index_options": "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',
index_options: '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",
index_options: "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",
"index_options": "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/index-options.html