Elasticsearchに新しくgroupsと言うnestedのfieldを追加したいのですが、うまくいきません。
ruby
1mappings do 2 indexes :category, type: 'keyword' 3 indexes :article do 4 indexes :title, type: 'text', analyzer: 'kuromoji' 5 indexes :content, type: 'text', analyzer: 'kuromoji' 6 end 7 indexes :created_at, type: 'date' 8 indexes :updated_at, type: 'date' 9end
上記を以下のように変更しました。
ruby
1mappings do 2 indexes :category, type: 'keyword' 3 indexes :article do 4 indexes :title, type: 'text', analyzer: 'kuromoji' 5 indexes :content, type: 'text', analyzer: 'kuromoji' 6 end 7 indexes :groups, type: 'nested' do 8 indexes :id, type: 'long' 9 indexes :created_at, type: 'date' 10 end 11 indexes :created_at, type: 'date' 12 indexes :updated_at, type: 'date' 13end
importしなおすとデータ自体はうまく入っているようですが、searchがうまくいきません。
"type":"illegal_state_exception","reason":"[nested] nested object under path [groups] is not of nested type
上記のエラーが出ます。
試したこと
mappingを更新しようとしてみたところ以下のようなエラーになりました。
ruby
1__elasticsearch__.client.indices.put_mapping(index: index_name,type: document_type,body: mapping)
"type":"illegal_argument_exception","reason":"object mapping [groups] can't be changed from non-nested to nested"}],"type":"illegal_argument_exception","reason":"object mapping [groups] can't be changed from non-nested to nested"
これはimportする際にnestedのデータとしてimportできていないと言うことでしょうか?
またもう一つ試したこととして、indexをDELETE後、再作成するとsearchはうまくいきました。
しかし諸事情によりindexの削除はしたくありません。
どのようにすればうまくいく、もしくは何が原因かわかりますでしょうか?
それとも既存のindexに新たにnestedのfiledを追加することはできないのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。