attribute (Structured Query)

isubiker edited this page Nov 11, 2011 · 1 revision

Matches XML documents, or JSON documents that contain XML, that have an attribute with the given value.

The following query will return documents where the author attribute on the book element is equal to "Noam Chomsky":

{
    "element": "book",
    "attribute": "author",
    "equals": "Noam Chomsky"  // Can be a boolean, number, string or an array of numbers or strings
}

<constraint>
    <element>book</element>
    <attribute>author</attribute>
    <equals>Noam Chomsky</equals>
</constraint>

The following query will return documents where the author attribute on the book element contains "Chomsky":

{
    "element": "book",
    "attribute": "author",
    "contains": "Chomsky"  // Can be a string or an array of strings
}

<constraint>
    <element>book</element>
    <attribute>author</attribute>
    <contains>Noam Chomsky</contains>
</constraint>

Required:

  • element - The XML element that the attribute is on
  • attribute - The XML attribute name
  • One of the following, but not both:
    • equals - The value that the XML element will need to be equal to
    • contains - A string that the value of the XML element will need to contain

In the JSON format, if an array of values is given for either the equals or contains key, documents will match if any of the provided values are present. In the XML format, the equals or contains key can also contain any number of <value> elements, providing the same functionality (eg: <contains><value>Chomsky</value><value>Plato</value></contains>).

Optional configuration:

  • weight (number) - Configure how important or how heavily this term weighs in the query. The higher the number the more this term will contribute to the score of the document, thus appearing higher in the search results.
  • caseSensitive (boolean) - Setting to true ensures that case is matched, false ignores case. The default behavior examines the query and if it contains upper-case characters it performs a case sensitive search. The above example would default to being case sensitive.
  • diacriticSensitive (boolean) - Setting to true ensures that diacritics are matched, false ignore diacritics. The default behavior examines the query and if it contains diacritics it performs a diacritic sensitive search.
  • punctuationSensitve (boolean) - Setting to true ensures that punctuation is matched in the query. It's not recommended to issue punctuation sensitive searches as they can not be resolved out of the indexes and can easily yield poor performance.
  • whitespaceSensitive (boolean) - Setting to true ensures that whitespace is matched exactly as it is in the query, otherwise whitespace is normalized. It's not recommended to issue whitespace sensitive searches as they can not be resolved out of the indexes and can easily yield poor performance.
  • stemmed (boolean) - Setting to true stems search terms (eg: "flying" also matches "fly" and "flew").
  • wildcarded (boolean) - Setting to true treats "*" and "?" as wildcards in the query.

Example:

{
    "element": "book",
    "attribute": "author",
    "equals": "Noam Chomsky",
    "caseSensitive": true,
    "stemmed": false
}
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.