5.5.7.1 Parallel Text Search Using Oracle Text
You can use parallel text query using Oracle Text by calling the method getPartitioned
in OracleTextAutoIndex
, specifying an array of connections to Oracle Text (Connection objects), the key/value pair to search, and the starting partition ID.
The following code fragment generates an automatic text index using Oracle Text and executes a parallel text query. The number of calls to the getPartitioned
method in the OracleTextAutoIndex
class is controlled by the total number of partitions in the VT$ (or GE$ tables) and the number of connections used.
OraclePropertyGraph opg = OraclePropertyGraph.getInstance(…); String prefOwner = "scott"; String datastore = (String) null; String filter = (String) null; String storage = (String) null; String wordlist = (String) null; String stoplist = (String) null; String lexer = "OPG_AUTO_LEXER"; String options = (String) null; OracleIndexParameters params = OracleTextIndexParameters.buildOracleText(prefOwner, datastore, filter, storage, wordlist, stoplist, lexer, dop, options); opg.setDefaultIndexParameters(indexParams); // Create auto indexing on all existing properties, use wildcard for all opg.createKeyIndex(("*", Vertex.class); // Create the text query object for Oracle Text OracleTextQueryObject otqo = OracleTextQueryObject.getInstance("Smith" /* query body */, 1 /* score */, ScoreRange.POSITIVE /* Score range */, Direction.ASC /* order by direction*/); // Get the Connection object Connection[] conns = new Connection[dop]; for (int idx = 0; idx < conns.length; idx++) { conns[idx] = opg.getOracle().clone().getConnection(); } // Get the auto index object OracleIndex<Vertex> index = ((OracleIndex<Vertex>) opg.getAutoIndex(Vertex.class); // Iterate to cover all the partitions in the index long lCount = 0; for (int split = 0; split < index.getTotalShards(); split += conns.length) { // Gets elements from split to split + conns.length Iterable<Vertex>[] iterAr = index.getPartitioned(conns /* connections */, "name"/* key */, otqo, true /* wildcards */, split /* start split ID */); lCount = countFromIterables(iterAr); /* Consume iterables in parallel */ } // Close the connections for (int idx = 0; idx < conns.length; idx++) { conns[idx].dispose(); } // Count results System.out.println("Vertices found using parallel query: " + lCount);