Skip to content

Commit

Permalink
updating as per PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Rubin <[email protected]>
  • Loading branch information
AntonEliatra committed Aug 19, 2024
1 parent 3ba945c commit af3f162
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions _search-plugins/searching-data/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Feature | Description
[Paginate results]({{site.url}}{{site.baseurl}}/opensearch/search/paginate/) | Rather than a single, long list, separate search results into pages.
[Sort results]({{site.url}}{{site.baseurl}}/opensearch/search/sort/) | Allow sorting of results by different criteria.
[Highlight query matches]({{site.url}}{{site.baseurl}}/opensearch/search/highlight/) | Highlight the search term in the results.
[Retrieve specific fields]({{site.url}}{{site.baseurl}}search-plugins/searching-data/retrieve-specific-fields/) | Retrieve only the specific fields

Check failure on line 21 in _search-plugins/searching-data/index.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.LinksMidSlash] Add a slash after '{{site.url}}/{{site.baseurl}}' in '({{site.url}}{{site.baseurl}}search-plugins/searching-data/retrieve-specific-fields/)'. Raw Output: {"message": "[OpenSearch.LinksMidSlash] Add a slash after '{{site.url}}/{{site.baseurl}}' in '({{site.url}}{{site.baseurl}}search-plugins/searching-data/retrieve-specific-fields/)'.", "location": {"path": "_search-plugins/searching-data/index.md", "range": {"start": {"line": 21, "column": 27}}}, "severity": "ERROR"}
10 changes: 4 additions & 6 deletions _search-plugins/searching-data/retrieve-specific-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The `_source` can also be disabled in index mappings by using the following conf
}
```

If source is disabled in the index mappings, [searching with docvalue fields]({{site.url}}{{site.baseurl}}/search-plugins/searching-data/retrieve-specific-fields/#searching-with-docvalue_fields) and [searching with stored fields]({{site.url}}{{site.baseurl}}/search-plugins/searching-data/retrieve-specific-fields/#searching-with-stored_fields) become extremely useful.
If `_source` is disabled in the index mappings, [searching with docvalue fields]({{site.url}}{{site.baseurl}}/search-plugins/searching-data/retrieve-specific-fields/#searching-with-docvalue_fields) and [searching with stored fields]({{site.url}}{{site.baseurl}}/search-plugins/searching-data/retrieve-specific-fields/#searching-with-stored_fields) become extremely useful.

Check failure on line 64 in _search-plugins/searching-data/retrieve-specific-fields.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.Spelling] Error: docvalue. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks. Raw Output: {"message": "[OpenSearch.Spelling] Error: docvalue. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_search-plugins/searching-data/retrieve-specific-fields.md", "range": {"start": {"line": 64, "column": 65}}}, "severity": "ERROR"}

## Specifying the fields to retrieve

Expand Down Expand Up @@ -505,7 +505,7 @@ The `stored_fields` parameter can be disabled completely by setting `stored_fiel
<!-- vale on -->
In OpenSearch, if you want to retrieve `stored_fields` for nested objects, you cannot directly use the `stored_fields` parameter because no data will be returned. Instead, you should use the `inner_hits` parameter with its own `stored_fields` property, as shown in the following example.

1. Create index and mappings:
1. Create an index with the following mappings:

```json
PUT my_index
Expand Down Expand Up @@ -775,7 +775,7 @@ Consider a `products` index containing the following document:
}
```

You want to perform a search on this index but include only the `name`, `price`, `reviews`, and `supplier` fields in the response. Additionally, you want to exclude any `contact_email` fields from the `supplier` object and `comment` fields from the `reviews` object. To achieve this, run the following search:
To perform a search on this index while including only the `name`, `price`, `reviews`, and `supplier` fields in the response, and excluding the `contact_email` field from the `supplier` object and the `comment` field from the `reviews` object, execute the following search:

```json
GET /products/_search
Expand Down Expand Up @@ -834,9 +834,7 @@ The following is the expected response:

The `script_fields` parameter allows you to include custom fields whose values are computed using scripts in your search results. This can be useful for calculating values dynamically based on the document data. You can also retrieve `derived fields` by using a similar approach. For more information, see [Retrieving fields]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/derived/#retrieving-fields).

The following example demonstrates how to use the `script_fields` parameter.

Let's say you have an index of products, and each product document contains the fields `price` and `discount_percentage`. You want to include a custom field in the search results that shows the discounted price of each product.
If you have an index of products, where each product document contains the `price` and `discount_percentage` fields. You can use `script_fields` parameter to include a custom field in the search results that displays the discounted price of each product. The following example demonstrates how to use the `script_fields` parameter:


1. Index the data:
Expand Down

0 comments on commit af3f162

Please sign in to comment.