Skip to content

Commit 667325d

Browse files
committed
Linting
1 parent caf6a57 commit 667325d

File tree

1 file changed

+38
-42
lines changed

1 file changed

+38
-42
lines changed

notebooks/enterprise-search/app-search-engine-exporter.ipynb

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -187,36 +187,36 @@
187187
"query_rules = []\n",
188188
"\n",
189189
"for curation in app_search.list_curations(engine_name=ENGINE_NAME).body[\"results\"]:\n",
190-
" if (curation[\"promoted\"]):\n",
191-
" query_rules.append(\n",
192-
" {\n",
193-
" \"rule_id\": curation[\"id\"] + \"-pinned\",\n",
194-
" \"type\": \"pinned\",\n",
195-
" \"criteria\": [\n",
196-
" {\n",
197-
" \"type\": \"exact\",\n",
198-
" \"metadata\": \"user_query\",\n",
199-
" \"values\": curation[\"queries\"],\n",
200-
" }\n",
201-
" ],\n",
202-
" \"actions\": {\"ids\": curation[\"promoted\"]},\n",
203-
" }\n",
204-
" )\n",
205-
" if(curation[\"hidden\"]):\n",
206-
" query_rules.append(\n",
207-
" {\n",
208-
" \"rule_id\": curation[\"id\"] + \"-exclude\",\n",
209-
" \"type\": \"exclude\",\n",
210-
" \"criteria\": [\n",
211-
" {\n",
212-
" \"type\": \"exact\",\n",
213-
" \"metadata\": \"user_query\",\n",
214-
" \"values\": curation[\"queries\"],\n",
215-
" }\n",
216-
" ],\n",
217-
" \"actions\": {\"ids\": curation[\"hidden\"]},\n",
218-
" }\n",
219-
" )\n",
190+
" if curation[\"promoted\"]:\n",
191+
" query_rules.append(\n",
192+
" {\n",
193+
" \"rule_id\": curation[\"id\"] + \"-pinned\",\n",
194+
" \"type\": \"pinned\",\n",
195+
" \"criteria\": [\n",
196+
" {\n",
197+
" \"type\": \"exact\",\n",
198+
" \"metadata\": \"user_query\",\n",
199+
" \"values\": curation[\"queries\"],\n",
200+
" }\n",
201+
" ],\n",
202+
" \"actions\": {\"ids\": curation[\"promoted\"]},\n",
203+
" }\n",
204+
" )\n",
205+
" if curation[\"hidden\"]:\n",
206+
" query_rules.append(\n",
207+
" {\n",
208+
" \"rule_id\": curation[\"id\"] + \"-exclude\",\n",
209+
" \"type\": \"exclude\",\n",
210+
" \"criteria\": [\n",
211+
" {\n",
212+
" \"type\": \"exact\",\n",
213+
" \"metadata\": \"user_query\",\n",
214+
" \"values\": curation[\"queries\"],\n",
215+
" }\n",
216+
" ],\n",
217+
" \"actions\": {\"ids\": curation[\"hidden\"]},\n",
218+
" }\n",
219+
" )\n",
220220
"\n",
221221
"elasticsearch.query_rules.put_ruleset(ruleset_id=ENGINE_NAME, rules=query_rules)"
222222
]
@@ -234,7 +234,11 @@
234234
"metadata": {},
235235
"outputs": [],
236236
"source": [
237-
"print(json.dumps(elasticsearch.query_rules.get_ruleset(ruleset_id=ENGINE_NAME).body, indent=2))"
237+
"print(\n",
238+
" json.dumps(\n",
239+
" elasticsearch.query_rules.get_ruleset(ruleset_id=ENGINE_NAME).body, indent=2\n",
240+
" )\n",
241+
")"
238242
]
239243
},
240244
{
@@ -649,9 +653,7 @@
649653
"# add the semantic_text field to our mapping for each field defined\n",
650654
"for field_name in SEMANTIC_TEXT_FIELDS:\n",
651655
" semantic_field_name = field_name + \"_semantic\"\n",
652-
" mapping[semantic_field_name] = {\n",
653-
" \"type\": \"semantic_text\"\n",
654-
" }\n",
656+
" mapping[semantic_field_name] = {\"type\": \"semantic_text\"}\n",
655657
"\n",
656658
"# and for our text fields, add a \"copy_to\" directive to copy the text to the semantic_text field\n",
657659
"for field_name in SEMANTIC_TEXT_FIELDS:\n",
@@ -838,7 +840,7 @@
838840
" \"order\": \"score\",\n",
839841
" \"encoder\": \"html\",\n",
840842
" \"require_field_match\": False,\n",
841-
" \"fields\": { \"description\" : { \"pre_tags\" : [\"<em>\"], \"post_tags\" : [\"</em>\"] } },\n",
843+
" \"fields\": {\"description\": {\"pre_tags\": [\"<em>\"], \"post_tags\": [\"</em>\"]}},\n",
842844
" },\n",
843845
" \"size\": 10,\n",
844846
" \"_source\": result_fields,\n",
@@ -895,13 +897,7 @@
895897
"\n",
896898
"for field_name in SEMANTIC_TEXT_FIELDS:\n",
897899
" semantic_field_name = field_name + \"_semantic\"\n",
898-
" semantic_text_queries.append(\n",
899-
" {\n",
900-
" \"match\": {\n",
901-
" semantic_field_name: QUERY_STRING\n",
902-
" }\n",
903-
" }\n",
904-
" )\n",
900+
" semantic_text_queries.append({\"match\": {semantic_field_name: QUERY_STRING}})\n",
905901
"\n",
906902
"semantic_query = {\"bool\": {\"should\": semantic_text_queries}}\n",
907903
"print(f\"Elasticsearch query:\\n{json.dumps(semantic_query, indent=2)}\\n\")"

0 commit comments

Comments
 (0)