protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException { checkNullField(field); SchemaField sf = schema.getField(field); return sf.getType().getRangeQuery(parser, sf, "*".equals(part1) ? null : part1, "*".equals(part2) ? null : part2, inclusive, inclusive); }
protected Query getPrefixQuery(String field, String termStr) throws ParseException { checkNullField(field); if (getLowercaseExpandedTerms()) { termStr = termStr.toLowerCase(); } // TODO: toInternal() won't necessarily work on partial // values, so it looks like we need a getPrefix() function // on fieldtype? Or at the minimum, a method on fieldType // that can tell me if I should lowercase or not... // Schema could tell if lowercase filter is in the chain, // but a more sure way would be to run something through // the first time and check if it got lowercased. // TODO: throw exception if field type doesn't support prefixes? // (sortable numeric types don't do prefixes, but can do range queries) Term t = new Term(field, termStr); PrefixQuery prefixQuery = new PrefixQuery(t); return prefixQuery; }
protected Query getFieldQuery(String field, String queryText) throws ParseException { checkNullField(field); // intercept magic field name of "_" to use as a hook for our // own functions. if (field.charAt(0) == '_') { if ("_val_".equals(field)) { if (parser==null) { return QueryParsing.parseFunction(queryText, schema); } else { QParser nested = parser.subQuery(queryText, "func"); return nested.getQuery(); } } else if ("_query_".equals(field) && parser != null) { return parser.subQuery(queryText, null).getQuery(); } } // default to a normal field query return super.getFieldQuery(field, queryText); }