使用映射创建索引的问题
Issue with create index with mapping
我正在使用弹性搜索版本 7.1.0 和 NEST 6.7.0 以及 Elasticsearch.Net 6.7.0。
当我尝试创建索引时出现错误。
这是我的代码,我在 NEST 和 Elasticsearch.Net 版本 6.4.0 上使用了相同的代码并且运行良好
var result = Client.CreateIndex(DefaultIndex, c => c
.Settings(s => s
.NumberOfShards(numberOfShards)
.NumberOfReplicas(numberOfReplicas)
.BlocksReadOnly(false)
)
.Mappings(m => m
.Map<SearchDocument>(mm => mm
.AutoMap(3)
)
)
);
这是我得到的错误
Invalid NEST response built from a unsuccessful low level call on PUT:
/local_brainbank_index
Audit trail of this API call:
- [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.2880040
OriginalException: Elasticsearch.Net.ElasticsearchClientException: The remote server returned an error: (400) Bad Request.. Call: Status
code 400 from: PUT /local_brainbank_index. ServerError: Type:
mapper_parsing_exception Reason: "Failed to parse mapping [_doc]: Root
mapping definition has unsupported parameters: [searchdocument :
{properties={sourceId={type=integer}, sourceType={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
authorName={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, subject={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
imageURL={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, id={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, sourceName={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, body={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text,
fields={keyword={ignore_above=256, type=keyword}}}}}]" CausedBy:
"Type: mapper_parsing_exception Reason: "Root mapping definition has
unsupported parameters: [searchdocument :
{properties={sourceId={type=integer}, sourceType={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
authorName={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, subject={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
imageURL={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, id={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, sourceName={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, body={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text,
fields={keyword={ignore_above=256, type=keyword}}}}}]"" --->
System.Net.WebException: The remote server returned an error: (400)
Bad Request. at System.Net.HttpWebRequest.GetResponse() at
Elasticsearch.Net.HttpWebRequestConnection.Request[TResponse](RequestData
requestData) --- End of inner exception stack trace ---
要求:
{"mappings":{"searchdocument":{"properties":{"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"sourceType":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"sourceId":{"type":"integer"},"sourceName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"authorName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"subject":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"body":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"uRL":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"imageURL":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index.number_of_replicas":0,"index.blocks.read_only":false,"index.number_of_shards":1}}
回复:
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root
mapping definition has unsupported parameters: [searchdocument :
{properties={sourceId={type=integer}, sourceType={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
authorName={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, subject={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
imageURL={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, id={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, sourceName={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, body={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text,
fields={keyword={ignore_above=256,
type=keyword}}}}}]"}],"type":"mapper_parsing_exception","reason":"Failed
to parse mapping [_doc]: Root mapping definition has unsupported
parameters: [searchdocument : {properties={sourceId={type=integer},
sourceType={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, authorName={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
subject={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, imageURL={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, id={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
sourceName={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, body={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, uRL={type=text, fields={keyword={ignore_above=256,
type=keyword}}}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root
mapping definition has unsupported parameters: [searchdocument :
{properties={sourceId={type=integer}, sourceType={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
authorName={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, subject={type=text,
fields={keyword={ignore_above=256, type=keyword}}},
imageURL={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, id={type=text, fields={keyword={ignore_above=256,
type=keyword}}}, sourceName={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, body={type=text,
fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text,
fields={keyword={ignore_above=256, type=keyword}}}}}]"}},"status":400}
NEST 和 Elasticsearch.Net 6.7.0 与 Elasticsearch 7.x 不兼容。请使用NEST和Elasticsearch.Net7.x,目前最新发布7.0.0-alpha2
我正在使用弹性搜索版本 7.1.0 和 NEST 6.7.0 以及 Elasticsearch.Net 6.7.0。 当我尝试创建索引时出现错误。
这是我的代码,我在 NEST 和 Elasticsearch.Net 版本 6.4.0 上使用了相同的代码并且运行良好
var result = Client.CreateIndex(DefaultIndex, c => c
.Settings(s => s
.NumberOfShards(numberOfShards)
.NumberOfReplicas(numberOfReplicas)
.BlocksReadOnly(false)
)
.Mappings(m => m
.Map<SearchDocument>(mm => mm
.AutoMap(3)
)
)
);
这是我得到的错误
Invalid NEST response built from a unsuccessful low level call on PUT: /local_brainbank_index
Audit trail of this API call:
- [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.2880040
OriginalException: Elasticsearch.Net.ElasticsearchClientException: The remote server returned an error: (400) Bad Request.. Call: Status
code 400 from: PUT /local_brainbank_index. ServerError: Type: mapper_parsing_exception Reason: "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [searchdocument : {properties={sourceId={type=integer}, sourceType={type=text, fields={keyword={ignore_above=256, type=keyword}}}, authorName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, subject={type=text, fields={keyword={ignore_above=256, type=keyword}}}, imageURL={type=text, fields={keyword={ignore_above=256, type=keyword}}}, id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, sourceName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, body={type=text, fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]" CausedBy: "Type: mapper_parsing_exception Reason: "Root mapping definition has unsupported parameters: [searchdocument : {properties={sourceId={type=integer}, sourceType={type=text, fields={keyword={ignore_above=256, type=keyword}}}, authorName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, subject={type=text, fields={keyword={ignore_above=256, type=keyword}}}, imageURL={type=text, fields={keyword={ignore_above=256, type=keyword}}}, id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, sourceName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, body={type=text, fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]"" ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at Elasticsearch.Net.HttpWebRequestConnection.Request[TResponse](RequestData requestData) --- End of inner exception stack trace ---
要求:
{"mappings":{"searchdocument":{"properties":{"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"sourceType":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"sourceId":{"type":"integer"},"sourceName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"authorName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"subject":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"body":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"uRL":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"imageURL":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index.number_of_replicas":0,"index.blocks.read_only":false,"index.number_of_shards":1}}
回复:
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [searchdocument : {properties={sourceId={type=integer}, sourceType={type=text, fields={keyword={ignore_above=256, type=keyword}}}, authorName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, subject={type=text, fields={keyword={ignore_above=256, type=keyword}}}, imageURL={type=text, fields={keyword={ignore_above=256, type=keyword}}}, id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, sourceName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, body={type=text, fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [searchdocument : {properties={sourceId={type=integer}, sourceType={type=text, fields={keyword={ignore_above=256, type=keyword}}}, authorName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, subject={type=text, fields={keyword={ignore_above=256, type=keyword}}}, imageURL={type=text, fields={keyword={ignore_above=256, type=keyword}}}, id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, sourceName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, body={type=text, fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [searchdocument : {properties={sourceId={type=integer}, sourceType={type=text, fields={keyword={ignore_above=256, type=keyword}}}, authorName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, subject={type=text, fields={keyword={ignore_above=256, type=keyword}}}, imageURL={type=text, fields={keyword={ignore_above=256, type=keyword}}}, id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, sourceName={type=text, fields={keyword={ignore_above=256, type=keyword}}}, body={type=text, fields={keyword={ignore_above=256, type=keyword}}}, uRL={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]"}},"status":400}
NEST 和 Elasticsearch.Net 6.7.0 与 Elasticsearch 7.x 不兼容。请使用NEST和Elasticsearch.Net7.x,目前最新发布7.0.0-alpha2