Open topic with navigation

TIBCO® Patterns 6.1.2

# Variable Attributes Queries

If your table has a container field for Variable Attributes, a Variable Attributes query is a convenient way to match against the values of such attributes. A Variable Attributes query consists of a set of name-value pairs. The name portion of the name-value pair is the name of a Variable Attribute that might or might not exist in any individual record in the table. The value is the text you search for in the attributes with that name. Weighting might be attached to each name-value pair to adjust its relative significance.

For example, the records in the table might represent products in a catalog. Catalog items can have Variable Attributes such as Color, Size, Style, Weight, and so forth. Not all items have every attribute; some might have none. A Variable Attributes query on such a table might consist of name value pairs such as “Color” = "Red", and "Size" = "X-Large".

With Variable Attributes, it is expected that many records will not have one or more of the named Attributes. The question is how to treat such records? By default, the Attribute is simply ignored if either the query value is empty or the record does not have the attribute, or the attribute value in the record is empty. It is as if the Name-Value pair was not included in the query. This behavior is controlled by setting the empty score value for the Variable Attribute query. If the user sets the empty score to a value between 0.0 and 1.0, the empty attributes are no longer ignored. Instead, if a query value is empty or an Attribute is not present or empty, that portion of the Variable Attribute Query is assigned the "empty score". Note that it is only that portion that receives the empty score, not the entire query. For example, assume a query:

    Color="Red", Size="X-Large"

and two records:

    Color="Red", Size="Large"
    Color="Red"

The first record receives a score somewhat less than 1.0 because it does not have a perfect match on both attributes. By default, the second record receives a perfect 1.0 score as it has a perfect match on the only attribute present in the record, the missing attribute is ignored so the total score is based on the remaining attribute. If you set the empty score to 0.0, the first record has the same high score as before, while the second record has a score of 0.5 as only half the attributes were matched, and the non-existent attribute gets a score of 0.0.

Remember that in all the cases, an attribute that is not present in a record is treated as if it existed but had an empty value. Matching makes no distinction between an empty attribute and a missing attribute.

A Variable Attributes query can be combined with other query types such as simple and cognate queries in more complex query structures. A Variable Attributes query is typically used in this way to qualify a search so that the most desired records (the records matching the most desired attributes) score highest.

Note: Simple and cognate queries can work with Variable Attributes. When specifying a field name to match against, use the field name of the Variable Attributes container, qualifying it with the name of a Variable Attribute using the colon (":") character as a separator, for example, "varattrs:Color".
Note: If the name of the Variable Attributes container field is used with no qualifier, the match is performed against the concatenated list of all Variable Attribute values in the container field.

## Example

If a field "Address" of type Variable Attributes is defined using the attributes:

    line1:123 Main St;line2:Suite101;city:Gothem;county:;state:NY;zip:07123

You can query the entire Variable Attribute field or any specific attribute as specified:

| • | Two Variable Attributes: `{"address:line1"= "123 Main St","address:line2"= "Suite 10"}`

| • | Entire attribute field: `{"address"= "123 Main St Suite 101 Gothem NY 07123"}`

| • | One Variable Attribute and one normal field: `{"address:line1"= "123 Main St","first"= "John"}`

| • | One entire Variable Attribute and one normal field: `{"address"= "123 Main St Suite 101 Gothem NY 07123","last"= "Smith"}`

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO® Patterns

Copyright © 2010-2025. Cloud Software Group, Inc. All Rights Reserved.