Overriding Query search profiles to modify the response fields
In this topic, you will learn how to override query search profiles to modify the response fields.
Procedure
Override query search profiles to modify the response fields.
You can override default search profiles by creating a custom profile using the same name as the default profile. If a custom profile with the same name as a default profile is available, the custom profile is used and the default profile is ignored. For detailed steps on overriding search profiles, see Setting up your custom search profile.
- Override the default search query profile to include the additional seller_description.raw attribute in the query response.
- Extend the default HCL_findCatalogEntrySKUs search
profile by adding seller_description.raw into the
responseFields section of the existing search
profile.
GET http://QUERY_HOST:30920/search/resources/api/v2/documents/profiles/HCL_findCatalogEntrySKUs
- Execute the GET call to retrieve the default query profile, and execute
the PUT call to create the custom query profile using the response of
the GET call as a request Body after adding the
seller.description.raw attribute in JSON. This
would extend the default query profile as
follows:
GET http://GET http://<QUERY_HOST>:<QUERY_PORT>/search/resources/api/v2/documents/profiles/HCL_findCatalogEntrySKUs :<QUERY_PORT>/search/resources/api/v2/documents/profiles/HCL_findCatalogEntrySKUs
For example:GET http://QUERY_HOST:30920/search/resources/api/v2/documents/profiles/HCL_findCatalogEntrySKUs PUT http://QUERY_HOST:30920/search/resources/api/v2/documents/profiles/HCL_findCatalogEntrySKUs [ { "profileName": "HCL_findCatalogEntrySKUs", "indexName": "product", "query": { "params": [ { "maxRows": "1200" } ], "queryFields": [ "relationship.product.id" ], "provider": [ "com.hcl.commerce.search.internal.expression.provider.SearchInventoryExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchByPublishedEntryOnlyExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchByStorePathExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchBySellerExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchByCatalogExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchByLanguageExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchProductEntitlementExpressionProvider" ], "preprocessor": [], "postprocessor": [ "com.hcl.commerce.search.internal.expression.postprocessor.SearchMainCatalogEntryViewResultQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewPriceQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewUserDataQueryPostprocessor" ], "responseFields": [ "id.catentry", "id.store", "buyable", "id.catalog", "identifier.sku.raw", "name.raw", "name.override.raw", "description.raw", "description.override.raw", "url.thumbnail", "url.override.thumbnail", "url.image", "url.override.image", "keyword.text", "manufacturer.raw", "id.member", "seller.raw", "seller_description.raw", "type", "prices.*", "path.*", "relationship.product.id", "relationship.item.id", "attribute.source", "url.seo", "url.override.seo", "attachments.*", "images.*", "description.long" ] } } ]
-
The response should be similar to:
{ "Profile created with name": "HCL_findCatalogEntrySKUs" }
- Repeat this step for
theHCL_V2_findProductByPartNumber_Details
search profile by adding seller_description.raw
into the responseFields section of the existing
search
profile.
GET http://QUERY_HOST:QUERY_PORT/search/resources/api/v2/documents/profiles/HCL_V2_findProductByPartNumber_Details
- Add seller_description.raw into the
responseFields section of the existing search
profile to use it as a request body for the below PUT
call to override the default
HCL_V2_findProductByPartNumber_Details search
profile.
PUT http://QUERY_HOST:30920/search/resources/api/v2/documents/profiles/HCL_V2_findProductByPartNumber_Details
{ "profileName": "HCL_V2_findProductByPartNumber_Details", "indexName": "product", "query": { "params": [ { "DynamicKitReturnPrice": "true" }, { "maxRows": "50" } ], "queryFields": [ "identifier.sku.normalized" ], "provider": [ "com.hcl.commerce.search.internal.expression.provider.SearchByCatalogExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchByStorePathExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchBySellerExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchByLanguageExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchInventoryExpressionProvider", "com.hcl.commerce.search.internal.expression.provider.SearchProductEntitlementExpressionProvider" ], "preprocessor": [], "postprocessor": [ "com.hcl.commerce.search.internal.expression.postprocessor.SearchMainCatalogEntryViewResultQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewPriceQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewSKUQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewAttributesQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewAttachmentsQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewImagesQueryPostProcessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewComponentsQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewMerchandisingAssocQueryPostprocessor", "com.hcl.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewUserDataQueryPostprocessor" ], "responseFields": [ "id.catentry", "id.store", "id.catalog", "buyable", "identifier.sku.raw", "name.raw", "name.override.raw", "description.raw", "description.override.raw", "url.thumbnail", "url.override.thumbnail", "keyword.text", "manufacturer.raw", "id.member", "seller.raw", "seller_description.raw", "type", "prices.*", "path.*", "relationship.item.*", "relationship.product.id", "relationship.component.*", "subscription.type", "subscription.recurring", "url.image", "url.override.image", "description.long", "attribute.source", "kit.components", "kit.preconfigured", "kit.model", "kit.URL", "kit.default_configuration", "kit.pdks", "kit.parent.model", "kit.configurable", "kit.parent.configurable", "associations.*", "url.seo", "attachments.*", "images.*" ] } }
The response should resemble:{ "Profile created with name": "HCL_V2_findProductByPartNumber_Details" }
- Restart the Query Service container.
Test the customization to verify that the customization is successful.
In this topic, you have covered how to modify the response fields by overriding query search profiles .