Skip to content

Commit 0f22449

Browse files
mveer99estolfo
authored andcommitted
Add nested mapping for ActiveRecord associations (#890)
1 parent 8c407be commit 0f22449

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: elasticsearch-model/examples/activerecord_associations.rb

+16
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@ module Searchable
9898

9999
module Indexing
100100

101+
#Index only the specified fields
102+
settings do
103+
mappings dynamic: false do
104+
indexes :categories, type: :object do
105+
indexes :title
106+
end
107+
indexes :authors, type: :object do
108+
indexes :full_name
109+
indexes :department
110+
end
111+
indexes :comments, type: :object do
112+
indexes :text
113+
end
114+
end
115+
end
116+
101117
# Customize the JSON serialization for Elasticsearch
102118
def as_indexed_json(options={})
103119
self.as_json(

0 commit comments

Comments
 (0)