Exact Match Query

  • By default, when querying strings the string comparisons are case-insensitive.

  • Use the where_equals method exact parameter to perform a search that is case-sensitive.

  • When making a dynamic query with an exact match, the auto-index created by the server indexes the text of the document field using the default exact analyzer where the casing of the original text is unchanged.

  • In this page:

Query with exact match

employees = list(
    # Make a query on 'Employees' collection
    # Query for all documents where 'FirstName' equals 'Robert'
    # Pass 'exact=True' for a case-sensitive match
    .where_equals("FirstName", "Robert", exact=True)
from "Employees"
where exact(FirstName == "Robert")

  • Executing the above query will generate the auto-index Auto/Employees/ByExact(FirstName).

  • This auto-index will contain the following two index-fields:

    • FirstName
      Contains terms with the text from the indexed document field 'FirstName'.
      Text is lower-cased and not tokenized.

    • exact(FirstName)
      Contain terms with the original text from the indexed document field 'FirstName'.
      Casing is exactly the same as in the original text, and the text is not tokenized.
      Making an exact query targets these terms to find matching documents.

Query with exact match - nested object

orders = list(
    # Make a query on 'Orders' collection
    # Query for documents that contain at least one order line with 'Teatime Chocolate Biscuits'
        "Teatime Chocolate Biscuits",
        # Pass 'exact=True' for a case-sensitive match
from "Orders" 
where exact(Lines.ProductName == "Teatime Chocolate Biscuits")


def where_equals(
    self, field_name: str, value_or_method: Union[object, MethodCall], exact: Optional[bool] = None
) -> DocumentQuery[_T]: ...
Parameter Type Description
field_name str Search-field name
value_or_method Union[object, MethodCall] object to match with
MethodCall with match condition
exact (optional) bool False - search is case-insensitive
True - search is case-sensitive
Return Type Description
DocumentQuery[_T] where_equals query results