Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 29, 2024
1 parent b0ac988 commit 7d1d6a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 40 deletions.
32 changes: 16 additions & 16 deletions _episodes/09-opensearch-queires.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {<field>: <value>}}
"query": {"term": {<field>: <value>}}
}
```

```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"]:
Expand Down Expand Up @@ -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
}
}
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 5 additions & 24 deletions _episodes/10-text-based-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
{
Expand All @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 7d1d6a5

Please sign in to comment.