【问题标题】:Elasticsearch wont apply not_analyzed into my mappingElasticsearch 不会将 not_analyzed 应用到我的映射中
【发布时间】:2015-04-29 23:56:21
【问题描述】:

当我尝试将“not_analyzed”应用到我的 ES 映射时,它不起作用。

我在 Laravel 中为 ES 使用这个包 - Elasticquent

我的映射如下:

'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 来查看映射,它会输出:

"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 缺失。 我的日志中也看不到任何错误/警告。

【问题讨论】:

  • 我没有发现任何问题,数字未分析(elasticsearch.org/guide/en/elasticsearch/reference/current/…)并且ad_title 具有正确的分析器。您是否尝试过在没有分析器的情况下输入 string 字段并且没有工作?
  • @dimzak 是的,但是 'index' => 'not_analyzed' 应该在之后在映射上进行输出时出现。我在堆栈上看到了另一个线程,其中一个人通过 _mapping?pretty 打印了他的映射。在他的身上,'index' => 'not_analyzed' 显示了

标签: php mysql apache laravel elasticsearch


【解决方案1】:

我从自己的经验中得出的结论是,您必须先进行映射,然后再进行任何索引。删除您创建的索引,分配您的 not_analyzed 映射器,然后再次索引您的字段,您将出现 not_analyzed 字段。请让我知道这是否适合您。谢谢。

【讨论】:

  • 谢谢,我已经尝试过了,但即使那样,“not_analyzed”也不会出现在整数上
【解决方案2】:

有一个简单的测试来看看它是否有效:

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"
               }
            }
         }
      }
   }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-24
    • 2017-01-10
    • 2015-06-29
    • 2016-05-08
    • 2021-01-17
    • 1970-01-01
    相关资源
    最近更新 更多