Skip to content

Commit dd4dc78

Browse files
committed
Fixed elasticsearch nested object count limit error
1 parent 4ff9287 commit dd4dc78

File tree

3 files changed

+97
-88
lines changed

3 files changed

+97
-88
lines changed

airone/lib/elasticsearch.py

+95-88
Original file line numberDiff line numberDiff line change
@@ -58,103 +58,110 @@ def recreate_index(self) -> None:
5858
self.indices.create(
5959
index=self._index,
6060
ignore=400,
61-
body={
62-
"mappings": {
63-
"properties": {
64-
"name": {
65-
"type": "text",
66-
"index": "true",
67-
"analyzer": "keyword",
68-
"fields": {
69-
"keyword": {"type": "keyword"},
70-
},
61+
settings={
62+
"index": {
63+
"mapping": {
64+
"nested_objects": {
65+
"limit": settings.ES_CONFIG["MAXIMUM_NESTED_OBJECT_NUM"],
66+
}
67+
}
68+
}
69+
},
70+
mappings={
71+
"properties": {
72+
"name": {
73+
"type": "text",
74+
"index": "true",
75+
"analyzer": "keyword",
76+
"fields": {
77+
"keyword": {"type": "keyword"},
7178
},
72-
"referrals": {
73-
"type": "nested",
74-
"properties": {
75-
"id": {
76-
"type": "integer",
77-
"index": "true",
78-
},
79-
"name": {
80-
"type": "text",
81-
"index": "true",
82-
"analyzer": "keyword",
83-
},
84-
"schema": {
85-
"type": "nested",
86-
"properties": {
87-
"id": {
88-
"type": "integer",
89-
"index": "true",
90-
},
91-
"name": {
92-
"type": "text",
93-
"index": "true",
94-
"analyzer": "keyword",
95-
},
79+
},
80+
"referrals": {
81+
"type": "nested",
82+
"properties": {
83+
"id": {
84+
"type": "integer",
85+
"index": "true",
86+
},
87+
"name": {
88+
"type": "text",
89+
"index": "true",
90+
"analyzer": "keyword",
91+
},
92+
"schema": {
93+
"type": "nested",
94+
"properties": {
95+
"id": {
96+
"type": "integer",
97+
"index": "true",
98+
},
99+
"name": {
100+
"type": "text",
101+
"index": "true",
102+
"analyzer": "keyword",
96103
},
97104
},
98105
},
99106
},
100-
"entity": {
101-
"type": "nested",
102-
"properties": {
103-
"id": {
104-
"type": "integer",
105-
"index": "true",
106-
},
107-
"name": {
108-
"type": "text",
109-
"index": "true",
110-
"analyzer": "keyword",
111-
},
107+
},
108+
"entity": {
109+
"type": "nested",
110+
"properties": {
111+
"id": {
112+
"type": "integer",
113+
"index": "true",
112114
},
113-
},
114-
"attr": {
115-
"type": "nested",
116-
"properties": {
117-
"name": {
118-
"type": "text",
119-
"index": "true",
120-
"analyzer": "keyword",
121-
},
122-
"type": {
123-
"type": "integer",
124-
"index": "false",
125-
},
126-
"id": {
127-
"type": "integer",
128-
"index": "false",
129-
},
130-
"key": {
131-
"type": "text",
132-
"index": "true",
133-
},
134-
"date_value": {
135-
"type": "date",
136-
"index": "true",
137-
},
138-
"value": {
139-
"type": "text",
140-
"index": "true",
141-
"analyzer": "keyword",
142-
},
143-
"referral_id": {
144-
"type": "integer",
145-
"index": "false",
146-
},
147-
"is_readble": {
148-
"type": "boolean",
149-
"index": "true",
150-
},
115+
"name": {
116+
"type": "text",
117+
"index": "true",
118+
"analyzer": "keyword",
151119
},
152120
},
153-
"is_readble": {
154-
"type": "boolean",
155-
"index": "true",
121+
},
122+
"attr": {
123+
"type": "nested",
124+
"properties": {
125+
"name": {
126+
"type": "text",
127+
"index": "true",
128+
"analyzer": "keyword",
129+
},
130+
"type": {
131+
"type": "integer",
132+
"index": "false",
133+
},
134+
"id": {
135+
"type": "integer",
136+
"index": "false",
137+
},
138+
"key": {
139+
"type": "text",
140+
"index": "true",
141+
},
142+
"date_value": {
143+
"type": "date",
144+
"index": "true",
145+
},
146+
"value": {
147+
"type": "text",
148+
"index": "true",
149+
"analyzer": "keyword",
150+
},
151+
"referral_id": {
152+
"type": "integer",
153+
"index": "false",
154+
},
155+
"is_readble": {
156+
"type": "boolean",
157+
"index": "true",
158+
},
156159
},
157-
}
160+
},
161+
"is_readble": {
162+
"type": "boolean",
163+
"index": "true",
164+
},
158165
}
159166
},
160167
)

airone/lib/test.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"NODES": settings.ES_CONFIG["NODES"],
2020
"INDEX": "test-airone",
2121
"MAXIMUM_RESULTS_NUM": 10000,
22+
"MAXIMUM_NESTED_OBJECT_NUM": 999999,
2223
"TIMEOUT": 300,
2324
}
2425
)

airone/settings_common.py

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class Common(Configuration):
235235
"NODES": ["localhost:9200"],
236236
"INDEX": "airone",
237237
"MAXIMUM_RESULTS_NUM": 500000,
238+
"MAXIMUM_NESTED_OBJECT_NUM": 999999,
238239
"TIMEOUT": None,
239240
}
240241

0 commit comments

Comments
 (0)