Index Update
POST/qlibs/:qlibid/q/:qhit/call/search_update
Update a index object via processing the data. Make a bitcode call to search_update on content that is open for update (write_token)
Before Creating an Index Object
An index object is an object that needs two things :
- A reference to a content type having the builtin capabilities (creating simple content type with metadata {"bitcode_format":"builtin"} will suffice).
- Metadata having a particular field and format (which is used to configure the indexer and search engine). That metadata should contain the field .indexer.config and the format of that field should follow the following rules :
-
fabric.root.library and fabric.root.content should correspond to the library ID and content ID of the root metadata to index.
-
indexer.type should be equal to "metadata-text"
-
indexer.arguments.fields will contain all the fields that are searchable.
-
A searchable field inside indexer.arguments.fields should have the following format :
"searchable_field_name": { "options": null, "paths": [ "path_0", "path_1", "...", "path_N" ]}
-
searchable_field_name can be any string, this name will be used when querying the index for that particular field (cf. below).
-
path_i correspond to all the metadata paths of leaf fields to index under the name <searchable_field_name>.
"synopsis": \{ "options": null, "paths": [ "public.asset_metadata.titles.*.*.info.synopsis", "public.asset_metadata.series.*.*.info.synopsis", "public.asset_metadata.series.*.*.seasons.*.*.synopsis", ] \} -
will index all the fields it can find corresponding to one of the paths and index them under the name synopsis. When doing a search, it will be possible to query a synopsis using a query string like this f_synopsis:=keyword (cf. below).
-
Paths can have a wildcard *, meaning that any key name will be indexed.
-
Paths are namespaces in the sense that arrays are ignored. For example : Metadata A.B and A[0].B will both be captured by path A.B.
Here is an example of a proper metadata for the Index Object :
json
{
"public": {
"name": "Index - Site Roar"
},
"indexer": {
"config": {
"fabric": {
"root": {
"library": "ilib2XX6yS9S8bgAeLVxDGKeoNcNVckN",
"content": "iq__cWJC7xQ9v3rXPYMiyhRF27Bf1rj"
}
},
"indexer": {
"type": "metadata-text",
"arguments": {
"fields": {
"title": {
"options": null,
"paths": [
"public.asset_metadata.titles.*.*.display_title",
"public.asset_metadata.titles.*.*.title",
"public.asset_metadata.titles.*.*.seasons.*.*.display_title",
"public.asset_metadata.titles.*.*.seasons.*.*.title",
"public.asset_metadata.titles.*.*.seasons.*.*.titles.*.*.display_title",
"public.asset_metadata.titles.*.*.seasons.*.*.titles.*.*.title",
"public.asset_metadata.series.*.*.display_title",
"public.asset_metadata.series.*.*.title",
"public.asset_metadata.series.*.*.seasons.*.*.display_title",
"public.asset_metadata.series.*.*.seasons.*.*.title",
"public.asset_metadata.series.*.*.seasons.*.*.titles.*.*.display_title",
"public.asset_metadata.series.*.*.seasons.*.*.titles.*.*.title"
]
},
"title_type": {
"options": null,
"paths": [
"public.asset_metadata.titles.*.*.title_type",
"public.asset_metadata.titles.*.*.seasons.*.*.title_type",
"public.asset_metadata.titles.*.*.seasons.*.*.titles.*.*.title_type",
"public.asset_metadata.series.*.*.title_type",
"public.asset_metadata.series.*.*.seasons.*.*.title_type",
"public.asset_metadata.series.*.*.seasons.*.*.titles.*.*.title_type"
]
},
"asset_type": {
"options": null,
"paths": [
"public.asset_metadata.titles.*.*.asset_type",
"public.asset_metadata.titles.*.*.seasons.*.*.asset_type",
"public.asset_metadata.titles.*.*.seasons.*.*.titles.*.*.asset_type",
"public.asset_metadata.series.*.*.asset_type",
"public.asset_metadata.series.*.*.seasons.*.*.asset_type",
"public.asset_metadata.series.*.*.seasons.*.*.titles.*.*.asset_type"
]
},
"synopsis": {
"options": null,
"paths": [
"public.asset_metadata.titles.*.*.info.synopsis",
"public.asset_metadata.titles.*.*.seasons.*.*.synopsis",
"public.asset_metadata.titles.*.*.seasons.*.*.titles.*.*.synopsis",
"public.asset_metadata.series.*.*.info.synopsis",
"public.asset_metadata.series.*.*.seasons.*.*.synopsis",
"public.asset_metadata.series.*.*.seasons.*.*.titles.*.*.synopsis"
]
}
}
}
}
}
}
}
Creating an Index Object
Once both the content type and metadata are ready (cf. above). It's time to create the index object using the fabric. The steps are as such :
- Create a new content by giving it the type hash of the content type, and the metadata prepared above.
- Finalize that object. At that point, the index is empty and cannot be searched. In order to be usable, it needs to Index (next step).
- Indexing using an Index Object
Any time your root metadata changes, you need to reindex again in order to update the index. To do that, follow those steps :
- Edit the Index Object (it will give you a write token)
- Make a bitcode call to search_update using the write token. IMPORTANT : The authorization token SHOULD NOT have a transaction id ! It will not work if it does.
- Wait a bit, it might take a few seconds to perform the indexing. Once the fabric returns with a reply, your Index Object should have been updated with two new parts that are referenced in its metadata at .indexer.part. If .indexer.part exists, then your Index Object is searchable.
Request
Responses
- 200
- 404
- default
Update Index result
Error message returned if the requested entity does not exist.
A generic error message.