From 4e9b35b147498df2aee096ad14ff68a036f8113e Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Wed, 10 Jul 2024 11:04:49 +0100 Subject: [PATCH 1/6] adding in a new page for filtering search results documentation Signed-off-by: leanne.laceybyrne@eliatra.com --- .../filtering-search-results.md | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 _search-plugins/searching-data/filtering-search-results.md diff --git a/_search-plugins/searching-data/filtering-search-results.md b/_search-plugins/searching-data/filtering-search-results.md new file mode 100644 index 0000000000..42628f818b --- /dev/null +++ b/_search-plugins/searching-data/filtering-search-results.md @@ -0,0 +1,131 @@ +--- +layout: default +title: Filter results +parent: Searching data +nav_order: 21 +redirect_from: + - /opensearch/search/filter/ +--- +# Filtering search results in OpenSearch + +Filtering the search results in OpenSearch allows you to refine the results returned. Specifying criteria to filter the indexes/documents by, allows you to refine the returned results. You can filter the results based on ranges, conditions or specific terms to refine the returned results. This is helpful when you have large datasets and allows you to interpret and understand larger datasets more easily. + +Filtering allows you to: +- Improve search accuracy by reducing unneeded information on a case by case basis to allow accurate interpretation of results. +- Enhance performance by reducing the amount of data necessary to process and return when querying. Improving query performance. +- Categorised search by allowing data to be returned in categories which allows you to explore the data in a structured manner. + +## Filtering with OpenSearch Dashboards + +To begin filtering in OpenSearch Dashboards, follow these steps: + +1. Navigate to the OpenSearch Dashboards UI. +2. Click on `Discover` in the sidebar. +3. Choose `opensearch_dashboards_sample_data_flights` from the index pattern selector. + +### Example: Filter by destination airport + +To filter flights arriving at "Zurich Airport": + +**Add a filter:** +- Click on the `Add filter` button. +- In the filter field, select `Dest`. +- In the operator field, select `is`. +- In the value field, type `Zurich Airport`. +- Click `Save`. + +This will display only the flights arriving at Zurich Airport. + +### Example: Filter by flight delay + +To filter flights that have been cancelled in the last 100 days: +- Click on the timeframe to update the time selection. +- Under the 'Relative' time tab. +- Change the unit to '1'. +- From the dropdown select 'Days ago'. +- The data shown is now from the Last 100 days. + +**Add a filter:** +- Click on the `Add filter` button. +- In the filter field, select `Cancelled`. +- In the operator field, select `is`. +- In the value field, type `true`. +- Click `Save`. + +This will display only the flights that have been cancelled with a destination of Zurich Airport in the last 100 days. + +## Using Query DSL for advanced filtering + +OpenSearch Query DSL (Domain Specific Language) allows for more complex and powerful queries. You can combine multiple conditions and use advanced logic to filter data. + +### Example of Query DSL filtering + +To use Query DSL, you need to define your queries in JSON format. + +To begin filtering via DSL in OpenSearch Dashboards, follow these steps: + +1. Navigate to the OpenSearch Dashboards UI. +2. Click on `Dev Tools` in the sidebar. +3. Write your DSL query in the dev tools left window. +4. Highlight the query and click the play button to run the query. +5. The answer is outputted in the right half of the dev tools window. + +### Example: Filter flights with delay greater than 60 minutes + +```json +GET opensearch_dashboards_sample_data_flights/_search +{ + "query": { + "range": { + "FlightDelayMin": { + "gt": 60 + } + } + } +} +``` + +This DSL query will retreive the instances where the flight delay is greater than 60 minutes. + +### Example: Combined filter with Query DSL + +To filter flights operated by "Logstash Airways", with an average ticket price (AvgTicketPrice) between 0 and 1000, and destination country (DestCountry) as Italy, you can use the following DSL query: + +```json +GET opensearch_dashboards_sample_data_flights/_search +{ + "query": { + "bool": { + "must": [ + { + "term": { + "Carrier": "Logstash Airways" + } + }, + { + "range": { + "AvgTicketPrice": { + "gte": 0, + "lte": 1000 + } + } + }, + { + "term": { + "DestCountry": "IT" + } + } + ] + } + } +} +``` + +This query uses a boolean must clause to combine three conditions: + +1. The carrier is Logstash Airways. +2. The average price ticket is between 0 and 1000 dollars. +3. The destination country is Italy. + +By following these steps, you can filter and examine large data sets with ease, based off the relevant queries and criteria for your investigations. + From b0fae42f766ed9b880bbb842c712fb0c0a9e2bf9 Mon Sep 17 00:00:00 2001 From: Melissa Vagi Date: Tue, 16 Jul 2024 15:57:50 -0600 Subject: [PATCH 2/6] Update _search-plugins/searching-data/filtering-search-results.md Signed-off-by: Melissa Vagi --- _search-plugins/searching-data/filtering-search-results.md | 1 - 1 file changed, 1 deletion(-) diff --git a/_search-plugins/searching-data/filtering-search-results.md b/_search-plugins/searching-data/filtering-search-results.md index 42628f818b..3cf286b33d 100644 --- a/_search-plugins/searching-data/filtering-search-results.md +++ b/_search-plugins/searching-data/filtering-search-results.md @@ -3,7 +3,6 @@ layout: default title: Filter results parent: Searching data nav_order: 21 -redirect_from: - /opensearch/search/filter/ --- # Filtering search results in OpenSearch From 22eada1407eefe6ed62551097183ade9924ed642 Mon Sep 17 00:00:00 2001 From: Melissa Vagi Date: Tue, 16 Jul 2024 15:58:07 -0600 Subject: [PATCH 3/6] Update _search-plugins/searching-data/filtering-search-results.md Signed-off-by: Melissa Vagi --- _search-plugins/searching-data/filtering-search-results.md | 1 - 1 file changed, 1 deletion(-) diff --git a/_search-plugins/searching-data/filtering-search-results.md b/_search-plugins/searching-data/filtering-search-results.md index 3cf286b33d..fd7873bc47 100644 --- a/_search-plugins/searching-data/filtering-search-results.md +++ b/_search-plugins/searching-data/filtering-search-results.md @@ -3,7 +3,6 @@ layout: default title: Filter results parent: Searching data nav_order: 21 - - /opensearch/search/filter/ --- # Filtering search results in OpenSearch From d2e0a3bcd7b40aeb64b7d45e7ca13bbc9c241815 Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Wed, 17 Jul 2024 16:33:17 +0100 Subject: [PATCH 4/6] addressing review comments Signed-off-by: leanne.laceybyrne@eliatra.com --- .../filtering-search-results.md | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) rename {_search-plugins/searching-data => _dashboards}/filtering-search-results.md (80%) diff --git a/_search-plugins/searching-data/filtering-search-results.md b/_dashboards/filtering-search-results.md similarity index 80% rename from _search-plugins/searching-data/filtering-search-results.md rename to _dashboards/filtering-search-results.md index fd7873bc47..07f5196c14 100644 --- a/_search-plugins/searching-data/filtering-search-results.md +++ b/_dashboards/filtering-search-results.md @@ -1,10 +1,14 @@ --- layout: default title: Filter results +<<<<<<< Updated upstream:_search-plugins/searching-data/filtering-search-results.md parent: Searching data nav_order: 21 +======= +nav_order: 139 +>>>>>>> Stashed changes:_dashboards/filtering-search-results.md --- -# Filtering search results in OpenSearch +# Filtering search results in OpenSearch Dashboards Filtering the search results in OpenSearch allows you to refine the results returned. Specifying criteria to filter the indexes/documents by, allows you to refine the returned results. You can filter the results based on ranges, conditions or specific terms to refine the returned results. This is helpful when you have large datasets and allows you to interpret and understand larger datasets more easily. @@ -37,7 +41,7 @@ This will display only the flights arriving at Zurich Airport. ### Example: Filter by flight delay To filter flights that have been cancelled in the last 100 days: -- Click on the timeframe to update the time selection. +- Click on the time frame to update the time selection. - Under the 'Relative' time tab. - Change the unit to '1'. - From the dropdown select 'Days ago'. @@ -54,19 +58,16 @@ This will display only the flights that have been cancelled with a destination o ## Using Query DSL for advanced filtering -OpenSearch Query DSL (Domain Specific Language) allows for more complex and powerful queries. You can combine multiple conditions and use advanced logic to filter data. +OpenSearch Query DSL (Domain Specific Language) allows for more complex and powerful queries. You can combine multiple conditions and use advanced logic to filter data. The DSL queries can be run in the Dev Tools, see the [Running queries in the Dev Tools console]()https://opensearch.org/docs/latest/dashboards/dev-tools/run-queries/], in the documentation for more information. Alternatively, DSL queries can also be run in the DSL query bar too. -### Example of Query DSL filtering -To use Query DSL, you need to define your queries in JSON format. +### Example of Query DSL filtering -To begin filtering via DSL in OpenSearch Dashboards, follow these steps: +DQL is a filtering language for OpenSearch Dashboards. There are 3 main ways to filter in OSD. -1. Navigate to the OpenSearch Dashboards UI. -2. Click on `Dev Tools` in the sidebar. -3. Write your DSL query in the dev tools left window. -4. Highlight the query and click the play button to run the query. -5. The answer is outputted in the right half of the dev tools window. +1. DQL or Lucene in the query bar +2. The Filter button which provides both a form to create a new filter and an advanced view to enter Query DSL directly +3. The time range picker ### Example: Filter flights with delay greater than 60 minutes From d66268899be568dc23d6e68fbd312e9e2c7e3fb7 Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Wed, 17 Jul 2024 17:42:07 +0100 Subject: [PATCH 5/6] removing merge conflicts. Signed-off-by: leanne.laceybyrne@eliatra.com --- _dashboards/filtering-search-results.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/_dashboards/filtering-search-results.md b/_dashboards/filtering-search-results.md index 07f5196c14..eb9ac004a7 100644 --- a/_dashboards/filtering-search-results.md +++ b/_dashboards/filtering-search-results.md @@ -1,12 +1,8 @@ --- layout: default title: Filter results -<<<<<<< Updated upstream:_search-plugins/searching-data/filtering-search-results.md parent: Searching data -nav_order: 21 -======= nav_order: 139 ->>>>>>> Stashed changes:_dashboards/filtering-search-results.md --- # Filtering search results in OpenSearch Dashboards From 3afdd35897f69f389afb41d34a02b73a1775f104 Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Wed, 17 Jul 2024 17:43:02 +0100 Subject: [PATCH 6/6] fixing link Signed-off-by: leanne.laceybyrne@eliatra.com --- _dashboards/filtering-search-results.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_dashboards/filtering-search-results.md b/_dashboards/filtering-search-results.md index eb9ac004a7..fd1e0e98ae 100644 --- a/_dashboards/filtering-search-results.md +++ b/_dashboards/filtering-search-results.md @@ -54,7 +54,7 @@ This will display only the flights that have been cancelled with a destination o ## Using Query DSL for advanced filtering -OpenSearch Query DSL (Domain Specific Language) allows for more complex and powerful queries. You can combine multiple conditions and use advanced logic to filter data. The DSL queries can be run in the Dev Tools, see the [Running queries in the Dev Tools console]()https://opensearch.org/docs/latest/dashboards/dev-tools/run-queries/], in the documentation for more information. Alternatively, DSL queries can also be run in the DSL query bar too. +OpenSearch Query DSL (Domain Specific Language) allows for more complex and powerful queries. You can combine multiple conditions and use advanced logic to filter data. The DSL queries can be run in the Dev Tools, see the [Running queries in the Dev Tools console](https://opensearch.org/docs/latest/dashboards/dev-tools/run-queries/), in the documentation for more information. Alternatively, DSL queries can also be run in the DSL query bar too. ### Example of Query DSL filtering