class CrescentSearchRequestWrapper {

	public Query getQuery() throws CrescentInvalidRequestException {
		
		Query resultQuery = null;
		
		String customQueryString = searchRequest.getCustomQuery();
		String regexQueryString = searchRequest.getRegexQuery();
		
		if((customQueryString != null && customQueryString.length() > 0) || (regexQueryString != null && regexQueryString.length() > 0)) {
			CustomQueryStringParser queryParser = new CustomQueryStringParser();
			
			try {
				
				resultQuery = queryParser.getQuery(getIndexedFields(), customQueryString, collection.getSearchModeAnalyzer(), regexQueryString);
			
			} catch (Exception e) {
				logger.error("Error In getQuery ", e);
				throw new CrescentInvalidRequestException(e.getMessage());
			}
			
		} else {
			
			if (getKeyword() == null || getKeyword().length() == 0) {
				resultQuery = new MatchAllDocsQuery();
				return resultQuery;
			
			}
			
			DefaultKeywordParser queryParser = new DefaultKeywordParser();
			resultQuery = queryParser.parse(getTargetSearchFields(), getKeyword(), collection.getSearchModeAnalyzer());
		
		}
		
		return resultQuery;
	}

	public  CrescentSearchRequestWrapper(SearchRequest searchRequest);

}