0

これは私を夢中にさせています。私は自分のデータにいくつかの配列を持っています。これはスリム化されたバージョンです:

{
"fullName": "Jane Doe",
"comments": [],
"tags": [
    "blah blah tag 1",
    "blah blah tag 1"
],
"contactInformation": {
    "attachments": [
        "some file 1",
        "some file 2",
        "some file 3"
    ]
}
}

わかりましたので、elasticsearch での私のマッピングは次のとおりです。

curl -XPOST localhost:9200/myindex -d '{
"settings" : {
    "number_of_shards" : 1
},
"mappings" : {
    "docs" : {
        "properties" : {
            “tags” : { "type" : "string", "index" : "not_analyzed" }
            “attachments” : { "type" : "string", "index" : "not_analyzed" }
        }
    }
}
}'

これらをファセットとして表示すると、次のようにタグが正常に表示されます。

[ ] - 何とかタグ 1

[ ] - 何とかタグ 2

ただし、添付ファイルはトークン化されており、単語ごとにファセットを取得します。

[ ] - いくつか

[ ] - ファイル

[ ] - 1

attachments プロパティは contactInformation 内にあるため、マッピングは次のようにする必要があるかもしれないと考えていました。

しかし、それはドットを予期せずにエラーをスローしました。

何か案は?

4

1 に答える 1

0

「複雑なコア フィールド タイプ」のドキュメントを参照してください(特に、「内部オブジェクトのマッピング」というタイトルのセクション)。

次のようになります。

"mappings" : {
  "docs" : {
    "properties" : {
      “tags” : { "type" : "string", "index" : "not_analyzed" },
      "contactInformation": {
        "type": "object",
        "properties": {
          “attachments” : { "type" : "string", "index" : "not_analyzed" }
        }
      }
    }
  }
}
于 2016-03-15T21:16:49.883 に答える