Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›Отображение ›Параметры отображения

index_prefixes

Параметр index_prefixes позволяет индексировать префиксы терминов для ускорения поиска по префиксам. Он принимает следующие необязательные настройки:

min_chars

Минимальная длина префикса для индексирования. Должна быть больше 0 и по умолчанию равна 2. Значение включительно.

max_chars

Максимальная длина префикса для индексирования. Должна быть меньше 20 и по умолчанию равна 5. Значение включительно.

В этом примере создается текстовое поле с настройками длины префикса по умолчанию:

resp = client.indices.create(
    index="my-index-000001",
    mappings={
        "properties": {
            "body_text": {
                "type": "text",
                "index_prefixes": {}
            }
        }
    },
)
print(resp)
response = client.indices.create(
  index: 'my-index-000001',
  body: {
    mappings: {
      properties: {
        body_text: {
          type: 'text',
          index_prefixes: {}
        }
      }
    }
  }
)
puts response
const response = await client.indices.create({
  index: "my-index-000001",
  mappings: {
    properties: {
      body_text: {
        type: "text",
        index_prefixes: {},
      },
    },
  },
});
console.log(response);
PUT my-index-000001
{
  "mappings": {
    "properties": {
      "body_text": {
        "type": "text",
        "index_prefixes": { }    
      }
    }
  }
}

Пустой объект настроек будет использовать значения по умолчанию для min_chars и max_chars.

В этом примере используются настраиваемые настройки длины префикса:

resp = client.indices.create(
    index="my-index-000001",
    mappings={
        "properties": {
            "full_name": {
                "type": "text",
                "index_prefixes": {
                    "min_chars": 1,
                    "max_chars": 10
                }
            }
        }
    },
)
print(resp)
response = client.indices.create(
  index: 'my-index-000001',
  body: {
    mappings: {
      properties: {
        full_name: {
          type: 'text',
          index_prefixes: {
            min_chars: 1,
            max_chars: 10
          }
        }
      }
    }
  }
)
puts response
const response = await client.indices.create({
  index: "my-index-000001",
  mappings: {
    properties: {
      full_name: {
        type: "text",
        index_prefixes: {
          min_chars: 1,
          max_chars: 10,
        },
      },
    },
  },
});
console.log(response);
PUT my-index-000001
{
  "mappings": {
    "properties": {
      "full_name": {
        "type": "text",
        "index_prefixes": {
          "min_chars" : 1,
          "max_chars" : 10
        }
      }
    }
  }
}

© 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-prefixes.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API