【发布时间】:2016-12-10 14:47:36
【问题描述】:
我正在为将在项目中使用的索引创建映射。 鉴于功能的领域,我希望大多数字段都可以通过不区分大小写的术语查询进行搜索。 我使用了一个自定义分析器(就像这里建议的那样:Elasticsearch Map case insensitive to not_analyzed documents),但是当我尝试索引文档时,该过程会挂起 60 秒,直到发生超时并且整个过程失败。 当我在 Sense 上进行测试时,我看到了相同的行为。
这是索引定义:
put /emails
{
"mappings": {
"email": {
"properties": {
"createdOn": {
"type": "date",
"store": true,
"format": "strict_date_optional_time||epoch_millis"
},
"data": {
"type": "object",
"dynamic": "true"
},
"from": {
"type": "string",
"store": true
},
"id": {
"type": "string",
"store": true
},
"sentOn": {
"type": "date",
"store": true,
"format": "strict_date_optional_time||epoch_millis"
},
"sesId": {
"type": "string",
"store": true
},
"subject": {
"type": "string",
"store": true,
"analyzer": "standard"
},
"templates": {
"properties": {
"html": {
"type": "string",
"store": true
},
"plainText": {
"type": "string",
"store": true
}
}
},
"to": {
"type": "string",
"store": true
},
"type": {
"type": "string",
"store": true
}
}
},
"event": {
"_parent": {
"type": "email"
},
"properties": {
"id": {
"type": "string",
"store": true
},
"origin": {
"type": "string",
"store": true
},
"time": {
"type": "date",
"store": true,
"format": "strict_date_optional_time||epoch_millis"
},
"type": {
"type": "string",
"store": true
},
"userAgent": {
"type": "string",
"store": true
}
}
}
},
"settings": {
"number_of_shards": "5",
"number_of_replicas": "0",
"analysis": {
"analyzer": {
"default": {
"tokenizer": "keyword",
"filter": [
"lowercase"
],
"type": "custom"
}
}
}
}
}
如您所见,我将分析器定义为“默认”(如果我尝试使用另一个名称并将其定义为两种类型的默认分析器,则会收到 "Root mapping definition has unsupported parameters: [analyzer : my_analyzer]" 错误)。
这是我试图将文档添加到索引中
post /emails/email/1
{
"from": "email-address-1",
"to": "email-address-2",
"subject": "Hello world",
"data":{
"status": "SENT"
}
}
我真的不明白为什么会发生这种超时。 我还尝试通过 C# 控制台应用程序使用 NEST。同样的行为。
谢谢。
PS:为了测试,我同时使用 AWS 托管的 Elasticsearch 2.3 和本地 docker 容器中托管的 Elasticsearch 2.3。
【问题讨论】:
-
集群中是否有足够的节点,在这个开发阶段是否值得拥有 5 个副本?
-
这是一个由单个节点临时制作的生产集群。目前是空的,创建一个新的集群可以让它空。
-
我认为应该是 5 个分片和 1 个副本。在开发过程中,您可以将副本设置为 0,然后在投入生产之前对其进行更新。
-
我注意到上面的索引定义不是给我带来问题的那个。我更新了问题。
-
将索引更改为 5 个分片和 1 个副本可以解决问题。一个节点上有 5 个副本和 1 个主分片的问题是没有足够的活动副本来满足默认的 quorum 写入一致性 4 (
n/2 +1),因为副本将在单个节点上全部取消分配。您将在日志中看到UnavailableShardsException并带有错误消息。
标签: c# elasticsearch nest