Skip to content

element (Structured Query)

isubiker edited this page Feb 18, 2012 · 2 revisions

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

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

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

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

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

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

<constraint>
    <element>author</element>
    <contains>Chomsky</contains>
</constraint>

Required:

  • element - An XML element name key
  • 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.
  • language - Configure the language that the term is in (eg: "en", "de", "ja").

Example:

{
    "element": "author"
    "equals": "Noam Chomsky",
    "caseSensitive": true,
    "stemmed": false
}
Clone this wiki locally