The
Data Access API is used to access structured data such as arrays and weighted sets.
Use Case: accessing array attributes
The following illustrates accessing some field that is of array type:
Here we assume there is a field in our schema like this:
field titles type array<string> {
indexing: attribute | summary
}
Again we process each hit, this time traversing the array and building a string which contains all the titles,
transforming a field looking like this:
into this output:
Use Case: accessing weighted set attributes
The following example illustrates accessing data held in a weighted set.
Note that the Data Access API doesn't have a "set" or "weighted set" concept;
the weighted set is represented as an unordered array of objects
where each object has an "item" and a "weight" field.
The weight is a long integer value,
while the item type will vary according to the field type as declared in the schema.
Here we assume there is a field in the schema like:
field titles type weightedset<string> {
indexing: attribute | summary
}
Again we process each hit, and format each element of the weighted set, transforming this input:
into this output:
Unit testing with structured data
For unit testing it is useful to be able to create structured data fields programmatically.
This case be done using Slime: