Imports an XML combined search definition that defines the matching
criteria for this rule.

@param queryDef
A combined raw query definition serialized as XML.
6628
public void importQueryDefinition(XMLWriteHandle queryDef) {
    List<XMLEvent> importedList = Utilities.importFromHandle(queryDef);
    // modify XMLEvent list if the imported XML was a structured query.
    XMLEvent firstEvent = importedList.get(0);
    if (firstEvent.getEventType() ==  XMLStreamConstants.START_ELEMENT) {
      StartElement startElement = firstEvent.asStartElement();
      if (RequestConstants.SEARCH_NS.equals(startElement.getName().getNamespaceURI()) &&
        startElement.getName().getLocalPart().equals("query")) {
        //wrap in search.
        List<XMLEvent> wrappedList = new ArrayList<>();
        XMLEventFactory  eventFactory = XMLEventFactory.newInstance();
        XMLEvent startSearchElement = eventFactory.createStartElement("search", RequestConstants.SEARCH_NS, "search");
        XMLEvent endSearchElement = eventFactory.createEndElement("search", RequestConstants.SEARCH_NS, "search");

        wrappedList.add(startSearchElement);
        wrappedList.addAll(importedList);
        wrappedList.add(endSearchElement);
        this.queryPayload = wrappedList;
      }
      else {
        this.queryPayload = importedList;
      }
    }
    else {
      logger.warn("Expected imported XML to be an element, but it's not.");
      this.queryPayload = importedList;
    }

  }
360019
public void addQuery(String query, String bId) {
		
		BatchItemRequest batchItemRequest = new BatchItemRequest();
		batchItemRequest.setBId(bId);
		batchItemRequest.setQuery(query);
		
		batchItemRequests.add(batchItemRequest);
		bIds.add(bId);
	}
