gpt4 book ai didi

elasticsearch - JAVA的createIndex elasticsearch高级REST客户端错误地进行了设置

转载 作者:行者123 更新时间:2023-12-03 02:23:24 25 4
gpt4 key购买 nike

我正在使用elasticsearch documentation中的这段代码来创建索引。我应该能够将Postman中的索引配置对象粘贴到我的Java代码中。

request.source("{\n" +
" \"settings\" : {\n" +
" \"number_of_shards\" : 1,\n" +
" \"number_of_replicas\" : 0\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"message\" : { \"type\" : \"text\" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : {\n" +
" \"twitter_alias\" : {}\n" +
" }\n" +
"}", XContentType.JSON);

当我执行GET / index_name时,我看到一个具有奇怪结构的索引,其中包含两个映射部分。为什么是这样?我希望有一个映射和一个设置部分。
{
"contacts_4_3t88f9nabk": {
"aliases": {},
"mappings": {
"properties": {
"aliases": {
"properties": {
"twitter_alias": {
"type": "object"
}
}
},
"mappings": {
"properties": {
"properties": {
"properties": {
"message": {
"properties": {
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
},
"settings": {
"properties": {
"number_of_replicas": {
"type": "long"
},
"number_of_shards": {
"type": "long"
}
}
}
}
},
"settings": {
"index": {
"creation_date": "1589442095340",
"number_of_shards": "1",
"number_of_replicas": "1",
"uuid": "othIq5Q2Sgy4eZ3xkxkneg",
"version": {
"created": "7060199"
},
"provided_name": "contacts_4_3t88f9nabk"
}
}
}
}

最佳答案

我需要使用CreateIndexRequest对象而不是IndexRequest。

关于elasticsearch - JAVA的createIndex elasticsearch高级REST客户端错误地进行了设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61791991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com