You can create, modify, view, and delete index attribute configuration remotely, using the Index Attributes API.
This section describes how to create and configure index attributes using the Index Attributes API.
The JSON configuration of index attributes is stored in the collection folder /config/import/attributes, which is located in your application's installation directory.
Typically, a
/config/import/attributes
folder and a
/system
subfolder are created when a Guided Search
application is initialized. If the
/attributes
folder does not exist on your system, you
must create it before you can create index attributes.
To create the attributes folder, use the following endpoint on the Guided Search server:
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes
Use the following request body with the POST request above to create the attributes folder without content:
{ "ecr:type": "attributes-folder" }
The endpoint above can also create owners in the attributes folder when it creates the folder. To do this, provide a request body such as the following, which creates two different owners, "ownerOne" and "MEDIA":
{ "ecr:type":"attributes-folder", "ownerOne":{ "ecr:type":"attributes-owner-folder", "camera.35_mm_camera_lens_equivalent":{ "propertyDataType":"ALPHA", "sourcePropertyNames":[ "camera.35 mm camera lens equivalent" ], "ecr:type":"property" }, "camera.color":{ "isWildcardEnabledInRecordSearch":true, "displayOrder":4, "sourcePropertyNames":[ "camera.Colour of product" ], "isAutogen":true, "isRecordSearchEnabled":true, "ecr:type":"dimension" }, "product.max_price":{ "derivedPropertySource":"product.price", "derivedPropertyFunction":"MAX", "ecr:type":"derived-property" } }, "MEDIA":{ "ecr:type":"attributes-owner-folder", "camera.35_mm_camera_lens_equivalent":{ "propertyDataType":"ALPHA", "sourcePropertyNames":[ "camera.35 mm camera lens equivalent" ], "ecr:type":"property" }, "camera.color":{ "isWildcardEnabledInRecordSearch":true, "displayOrder":5, "sourcePropertyNames":[ "camera.Colour of product" ], "isAutogen":true, "isRecordSearchEnabled":true, "ecr:type":"dimension" }, "product.min_price":{ "derivedPropertySource":"product.price", "derivedPropertyFunction":"MIN", "ecr:type":"derived-property" } } } }
If the
/system
folder was not configured when your Guided
Search application was initialized, you must configure it before you create
configuration for individual owners, as follows:
{ "ecr-type": "attributes-owner-folder", "common.record_type" : { "displayOrder" : 18, "jcr:primaryType" : "endeca:dimension" }, "common.id" : { "propertyDataType" : "ALPHA", "jcr:primaryType" : "endeca:property", "isRecordFilterable" : true } }
Note
The default version of
/system
used by the Discover reference application
provided with Guided Search contains the index attribute configuration used by
Discover. To configure your own Guided Search application, replace the default
contents of
/system
with the content shown in the example
immediately above. Then create the index attribute configuration used by your
application under a separate owner or owners that you create.
To create a folder for a particular owner, use an endpoint of the following form:
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/{owner}
For example, the following endpoint to create a folder for an owner named "ownerOne":
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/ownerOne
Use the following input for any endpoint that creates an empty folder for the specified owner:
{ "ecr:type": "attributes-owner-folder" }
To create the owner’s folder with content (index attributes), use a request body such as the following, which creates the attributes “camera.35_mm_camera_lens_equivalent”, “camera.color”, and “product.max_price”:
{ "ecr:type": "attributes-owner-folder", "camera.35_mm_camera_lens_equivalent": { "propertyDataType": "ALPHA", "sourcePropertyNames": [ "camera.35 mm camera lens equivalent" ], "ecr:type": "property" }, "camera.color": { "isWildcardEnabledInRecordSearch": true, "displayOrder": 4, "sourcePropertyNames": ["camera.Colour of product"], "isAutogen": true, "isRecordSearchEnabled": true, "ecr:type": "dimension" }, "product.max_price": { "derivedPropertySource": "product.price", "derivedPropertyFunction": "MAX", "ecr:type": "derived-property" } }
Note
The "ecr:type" value for an owner's folder, with or without content, must be "attributes-owner-folder".
To create a dimension attribute for an existing owner, use an endpoint of the following form:
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/{owner}/{dimension_attribute_name}
For example, the following endpoint creates a dimension attribute named "camera_color" for the owner "ownerOne":
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/ownerOne/camera_color
The following request body creates the dimension "camera_color" for the owner "ownerOne":
{ "isWildcardEnabledInRecordSearch": true, "displayOrder": 4, "sourcePropertyNames": [ "camera.color of product" ], "isAutogen": true, "isRecordSearchEnabled": true, "ecr:type": "dimension" }
To create a property for an existing owner, use an endpoint of the following form:
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/{owner}/{property_name}
For example, the following endpoint creates a property named camera_pixels:
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/ownerOne/camera_pixels
Note: If neither the "attributes" folder nor the owner exists, use the POST command with the above URL.
The following request body creates the property "camera_pixels":
{ "propertyDataType": "INTEGER", "sourcePropertyNames": [ "camera.pixels" ], "ecr:type": "property" }
To create a derived property for an existing owner, use an endpoint of the following form:
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/{owner}/{derived_property}
Note: If neither the "attributes" folder nor the owner exists, use the POST command with the above URL.
For example, the following endpoint creates a derived property named "min_price":
POST
http://host:port/ifcr/gsadmin/v1/Discover/attributes/ownerOne/min_price
The following JSON property definition can be input to the above endpoint to create the derived property "min_price":
{ "derivedPropertySource": "product.price", "derivedPropertyFunction": "MIN", "ecr:type": "derived-property" }
You can modify existing configuration or replace it altogether.
To modify the index attributes of a specified owner, use an endpoint of the following form:
PATCH
http://host:port/ifcr/gsadmin/v1/Discover/attributes/{owner}
For example, the following endpoint modifies the configuration belonging to the owner "sourceone":
PATCH
http://host:port/ifcr/gsadmin/v1/Discover/attributes/sourceone
For example, use the following request body to change the displayOrder value of the attribute "camera.color" from any other value to 9:
{ "ecr:type": "attributes-owner-folder", "camera.color": { "isWildcardEnabledInRecordSearch": true, "displayOrder": 9, "sourcePropertyNames": [ "camera.Colour of product" ], "isAutogen": true, "isRecordSearchEnabled": true, "ecr:type": "dimension" } }
To replace the index attributes of a specific owner, use an endpoint of the following form:
PUT
http://host:port/ifcr/gsadmin/v1/Discover/attributes/{owner}
For example, the following endpoint replaces the attributes of the "sourceone" owner:
PUT
http://host:port/ifcr/gsadmin/v1/Discover/attributes/sourceone
Suppose that a single property attribute, "camera.35_mm_camera_lens_equivalent", is configured for the owner sourceone:
{ "ecr:type": "attributes-owner-folder", "camera.35_mm_camera_lens_equivalent": { "ecr:lastModifiedBy": "admin", "propertyDataType": "ALPHA", "sourcePropertyNames": [ "camera.35 mm camera lens equivalent" ], "ecr:type": "property" } }
The following request body updates the configuration belonging to the owner “sourceone” by adding two attributes, “camera.color” and product.max_price“”:
{ "ecr:lastModifiedBy": "admin", "ecr:lastModified": "2016-05-26T14:00:09.764Z", "ecr:createDate": "2016-05-23T11:49:58.144-04:00", "ecr:type": "attributes-owner-folder", "camera.35_mm_camera_lens_equivalent": { "ecr:lastModifiedBy": "admin", "propertyDataType": "ALPHA", "ecr:lastModified": "2016-05-26T09:09:04.248-04:00", "sourcePropertyNames": [ "camera.35 mm camera lens equivalent" ], "ecr:createDate": "2016-05-26T09:09:04.248-04:00", "ecr:type": "property" }, "camera.color": { "isWildcardEnabledInRecordSearch": true, "ecr:lastModifiedBy": "admin", "ecr:lastModified": "2016-05-26T09:09:04.248-04:00", "displayOrder": 9, "sourcePropertyNames": [ "camera.Colour of product" ], "isAutogen": true, "ecr:createDate": "2016-05-26T09:09:04.248-04:00", "isRecordSearchEnabled": true, "ecr:type": "dimension" }, "product.max_price": { "derivedPropertySource": "product.price", "ecr:lastModifiedBy": "admin", "ecr:lastModified": "2016-05-26T09:09:04.248-04:00", "derivedPropertyFunction": "MAX", "ecr:createDate": "2016-05-26T09:09:04.248-04:00", "ecr:type": "derived-property" } }
You can use different endpoints with the GET command to export the following resources from the ECR for viewing:
View a list of all attribute owners
To view a list of the owners of attributes, use the following endpoint:
GET
http://host:port/ifcr/gsadmin/v1/Discover/attributes
The following JSON illustrates a possible response returned by the endpoint above when two owners, "sourceone" and "MEDIA", exist:
{ "ecr:lastModifiedBy": "admin", "ecr:lastModified": "2016-05-23T15:49:58.134Z", "ecr:createDate": "2016-05-23T11:06:48.229-04:00", "ecr:type": "attributes-folder", "sourceone": { "ecr:lastModifiedBy": "admin", "ecr:lastModified": "2016-05-26T13:09:22.663Z", "ecr:createDate": "2016-05-23T11:49:58.144-04:00", "ecr:type": "attributes-owner-folder" }, "MEDIA": { "ecr:lastModifiedBy": "admin", "ecr:lastModified": "2016-05-23T11:49:58.146-04:00", "ecr:createDate": "2016-05-23T11:49:58.146-04:00", "ecr:type": "attributes-owner-folder" } }
Note
Lists of owners do not include the attributes belonging to the owners.
To view the attributes belonging to a specified owner, use an endpoint of the following form:
GET
https://localhost:port/ifcr/gsadmin/v1/Discover/attributes/{owner}
For example, the following endpoint gets the attibutes belonging to the owner "sourceone":
GET
https://localhost:port/ifcr/gsadmin/v1/Discover/attributes/
sourceone
This endpoint can return a response such as the following for the owner "sourceone":
{ "ecr:lastModifiedBy": "admin", "ecr:lastModified": "2016-04-14T17:43:34.236-04:00", "ecr:createDate": "2016-04-14T17:43:34.236-04:00", "ecr:type": "attributes-owner-folder", "camera.35_mm_camera_lens_equivalent": { "ecr:lastModifiedBy": "admin", "propertyDataType": "ALPHA", "ecr:lastModified": "2016-04-14T17:43:34.236-04:00", "sourcePropertyNames": [ "camera.35 mm camera lens equivalent" ], "ecr:createDate": "2016-04-14T17:43:34.236-04:00", "ecr:type": "property" }, "camera.aperture_range": { "ecr:lastModifiedBy": "admin", "propertyDataType": "ALPHA", "ecr:lastModified": "2016-04-14T17:43:34.245-04:00", "sourcePropertyNames": [ "camera.Aperture range" ], "ecr:createDate": "2016-04-14T17:43:34.245-04:00", "ecr:type": "property" } }
To view a specified attribute belonging to a specified owner, use an endpoint of the following form:
GET
http://host:port/ifcr/gsadmin/v1/Discover/attributes/{owner}/{attribute}
For example, the following endpoint returns the attribute "camera.35_mm_camera_lens_equivalent", which belongs to the owner "sourceone":
GET
http://host:port/ifcr/gsadmin/v1/Discover/attributes/sourceone/camera.35_mm_camera_lens_equivalent
This endpoint can return a response such as the following:
{ "ecr:lastModifiedBy": "admin", "propertyDataType": "ALPHA", "ecr:lastModified": "2016-04-14T17:43:34.236-04:00", "sourcePropertyNames": [ "camera.35 mm camera lens equivalent" ], "ecr:createDate": "2016-04-14T17:43:34.236-04:00", "ecr:type": "property" }