516164
function getQueryObj(query='') {
  const qObj = {};
  const pairs = (query[0] === '?' ? query.substr(1) : query).split('&');
  for (let i = 0, j = pairs.length; i < j; i++) {
    let pair = pairs[i].split('=');
    qObj[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
  }
  return qObj;
}
311600
public static QueryType getQueryType(String query) {

        final String trimmedQuery = removeCommentAndWhiteSpace(query);
        if (trimmedQuery == null || trimmedQuery.length() < 1) {
            return QueryType.OTHER;
        }

        final char firstChar = trimmedQuery.charAt(0);
        final QueryType type;
        switch (firstChar) {
            case 'S':
            case 's':
                type = QueryType.SELECT;
                break;
            case 'I':
            case 'i':
                type = QueryType.INSERT;
                break;
            case 'U':
            case 'u':
                type = QueryType.UPDATE;
                break;
            case 'D':
            case 'd':
                type = QueryType.DELETE;
                break;
            default:
                type = QueryType.OTHER;
        }
        return type;
    }
938829
private void addQueryStringPair(String cleanKey, Object rawValue, StringBuilder queryStringBuilder)
    {
        // Serialize null values as an empty string.
        String valueAsString = rawValue == null ? "" : String.valueOf(rawValue);
        String cleanValue = this.url(valueAsString);
        if (queryStringBuilder.length() != 0) {
            queryStringBuilder.append(AND);
        }
        queryStringBuilder.append(cleanKey).append(EQUALS).append(cleanValue);
    }
305006
public void setSearchString(String queryString)
    {
        this.searchString = queryString;
        if (this.textFilterField != null)
        {
            this.textFilterField.setText(this.searchString);
        }
    }
473060
protected void addFilterQueryParts(CmsSolrQuery query) {

        if (!m_state.getCheckedEntries().isEmpty()) {
            StringBuffer value = new StringBuffer();
            value.append("{!tag=").append(m_config.getName()).append('}');
            value.append(m_config.getRange());
            value.append(":(");
            final Iterator<String> fieldIterator = m_state.getCheckedEntries().iterator();
            value.append(generateRange(fieldIterator.next()));
            final String concater = m_config.getIsAndFacet() ? " AND " : " OR ";
            while (fieldIterator.hasNext()) {
                value.append(concater);
                value.append(generateRange(fieldIterator.next()));
            }
            if (m_config.getHardEnd()) {
                value.append(concater);
                value.append("[" + m_config.getStart() + " TO " + m_config.getEnd() + "}");
            }
            value.append(')');
            query.add("fq", value.toString());
        }
    }
1304723
public void setQuery( String query )
    {
        _parameters = null;

        if ( query == null || query.length() == 0 ) { return; }

        for ( StringTokenizer tok = new StringTokenizer( query, "&" ); tok.hasMoreElements(); )
        {
            String queryItem = tok.nextToken();

            if ( queryItem.startsWith( "amp;" ) )
            {
                queryItem = queryItem.substring( 4 );
            }

            int eq = queryItem.indexOf( '=' );
            if ( eq != -1 )
            {
                addParameter( queryItem.substring( 0, eq ) , queryItem.substring( eq + 1 ), true );
            }
            else
            {
                addParameter( queryItem, null, true );
            }
        }
    }
77831
private I_CmsFacetQueryItem parseFacetQueryItem(final String prefix) {

        I_CmsXmlContentValue query = m_xml.getValue(prefix + XML_ELEMENT_QUERY_FACET_QUERY_QUERY, m_locale);
        if (null != query) {
            String queryString = query.getStringValue(null);
            I_CmsXmlContentValue label = m_xml.getValue(prefix + XML_ELEMENT_QUERY_FACET_QUERY_LABEL, m_locale);
            String labelString = null != label ? label.getStringValue(null) : null;
            return new CmsFacetQueryItem(queryString, labelString);
        } else {
            return null;
        }
    }
804685
public JSONObject searchRules(RuleQuery query, RequestOptions requestOptions) throws AlgoliaException, JSONException {
    JSONObject body = new JSONObject();
    if (query.getQuery() != null) {
      body = body.put("query", query.getQuery());
    }
    if (query.getAnchoring() != null) {
      body = body.put("anchoring", query.getAnchoring());
    }
    if (query.getContext() != null) {
      body = body.put("context", query.getContext());
    }
    if (query.getPage() != null) {
      body = body.put("page", query.getPage());
    }
    if (query.getHitsPerPage() != null) {
      body = body.put("hitsPerPage", query.getHitsPerPage());
    }

    return client.postRequest("/1/indexes/" + encodedIndexName + "/rules/search", body.toString(), false, true, requestOptions);
  }
707926
@SuppressWarnings("unchecked")
    public static Map<String, Object> normaliseAndValidateQuery(Map<String, Object> query) throws QueryException{
        boolean isWildCard = false;
        if (query.isEmpty()) {
            isWildCard = true;
        }

        // First expand the query to include a leading compound predicate
        // if there isn't one already.
        query = addImplicitAnd(query);

        // At this point we will have a single entry map, key AND or OR,
        // forming the compound predicate.
        String compoundOperator = (String) query.keySet().toArray()[0];
        List<Object> predicates = new ArrayList<Object>();
        if (query.get(compoundOperator) instanceof List) {
            // Next make sure all the predicates have an operator -- the EQ
            // operator is implicit and we need to add it if there isn't one.
            // Take
            //     [ {"field1": "mike"}, ... ]
            // and make
            //     [ {"field1": { "$eq": "mike"} }, ... ]
            predicates = addImplicitEq((List<Object>) query.get(compoundOperator));

            // Then all shorthand operators like $ne, if present, need to be converted
            // to their logical longhand equivalent.
            // Take
            //     [ { "field1": { "$ne": "mike"} }, ... ]
            // and make
            //     [ { "field1": { "$not" : { "$eq": "mike"} } }, ... ]
            predicates = handleShortHandOperators(predicates);

            // Now in the event that extraneous $not operators exist in the query,
            // these operators must be compressed down to the their logical equivalent.
            // Take
            //     [ { "field1": { "$not" : { $"not" : { "$eq": "mike"} } } }, ... ]
            // and make
            //     [ { "field1": { "$eq": "mike"} }, ... ]
            predicates = compressMultipleNotOperators(predicates);

            // Here we ensure that all non-whole number arguments included in a $mod
            // clause are truncated.  This provides for consistent behavior between
            // the SQL engine and the unindexed matcher.
            // Take
            //     [ { "field1": { "$mod" : [ 2.6, 1.7] } }, ... ]
            // and make
            //     [ { "field1": { "$mod" : [ 2, 1 ] } }, ... ]
            predicates = truncateModArguments(predicates);
        }

        Map<String, Object> selector = new HashMap<String, Object>();
        selector.put(compoundOperator, predicates);
        if (!isWildCard) {
            validateSelector(selector);
        }

        return selector;
    }
818047
private void addQueryParams(final Request request) {
        if (order != null) {
            request.addQueryParam("Order", order.toString());
        }

        if (from != null) {
            request.addQueryParam("From", from);
        }

        if (bounds != null) {
            request.addQueryParam("Bounds", bounds.toString());
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
569174
public static String getQuery(String clazzFieldName, String clazzName, String idFieldName, String idFieldValue)
    {
        StringBuffer sb = new StringBuffer("+");
        sb.append(clazzFieldName);
        sb.append(":");
        sb.append(clazzName);
        sb.append(" AND ");
        sb.append("+");
        sb.append(idFieldName);
        sb.append(":");
        sb.append(idFieldValue);
        return sb.toString();
    }
1257278
public QueryFilter withQuery(String query) {
        try {
            String encodedQuery = urlEncode(query);
            parameters.put(KEY_QUERY, encodedQuery);
            return this;
        } catch (UnsupportedEncodingException ex) {
            //"Every implementation of the Java platform is required to support the following standard charsets [...]: UTF-8"
            //cf. https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html
            throw new IllegalStateException("UTF-8 encoding not supported by current Java platform implementation.", ex);
        }
    }
1323538
private static QueryComponent getQueryComponent(Queue filterClauseQueue)
    {
        QueryComponent subQuery = new QueryComponent();
        QueryComponent currentSubQuery = subQuery;

        for (Object object : filterClauseQueue)
        {
            if (object instanceof FilterClause)
            {
                currentSubQuery.clauses.add(object);
            }
            else if (object instanceof String)
            {
                String interClauseConstruct = (String) object;
                if (interClauseConstruct.equals("("))
                {
                    QueryComponent temp = new QueryComponent();
                    currentSubQuery.children.add(temp);
                    temp.parent = currentSubQuery;
                    currentSubQuery = temp;
                }
                else if (interClauseConstruct.equals(")"))
                {
                    currentSubQuery = currentSubQuery.parent;
                }
                else if (interClauseConstruct.equalsIgnoreCase("AND"))
                {
                    currentSubQuery.isAnd = true;
                }
                else if (interClauseConstruct.equalsIgnoreCase("OR"))
                {
                    currentSubQuery.isAnd = false;
                }
            }
        }

        return subQuery;
    }
1108446
public String processSearchRequest(final SearchRequest request) {
    StringBuilder builder = new StringBuilder();
    builder.append("Search for ");
    if (request.getDatabaseCode() != null) {
      builder.append("code ");
      builder.append(request.getDatabaseCode());
    }
    if (request.getQuery() != null) {
      builder.append(" with query ");
      builder.append(request.getQuery());
    }
    if (request.getPageNumber() != null) {
      builder.append(" page ");
      builder.append(request.getPageNumber());
    }
    if (request.getMaxPerPage() != null) {
      builder.append(" limited to ");
      builder.append(request.getMaxPerPage());
      builder.append(" per page");
    }
    return builder.toString();
  }
1204021
protected void appendFilterQuery(SolrQuery solrQuery, List<FilterQuery> filterQueries,
			@Nullable Class<?> domainType) {

		if (CollectionUtils.isEmpty(filterQueries)) {
			return;
		}

		List<String> filterQueryStrings = getFilterQueryStrings(filterQueries, domainType);

		if (!filterQueryStrings.isEmpty()) {
			solrQuery.setFilterQueries(convertStringListToArray(filterQueryStrings));
		}
	}