php - 不确定我的映射在 Elasticsearch 中是否有效

标签 php mysql apache laravel elasticsearch

我正在将 ES 与我的 Laravel 应用程序一起使用 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 调用_mapping?之后就很漂亮了

我的映射如下所示:

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

之后我应该能够在映射中看到 'index' => 'not_analyzed' 吗?或者 'index' => 'not_analyzed' 之后不会显示在 map 结构中?

最佳答案

您是对的,映射未得到应用。如果正确应用,您将在映射 API 中看到 not_analyzed。

确保在写入任何数据之前应用映射。我们在应用程序启动时应用映射,以验证映射始终正确并应用任何映射更新。

以下是如何应用映射的示例:

PUT hilden1

PUT hilden1/type1/_mapping
{
  "properties": {
    "regular": {
      "type": "string"
    },
    "indexSpecified": {
      "type": "string",
      "index": "not_analyzed"
    }
  }
}

要验证映射,请使用 GET api

GET hilden1/type1/_mapping

您应该看到字段“regular”仅指定其类型,其中“indexSpecified”被列为 not_analyzed。这是我运行 ES 1.4.4 的机器的输出

{
   "hilden1": {
      "mappings": {
         "type1": {
            "properties": {
               "indexSpecified": {
                  "type": "string",
                  "index": "not_analyzed"
               },
               "regular": {
                  "type": "string"
               }
            }
         }
      }
   }
}

关于php - 不确定我的映射在 Elasticsearch 中是否有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28745423/

相关文章:

python - 如何在 LXLE 上使用 Apache 和 mod_wsgi 为 Django 应用程序提供服务

apache - .htaccess:将根 url 重定向到子目录,但保留根 url

php - 如何隐藏php代码和mysql表模式

php - 无法通过PHP连接MYSQL,但可以通过phpMyAdmin使用

php - 匹配字符集和可选实体

php - 如何从一张表中查找不匹配的记录

mysql如何查找相对于父行的子行总数

javascript - 使用 PHP DB 填充 JQuery 自动完成的最佳实践

MySQL查询时间段和最大下降值与前一个最大值

PHP 总是创建一个新 session