All Products
Search
Document Center

OpenSearch:Default display fields

Last Updated:Nov 07, 2024

You can set default display fields to specify the fields in the application schema that need to be retrieved and returned by default for each search request.

Set the fields to return in the OpenSearch console

1. Log on to the OpenSearch console. In the left-side navigation pane, click OpenSearch Industry Algorithm Edition and select OpenSearch High-performance Search Edition, and then choose Feature Extensions > Search Result Display. On the Search Result Display page, select an application for which you want to set default display fields from the drop-down list, and add default display fields in the Default Display Fields section.

image

2. If you do not specify default display fields on the Search Result Display page, you can use the fetch_fields parameter to specify the fields to return when you run a search test for an application in the OpenSearch console, as shown in the following figure.

Note: Separate the fields specified in the fetch_fields parameter with semicolons (;).image

Set the fields to return by using the API or SDK

fetch_fields: The size of text data to return has a great impact on search performance. We recommend that you specify only the required fields to return. If you set the fetch_fields parameter by using the API or SDK, the corresponding configuration in the OpenSearch console is overwritten.

  • API: Use the fetch_fields parameter to specify the fields to return. For more information, see Initiate search requests.

  • SDK: The following sample code shows how to specify the fields to return by using the SDK for Java.

// Specify the fields in the application that need to be returned in the search results.
config.setFetchFields(Lists.newArrayList("id","name","phone","int_arr","literal_arr","float_arr","cate_id"));

Usage notes

  • If you do not set the fetch_fields parameter by using the API or SDK, the default display fields that you configure in the OpenSearch console are returned in the search results. If you set the fetch_fields parameter by using the API or SDK, the fields that are specified by the fetch_fields parameter are returned in the search results.