private static TInfo parseTerm(FunctionQParser fp) throws SyntaxError {
    TInfo tinfo = new TInfo();

    tinfo.indexedField = tinfo.field = fp.parseArg();
    tinfo.val = fp.parseArg();
    tinfo.indexedBytes = new BytesRef();

    FieldType ft = fp.getReq().getSchema().getFieldTypeNoEx(tinfo.field);
    if (ft == null) ft = new StrField();

    if (ft instanceof TextField) {
      // need to do analysis on the term
      String indexedVal = tinfo.val;
      Query q =
          ft.getFieldQuery(fp, fp.getReq().getSchema().getFieldOrNull(tinfo.field), tinfo.val);
      if (q instanceof TermQuery) {
        Term term = ((TermQuery) q).getTerm();
        tinfo.indexedField = term.field();
        indexedVal = term.text();
      }
      UnicodeUtil.UTF16toUTF8(indexedVal, 0, indexedVal.length(), tinfo.indexedBytes);
    } else {
      ft.readableToIndexed(tinfo.val, tinfo.indexedBytes);
    }

    return tinfo;
  }
Exemplo n.º 2
0
 private boolean matches(ByteRunAutomaton a, int code) {
   char[] chars = Character.toChars(code);
   UnicodeUtil.UTF16toUTF8(chars, 0, chars.length, b);
   return a.run(b.bytes, 0, b.length);
 }
Exemplo n.º 3
0
 public static byte[] toUTF8Bytes(CharSequence charSequence, BytesRef spare) {
   UnicodeUtil.UTF16toUTF8(charSequence, 0, charSequence.length(), spare);
   final byte[] bytes = new byte[spare.length];
   System.arraycopy(spare.bytes, spare.offset, bytes, 0, bytes.length);
   return bytes;
 }
Exemplo n.º 4
0
 static {
   MAX_TERM = new BytesRef();
   final char[] chars = Character.toChars(Character.MAX_CODE_POINT);
   UnicodeUtil.UTF16toUTF8(chars, 0, chars.length, MAX_TERM);
 }