From 7d1d6a5f71d487cfe88310b6dbb0e727b938a9ae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:19:22 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- _episodes/09-opensearch-queires.md | 32 +++++++++++++++--------------- _episodes/10-text-based-search.md | 29 +++++---------------------- 2 files changed, 21 insertions(+), 40 deletions(-) diff --git a/_episodes/09-opensearch-queires.md b/_episodes/09-opensearch-queires.md index e21d30f..1efebc0 100644 --- a/_episodes/09-opensearch-queires.md +++ b/_episodes/09-opensearch-queires.md @@ -211,13 +211,13 @@ This lets you search for document by single field (i.e. by single metadata in ou Query structure looks like: ```JSON { - "query": {"term": {: }} + "query": {"term": {: }} } ``` ```python search_query = { - "query": {"term": {"collision_type": "pp"}} + "query": {"term": {"collision_type": "pp"}} } search_results = es.search(index=index_name, body=search_query) for hit in search_results["hits"]["hits"]: @@ -267,12 +267,12 @@ Lets get the docuemnts with `run_number` between 60 and 150 both inclusive. ```python search_query = { "query":{ - "range": { - "run_number": { - "gte": 60, - "lte": 150 - } - } + "range": { + "run_number": { + "gte": 60, + "lte": 150 + } + } } } @@ -291,10 +291,10 @@ for hit in search_results["hits"]["hits"]: > > "query": { > > "range": { > > "collision_energy": { -> > "gt": 100, -> > "lt": 200 -> > } -> > } +> > "gt": 100, +> > "lt": 200 +> > } +> > } > > } > > } > > search_results = es.search(index=index_name, body=search_query) @@ -329,11 +329,11 @@ Lets get the documents which collision_type has prefix "p". ```python search_query = { "query":{ - "prefix": { - "collision_type":{ + "prefix": { + "collision_type":{ "value": "p" - } - } + } + } } } search_results = es.search(index=index_name, body=search_query) diff --git a/_episodes/10-text-based-search.md b/_episodes/10-text-based-search.md index 8130391..bcba630 100644 --- a/_episodes/10-text-based-search.md +++ b/_episodes/10-text-based-search.md @@ -37,13 +37,7 @@ Structure of query is: ``` Lets search for document(s) with exact phrase "without beam background" in description field. ```python -search_query = { - "query": { - "match_phrase": { - "description": "without beam background" - } - } -} +search_query = {"query": {"match_phrase": {"description": "without beam background"}}} search_results = es.search(index=index_name, body=search_query) @@ -80,7 +74,7 @@ for hit in search_results["hits"]["hits"]: {: .challenge} ## Match query -The match query is a basic query type in opensearch used to search for documents containing specific words or phrases in a specified field, such as the description field. +The match query is a basic query type in opensearch used to search for documents containing specific words or phrases in a specified field, such as the description field. Structure of query is: ```JSON { @@ -93,13 +87,7 @@ Structure of query is: ``` Lets search for documents containing words "without" or "beam" in description field. Here it looks for docuement containing either of the words. ```python -search_query = { - "query": { - "match": { - "description": "without beam" - } - } -} +search_query = {"query": {"match": {"description": "without beam"}}} search_results = es.search(index=index_name, body=search_query) @@ -123,14 +111,7 @@ Example , to get the documents with word "beam" and "chrenkov" you will do. ```python search_query = { - "query": { - "match": { - "description": { - "query": "beam chrenkov", - "operator": "and" - } - } - } + "query": {"match": {"description": {"query": "beam chrenkov", "operator": "and"}}} } search_results = es.search(index=index_name, body=search_query) @@ -168,7 +149,7 @@ for hit in search_results["hits"]["hits"]: > {: .solution} {: .challenge} -# query_string +# query_string # Wild card Wildcard queries are used to search for documents based on patterns or partial matches within a field. In the example below, a wildcard query is used to search for documents where the description field contains any L trigger ie. L1/L2.