[英]Timeout when indexing document with custom analyzer
我正在为将在项目中使用的索引创建映射。 给定功能的范围,我希望可以通过不区分大小写的术语查询来搜索大多数字段。 我曾使用过一个自定义分析器(如此处建议的分析器: Elasticsearch Map大小写对not_analyzed文档不敏感 ),但是当我尝试为文档建立索引时,该过程将挂起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。
问题是您有1个节点和一个索引,其中包含1个主分片和5个副本分片。
由于主数据库的副本不会与主数据库在同一节点上分配,因此这5个副本将全部未分配。 为文档建立索引时,这是一个问题; 默认情况下,索引操作的写入一致性为quorum
,并且法定数量6(1个主副本+ 5个副本)为4( n/2 + 1
)。 这意味着文档必须已写入同一分片的主副本和3个副本才能成功。 使用未分配的分片,将无法满足此要求。 您会在日志中看到UnavailableShardsException
,并显示一条错误消息。
将索引更改为5个分片和1个副本将解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.