Package org.apache.jackrabbit.core.query.lucene.fulltext

Examples of org.apache.jackrabbit.core.query.lucene.fulltext.QueryParser


                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);
            parser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
            // replace unescaped ' with " and 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) {
                        query.append('\'');
                        escaped = false;
                    } else {
                        query.append('\"');
                    }
                } 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.PathElement[] elements = relPath.getElements();
                for (int i = elements.length - 1; i >= 0; i--) {
                    String name = null;
View Full Code Here


                tmp.append(nsMappings.getPrefix(node.getPropertyName().getNamespaceURI()));
                tmp.append(":").append(FieldNames.FULLTEXT_PREFIX);
                tmp.append(node.getPropertyName().getLocalName());
                fieldname = tmp.toString();
            }
            QueryParser parser = new QueryParser(fieldname, analyzer);
            parser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
            // replace unescaped ' with " and 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) {
                        query.append('\'');
                        escaped = false;
                    } else {
                        query.append('\"');
                    }
                } else {
                    if (escaped) {
                        query.append('\\');
                        escaped = false;
                    }
                    query.append(textsearch.charAt(i));
                }
            }
            return parser.parse(query.toString());
        } catch (NamespaceException e) {
            exceptions.add(e);
        } catch (ParseException e) {
            exceptions.add(e);
        }
View Full Code Here

                tmp.append(nsMappings.getPrefix(node.getPropertyName().getNamespaceURI()));
                tmp.append(":").append(FieldNames.FULLTEXT_PREFIX);
                tmp.append(node.getPropertyName().getLocalName());
                fieldname = tmp.toString();
            }
            QueryParser parser = new QueryParser(fieldname, analyzer);
            parser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
            // replace unescaped ' with " and 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) {
                        query.append('\'');
                        escaped = false;
                    } else {
                        query.append('\"');
                    }
                } else {
                    if (escaped) {
                        query.append('\\');
                        escaped = false;
                    }
                    query.append(textsearch.charAt(i));
                }
            }
            return parser.parse(query.toString());
        } catch (NamespaceException e) {
            exceptions.add(e);
        } catch (ParseException e) {
            exceptions.add(e);
        }
View Full Code Here

                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;
View Full Code Here

            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.getFullTextSearchExpression();
        // 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));
            }
        }
        return parser.parse(query.toString());
    }
View Full Code Here

                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--) {
                    Name name = null;
View Full Code Here

                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);
            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.PathElement[] elements = relPath.getElements();
                for (int i = elements.length - 1; i >= 0; i--) {
                    String name = null;
View Full Code Here

            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.getFullTextSearchExpression();
        // 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));
            }
        }
        return parser.parse(query.toString());
    }
View Full Code Here

                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;
View Full Code Here

            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.getFullTextSearchExpression();
        // 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));
            }
        }
        return parser.parse(query.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.query.lucene.fulltext.QueryParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.