Migration of Items of any Catalog index
Step-by-step guide - How to convert an existing text file based search index configuration into the new export template based search index configuration.
Below example illustrates how to define an export template equivalent to old configuration in order to create a search index.
Old Index configuration for field ArticleLang.DescriptionShort
field.Article.ArticleLang.DescriptionShort.autocompletable=false
field.Article.ArticleLang.DescriptionShort.facetable=false
field.Article.ArticleLang.DescriptionShort.filterable=true
field.Article.ArticleLang.DescriptionShort.searchable=true
field.Article.ArticleLang.DescriptionShort.sortable=true
field.Article.ArticleLang.DescriptionShort.sourcefield=ArticleLang.DescriptionShort(eng)
field.Article.ArticleLang.DescriptionShort.returnfield=ArticleLang.DescriptionShort(eng)
field.Article.ArticleLang.DescriptionShort.stored=true
field.Article.ArticleLang.DescriptionShort.type=descriptionshort
New export template based configuration
Create a new template with purpose as Full-text Search
Take care of the points defined in Web Search Configuration
In the configuration of template, define following variables
catalog variable that can uniformly set the catalog for all the data sources
last modification date variable which would be responsible for providing delta changes from the data source.
language variable, used for qualification of logical keys of different entities which are language dependent.
Define 2 data sources for making sure all the data is picked up
Changed and new items :
Deleted items :
There will always be a module which writes it's output to config-file.json. This module defines the meta data about all the repository based entities and fields that are to be indexed (along with language qualification using the above defined variable) and contains all the other configurations specific to elasticsearch.
In the config module, define the required field as below:
{
"rootEntities": [
{
"identifier": "Article",
"fields": [],
"subEntities": [
{
"identifier": "ArticleLang",
"fields": [
{
"identifier": "DescriptionShort",
"dataType": "text",
"searchProperties": {
"searchable": true,
"sortable": false,
"facetable": false
},
"qualifications": [
"{%language}"
]
}
]
}
]
}
]
}The above step just acts as meta data for elastic and it does not do anything for the "data" part. For that user needs to define the data modules which generate data via export using the above defined data sources in advanced configuration of template.
Since there are 2 data sources available here, user will have to define 2 different modules to utilize both the data sources (New and changed items and Deleted items).
Users can use the new JSON methods available in the export templates when they define the data fields for exporting. This ensures the formatting required to index data and gives certain level of legibility.
Associate each of these modules and their sub-modules if any, with export file "data-file.json".
New and changed items module will be defined as follows :
Meta data that defines the operation and identifier for Elastic
{?JSONObject
{?JSONObjectElement "upsert",
{?JSONObject
{?JSONStringElement "_id",{?DatasetIdWithContainer}}
}
}
}
Then the actual data part that is required to indexed. It is important that there is a strict mapping between the fields defined here and in config. Fields Acl and Entity are the important ones, without which indexing will fail.
{?JSONObject
{?JSONStringElement "Acl",{?FormatDecimal {&Item.Object rights.Internal identifier},,}},
{?JSONStringElement "Entity","Article"},
{?JSONObjectElement "Article",
{?JSONObject
{?JSONArray
{?JSONObject
{?JSONStringElement "DescriptionShort",{&Item.Short description (English)}}
}
}
}
}
}
Deleted items module is defined as follows:
{?JSONObject
{?JSONObjectElement "delete",
{?JSONObject
{?JSONStringElement "_id",{?DatasetIdWithContainer}}
}
}
}
Now the user needs to create a new export profile :
Running an export job from here or scheduling it will create an index and upload the data to Elasticsearch server.
Handling sub-entities in sub-module
In case of sub-entities that can only be handled inside the sub-module of export template. First a field for the corresponding sub-entity with it's qualification(s) needs to be defined in the config module for elastic:
{
"rootEntities": [
{
"identifier": "Article",
"fields": [],
"subEntities": [
{
"identifier": "ArticleStructureMap",
"fields": [
{
"identifier": "ManualMap",
"dataType": "text",
"searchProperties": {
"searchable": true,
"sortable": true,
"facetable": true
},
"qualifications": [
"HeilerStandard"
]
}
]
}
]
}
]
}
The New and changed items module will now have following content to accommodate the sub-entity. Notice that ArticleStructureMap is a sub-module which is defined below :
{?JSONObject
{?JSONObjectElement "upsert",
{?JSONObject
{?JSONStringElement "_id",{?DatasetIdWithContainer}}
}
}
}
{?JSONObject
{?JSONStringElement "Acl",{?FormatDecimal {&Item.Object rights.Internal identifier},,}},
{?JSONStringElement "Entity","Article"},
{?JSONObjectElement "Article",
{?JSONObject
{?JSONObjectElement "ArticleStructureMap",{?JSONArray {$ArticleStructureMap}}}
}
}
}
ArticleStructureMap sub-module will have following content (Note that this sub-module is qualified with the qualification provided in the config file):
{?Compare {?LoopCounter}, 0 ,"", "," }{!
}{?JSONObject
{?JSONStringElement "ManualMap",{&Structure assignments.Structure groups.Name (English)}}
}
Take care that every sub-module is qualified as shown below as per the config file.