dongqiyang3711 2017-04-11 03:17 采纳率: 100%
浏览 235

PHP Elasticsearch not_analyzed字段按空格分割字符串

My field type is "not_analyzed". I researched many similar issues but these solutions not affected. I'm trying to search exact value of field and getting aggregations. But aggregation returns splitted string.

Example: Asset Sale and Purchase Agreement => "[Asset", "Sale", "and", "Purchase", "Agreement"]

Also .raw field is empty. How to set .raw field value?

in search term "document_type_raw" => "Asset Sale and Purchase Agreement" returns empty. But "document_type_raw" => "sale" returns a result.

My ES version info is:

"number" : "1.7.2",
"build_hash" : "e43676b1385b8125d647f593f7202acbd816e8ec",
"build_timestamp" : "2015-09-14T09:49:53Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"

My mapping is:

$mapping        = [
            "properties" => [
                "metadata"             => [

                    "dynamic_templates" => [
                        "strings" => [
                            "match_mapping_type"    => "string",
                            "match"                 => "*",
                            "mapping"               => [
                                "type"              => "string",
                                "index"             => "not_analyzed"
                            ]
                        ]
                    ],

                    "properties" => [
                        "contract_name"       => [
                            "type"     => "string",
                            "analyzer" => "english",
                            "fields"   => [
                                "raw" => [
                                    "type"  => "string",
                                    "index" => "not_analyzed"
                                ]
                            ]

                        ],
                        "open_contracting_id" => [
                            "type"  => "string",
                            "index" => "not_analyzed"
                        ],
                        "country_name"        => [
                            "type"  => "string",
                            "index" => "not_analyzed"
                        ],
                        "country_code"        => [
                            "type" => "string"
                        ],
                        "signature_year"      => [
                            "type" => "string"
                        ],
                        "signature_date"      => [
                            'type'   => 'date',
                            'format' => 'dateOptionalTime',
                        ],
                        "resource"            => [
                            "type" => "string"
                        ],
                        "resource_raw"        => [
                            "type"  => "string",
                            'index' => 'not_analyzed'
                        ],
                        "file_size"           => [
                            "type" => "integer",
                        ],
                        "language"            => [
                            "type" => "string"
                        ],
                        "category"            => [
                            "type" => "string"
                        ],
                        'contract_type_raw'      =>
                            [
                                'type' => 'string',
                                "index" => "not_analyzed",
                                'include_in_all' => "false"
                            ],
                        'document_type_raw'      =>
                            [
                                'type' => 'keyword',
                                "index" => "not_analyzed",
                                'include_in_all' => "false"
                            ],
                        "contract_type"       => [
                            "type"  => "string",
                            "index" => "not_analyzed"
                        ],
                        'document_type'       =>
                            [
                                'type'     => 'string',
                                "fields"   => [
                                    "raw" => [
                                        "type"  => "string",
                                        "index" => "not_analyzed"
                                    ]
                                ]
                            ],
                        "company_name"        => [
                            "type"  => "string",
                            "fields"   => [
                                "raw" => [
                                    "type"  => "string",
                                    "index" => "not_analyzed"
                                ]
                            ]
                        ],
                        "corporate_grouping"  => [
                            "type"  => "string",
                            "index" => "not_analyzed"
                        ]
                    ]
                ],
                "annotations_category" => [
                    "type"  => "string",
                    "index" => "not_analyzed"
                ],
                "metadata_string"      => [
                    "type" => "string"
                ],
                "pdf_text_string"      => [
                    "type" => "string"
                ],
                "annotations_string"   => [
                    "type" => "string"
                ]
            ]
        ];

Real mapping:

      "master" : {
    "properties" : {
      "metadata" : {
        "properties" : {
          "category" : {
            "type" : "string"
          },
          "company_name" : {
            "type" : "string"
          },
          "contract_name" : {
            "type" : "string"
          },
          "contract_type" : {
            "type" : "string"
          },
          "contract_type_raw" : {
            "type" : "string"
          },
          "country_code" : {
            "type" : "string"
          },
          "country_name" : {
            "type" : "string"
          },
          "district_id" : {
            "type" : "string"
          },
          "document_type" : {
            "type" : "string"
          },
          "document_type_raw" : {
            "type" : "string"
          },
          "file_size" : {
            "type" : "long"
          },
          "language" : {
            "type" : "string"
          },
          "open_contracting_id" : {
            "type" : "string"
          },
          "parent_id" : {
            "type" : "string"
          },
          "province_id" : {
            "type" : "string"
          },
          "resource" : {
            "type" : "string"
          },
          "resource_raw" : {
            "type" : "string"
          },
          "show_pdf_text" : {
            "type" : "string"
          },
          "signature_date" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "signature_year" : {
            "type" : "string"
          }
        }
      },
      "metadata_string" : {
        "type" : "string"
      },
      "pdf_text_string" : {
        "type" : "string"
      }
    }
  }
},
"settings" : {
  "index" : {
    "creation_date" : "1490038552133",
    "number_of_shards" : "5",
    "uuid" : "itB8Ns-5TNKRRBSFojymiQ",
    "version" : {
      "created" : "1070299"
    },
    "number_of_replicas" : "1"
  }
}

Thank you! Very much.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题