tmp.append(nsMappings.getPrefix(propName.getNamespaceURI()));
tmp.append(":").append(FieldNames.FULLTEXT_PREFIX);
tmp.append(propName.getLocalName());
fieldname = tmp.toString();
}
QueryParser parser = new QueryParser(
fieldname, analyzer, synonymProvider);
parser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
// replace escaped ' with just '
StringBuffer query = new StringBuffer();
String textsearch = node.getQuery();
// the default lucene query parser recognizes 'AND' and 'NOT' as
// keywords.
textsearch = textsearch.replaceAll("AND", "and");
textsearch = textsearch.replaceAll("NOT", "not");
boolean escaped = false;
for (int i = 0; i < textsearch.length(); i++) {
if (textsearch.charAt(i) == '\\') {
if (escaped) {
query.append("\\\\");
escaped = false;
} else {
escaped = true;
}
} else if (textsearch.charAt(i) == '\'') {
if (escaped) {
escaped = false;
}
query.append(textsearch.charAt(i));
} else {
if (escaped) {
query.append('\\');
escaped = false;
}
query.append(textsearch.charAt(i));
}
}
Query context = parser.parse(query.toString());
if (relPath != null && (!node.getReferencesProperty() || relPath.getLength() > 1)) {
// text search on some child axis
Path.Element[] elements = relPath.getElements();
for (int i = elements.length - 1; i >= 0; i--) {
String name = null;