Elasticsearch 不会将 not_analyzed 应用到我的映射中
Elasticsearch wont apply not_analyzed into my mapping
当我尝试将 "not_analyzed" 应用到我的 ES 映射时,它不起作用。
我在 Laravel - Elasticquent
中将此包用于 ES
我的映射看起来像:
'ad_title' => [
'type' => 'string',
'analyzer' => 'standard'
],
'ad_type' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
'ad_type' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
'ad_state' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
之后我调用 API get 来查看映射,它会输出:
"testindex": {
"mappings": {
"ad_ad": {
"properties": {
"ad_city": {
"type": "integer"
},
"ad_id": {
"type": "long"
},
"ad_state": {
"type": "integer"
},
"ad_title": {
"type": "string",
"analyzer": "standard"
},
"ad_type": {
"type": "integer"
},
请注意缺少 not_analyzed。
我在日志中也看不到任何 errors/warnings。
有一个简单的测试可以看看它是否有效:
PUT /stack
{
"mappings": {
"try": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"age": {
"type": "integer",
"index": "not_analyzed"
}
}
}
}
}
GET /stack/_mapping
响应是:
{
"stack": {
"mappings": {
"try": {
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
我根据自己的经验得出的结论是,在进行任何索引之前必须先进行映射。删除您创建的索引,分配您的 not_analyzed 映射器,然后再次为您的字段编制索引,您将看到 not_analyzed 字段。如果这对您有用,请告诉我。谢谢。
当我尝试将 "not_analyzed" 应用到我的 ES 映射时,它不起作用。
我在 Laravel - Elasticquent
中将此包用于 ES我的映射看起来像:
'ad_title' => [
'type' => 'string',
'analyzer' => 'standard'
],
'ad_type' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
'ad_type' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
'ad_state' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
之后我调用 API get 来查看映射,它会输出:
"testindex": {
"mappings": {
"ad_ad": {
"properties": {
"ad_city": {
"type": "integer"
},
"ad_id": {
"type": "long"
},
"ad_state": {
"type": "integer"
},
"ad_title": {
"type": "string",
"analyzer": "standard"
},
"ad_type": {
"type": "integer"
},
请注意缺少 not_analyzed。 我在日志中也看不到任何 errors/warnings。
有一个简单的测试可以看看它是否有效:
PUT /stack
{
"mappings": {
"try": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"age": {
"type": "integer",
"index": "not_analyzed"
}
}
}
}
}
GET /stack/_mapping
响应是:
{
"stack": {
"mappings": {
"try": {
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
我根据自己的经验得出的结论是,在进行任何索引之前必须先进行映射。删除您创建的索引,分配您的 not_analyzed 映射器,然后再次为您的字段编制索引,您将看到 not_analyzed 字段。如果这对您有用,请告诉我。谢谢。