List of usage examples for org.apache.lucene.index Term toString
public static final String toString(BytesRef termText)
From source file:org.apache.solr.query.SolrRangeQuery.java
License:Apache License
private String endpoint(BytesRef ref) { if (ref == null) return "*"; String toStr = Term.toString(ref); if ("*".equals(toStr)) { toStr = "\\*"; }/*from w w w.ja v a 2 s . co m*/ // TODO: other escaping return toStr; }
From source file:org.elasticsearch.validate.SimpleValidateQueryTests.java
License:Apache License
private String indexedValueForSearchAsString(int value) { BytesRefBuilder bytesRef = new BytesRefBuilder(); NumericUtils.intToPrefixCoded(value, 0, bytesRef); // 0 because of exact match return Term.toString(bytesRef.get()); }
From source file:uk.co.flax.luwak.presearcher.FieldFilterPresearcherComponent.java
License:Apache License
private Query buildFilterClause(LeafReader reader) throws IOException { Terms terms = reader.fields().terms(field); if (terms == null) return null; BooleanQuery.Builder bq = new BooleanQuery.Builder(); int docsInBatch = reader.maxDoc(); BytesRef term;/*w ww. j a va2 s. c o m*/ TermsEnum te = terms.iterator(); while ((term = te.next()) != null) { // we need to check that every document in the batch has the same field values, otherwise // this filtering will not work if (te.docFreq() != docsInBatch) throw new IllegalArgumentException("Some documents in this batch do not have a term value of " + field + ":" + Term.toString(term)); bq.add(new TermQuery(new Term(field, BytesRef.deepCopyOf(term))), BooleanClause.Occur.SHOULD); } BooleanQuery built = bq.build(); if (built.clauses().size() == 0) return null; return built; }