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

时间:2017-04-11 03:17:51

标签: php elasticsearch

我的字段类型是" not_analyzed"。我研究了许多类似的问题,但这些解决方案没有受到影我试图搜索字段的确切值并获取聚合。但聚合返回splitted string。

示例:资产出售和购买协议=> " [资产","销售","","购买","协议"]

此外.raw字段为空。如何设置.raw字段值?

在搜索字词" document_type_raw" => "资产买卖协议"返回空。但" document_type_raw" => "销售"返回结果。

我的ES版本信息是:

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

我的映射是:

$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"
                ]
            ]
        ];

真实地图:

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

谢谢!非常。

0 个答案:

没有答案