public boolean setCategory(String category) throws ParseException { if (category == null || category.length() == 0) return false; String[] categories = category.split(","); Query catQuery = null; QueryParser qp = new QueryParser( DocumentWrap.CATEGORY, AnalyzerFactory.get(collectionsList.get(0).getLanguage())); if (categories.length == 1) { catQuery = qp.parse(categories[0]); } else { catQuery = new BooleanQuery(); for (int i = 0; i < categories.length; i++) { ((BooleanQuery) catQuery).add(qp.parse(categories[i]), BooleanClause.Occur.SHOULD); } } this.query = combineQueries(catQuery, this.query); return true; }
public boolean setCriteria(String _critera, String type) throws ParseException { if (_critera == null || _critera.length() == 0) return false; // If this is 'simple' then we OR up all parameters if ((type == null || type.equalsIgnoreCase("simple")) && _critera.indexOf(",") != -1) { String[] tokens = _critera.split(","); _critera = tokens[0]; for (int x = 1; x < tokens.length; x++) _critera += " OR " + tokens[x]; } if (_critera.equals( "*")) // Special Case, this allows you to retrieve all results from the collection query = new MatchAllDocsQuery(); else { QueryParser qp = new QueryParser( DocumentWrap.CONTENTS, AnalyzerFactory.get(collectionsList.get(0).getLanguage())); query = qp.parse(_critera); } return true; }