Overview of Filter Operator $contains

Filter operator $contains performs full-text search of JSON documents in a SODA collection.

A filter field whose value is an object with a $contains operator matches a JSON document if the document has that field with a full-word string value or a full-number value that matches the string operand of $contains somewhere, including in an array element. Matching is Oracle Text full-text.

The syntax of the search-pattern value for operator $contains is the same as the third parameter of SQL condition json_textcontains, and the resulting behavior is the same. This means, for instance, that you can query for text that is near some other text, or query use fuzzy pattern-matching. (If the search-pattern argument contains a character or a word that is reserved with respect to Oracle Text search then you must escape that character or word.)

To use full-text search with $contains you must create a JSON search index for the document collection. To do that you pass a search-index specification, such as in Example 3-3, to the index-creation function or method for your chosen SODA implementation (language).

Once you have a search index for your collection, this simple filter searches the street fields of all documents, case-insensitively, for a value that contains the word "abc".

{"street" : { "$contains" : "abc"}}

Example 2-2 is a match, for example, because it has a street field with value "30 ABC avenue".

Related Topics

See Also: JSON_TEXTCONTAINS Condition in Oracle Database SQL Language Reference