我是ElasticSearch的新手,正在尝试执行他们在主页中提到的示例,我遇到了这个问题-
public class RewriteRules
{
public static void RedirectRequests(RewriteContext context)
{
var request = context.HttpContext.Request;
if (request.Path.Value.EndsWith("/", StringComparison.OrdinalIgnoreCase))
{
context.HttpContext.Response.Redirect("/Home.html");
}
else if(!request.Path.Value.EndsWith(".html", StringComparison.OrdinalIgnoreCase))
{
context.HttpContext.Response.Redirect($"{ request.Path.Value }.html");
}
}
public static void ReWriteRequests(RewriteContext context)
{
var request = context.HttpContext.Request;
if (request.Path.Value.EndsWith(".html", StringComparison.OrdinalIgnoreCase))
{
context.HttpContext.Request.Path = context.HttpContext.Request.Path.Value.Replace(".html","");
}
}
}
发布请求的网址和正文如下-
URL-> http://localhost:9200/company 身体->
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "unknown setting [index.mappings.employee.properties.age.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
}
],
"type": "illegal_argument_exception",
"reason": "unknown setting [index.mappings.employee.properties.age.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings",
"suppressed": [
{
"type": "illegal_argument_exception",
"reason": "unknown setting [index.mappings.employee.properties.experience.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
},
{
"type": "illegal_argument_exception",
"reason": "unknown setting [index.mappings.employee.properties.name.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
},
{
"type": "illegal_argument_exception",
"reason": "unknown setting [index.mappings.employee.properties.name.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
}
]
},
"status": 400
}
如何解决该错误?
答案 0 :(得分:1)
JSON主体对象的语法有两个错误:
settings
必须只有两个孩子:index
和analysis
。节点mappings
必须是根级别的。name
的类型string
无效,必须为text
或keyword
。由于您需要分析此字段,因此在您的情况下应为text
。所以工作查询应该是这样的:
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"analysis": {
"analyzer": {
"analyzer-name": {
"type": "custom",
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
},
"mappings": {
"employee": {
"properties": {
"age": {
"type": "long"
},
"experience": {
"type": "long"
},
"name": {
"type": "text",
"analyzer": "analyzer-name"
}
}
}
}
}
答案 1 :(得分:0)
As you mentioned that you are new to Elastic Search, better start with the basic and use the default settings of ElasticSearch. Use the following mapping:
curl -XPUT localhost:9200/company -d '{
"mappings": {
"employee": {
"properties": {
"age": {"type": "long"},
"experience": {"type": "long"},
"name": {"type": "string","index": "not_analyzed"}
}
}
}
}'