Package org.exoplatform.services.jcr.impl.core.query.lucene.fulltext

Examples of org.exoplatform.services.jcr.impl.core.query.lucene.fulltext.QueryParser


            StringBuffer tmp = new StringBuffer();

            fieldname = FieldNames.createFullTextFieldName(resolver.createJCRName(propName).getAsString());
         }

         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.getEntries().length > 1))
         {
            // text search on some child axis
            QPathEntry[] elements = relPath.getEntries();
            for (int i = elements.length - 1; i >= 0; i--)
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.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.