List of usage examples for com.mongodb QueryOperators TEXT
String TEXT
To view the source code for com.mongodb QueryOperators TEXT.
Click Source Link
From source file:org.nuxeo.ecm.core.storage.mongodb.MongoDBQueryBuilder.java
License:Apache License
protected DBObject walkEcmFulltext(String name, Operator op, Operand rvalue) { if (op != Operator.EQ && op != Operator.LIKE) { throw new QueryParseException(NXQL.ECM_FULLTEXT + " requires = or LIKE operator"); }// w w w .j a v a 2s. c o m if (!(rvalue instanceof StringLiteral)) { throw new QueryParseException(NXQL.ECM_FULLTEXT + " requires literal string as right argument"); } if (fulltextSearchDisabled) { throw new QueryParseException("Fulltext search disabled by configuration"); } String fulltextQuery = ((StringLiteral) rvalue).value; if (name.equals(NXQL.ECM_FULLTEXT)) { // standard fulltext query hasFulltext = true; String ft = getMongoDBFulltextQuery(fulltextQuery); if (ft == null) { // empty query, matches nothing return new BasicDBObject(MONGODB_ID, "__nosuchid__"); } DBObject textSearch = new BasicDBObject(); textSearch.put(QueryOperators.SEARCH, ft); // TODO language? return new BasicDBObject(QueryOperators.TEXT, textSearch); } else { // secondary index match with explicit field // do a regexp on the field if (name.charAt(NXQL.ECM_FULLTEXT.length()) != '.') { throw new QueryParseException(name + " has incorrect syntax" + " for a secondary fulltext index"); } String prop = name.substring(NXQL.ECM_FULLTEXT.length() + 1); String ft = fulltextQuery.replace(" ", "%"); rvalue = new StringLiteral(ft); return walkLike(new Reference(prop), rvalue, true, true); } }