CipherStash
CipherStash Documentation

Querying Records with an Exact Index

An exact index only matches if the query term is identical to the value in the record. What is meant by “identical” is usually straightforward, and is defined by the data type being indexed.

Querying on an exact index is quite straightforward. Only the eq operator is supported, and it takes the value that must be identical, like this:

movies.query do |m|
  m.exactTitle.eq("Star Trek: The Motion Picture")
end

This will only return movies titled “Star Trek: The Motion Picture”.

It’s important not to mistake exactness for uniqueness. Several movies can have the same title, so you shouldn’t expect that only one record will be returned. For example, this query:

movies.query do |m|
  m.exactTitle.eq("Annie")
end

Will return quite a number of records, because it is a very popular movie title. However, the records returned will not include movies such as “Annie Hall” and “Annie Get Your Gun”, because while those titles contain the word “Annie”, they are not exactly identical to “Annie”.