I need to check if the concatenation of two fields matches a particular regex. Here there is my code:
BasicDBObject regexQueryName = new BasicDBObject();
regexQueryCode.put("name", new BasicDBObject("$regex", ".*"+parameter+".*").append("$options", "i"));
BasicDBObject regexQuerySurname = new BasicDBObject();
regexQueryTitle.put("surname", new BasicDBObject("$regex", ".*"+parameter+".*").append("$options", "i"));
BasicDBList or = new BasicDBList();
or.add(regexQueryName);
or.add(regexQuerySurname);
BasicDBObject query = new BasicDBObject("$or", or);
it checks if the regex matches the first or the second field and then shows the result, while i need to concatenate the two fields before checking the regex. Please don't suggest me to use a view.
Thank you