Package org.apache.lucene.util

Examples of org.apache.lucene.util.BytesRef.utf8ToString()


            Automaton a = WildcardQuery.toAutomaton(newFulltextTerm(token));
            CompiledAutomaton ca = new CompiledAutomaton(a);
            TermsEnum te = ca.getTermsEnum(t);
            BytesRef text;
            while ((text = te.next()) != null) {
                terms.add(newFulltextTerm(text.utf8ToString()));
            }
            return terms.toArray(new Term[terms.size()]);
        } catch (IOException e) {
            LOG.error("Building fulltext query failed", e.getMessage());
            return null;
View Full Code Here


    out.write(bytes.bytes, bytes.offset, bytes.length);
  }

  public static String readString(DataInput in) throws IOException {
    BytesRef bytes = readBytesRef(in);
    return bytes.utf8ToString();
  }

  public static BytesRef readBytesRef(DataInput in) throws IOException {
    int length = in.readInt();
    BytesRef bytes = new BytesRef(length);
View Full Code Here

            Automaton a = WildcardQuery.toAutomaton(newFulltextTerm(token));
            CompiledAutomaton ca = new CompiledAutomaton(a);
            TermsEnum te = ca.getTermsEnum(t);
            BytesRef text;
            while ((text = te.next()) != null) {
                terms.add(newFulltextTerm(text.utf8ToString()));
            }
            return terms.toArray(new Term[terms.size()]);
        } catch (IOException e) {
            LOG.error("Building fulltext query failed", e.getMessage());
            return null;
View Full Code Here

    IndexReader ir = DirectoryReader.open(dir);
    Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME, PAYLOAD_FIELD_NAME);
    InputIterator tfp = (InputIterator) dictionary.getWordsIterator();
    BytesRef f;
    while((f = tfp.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
      assertEquals(tfp.weight(), doc.getField(WEIGHT_FIELD_NAME).numericValue().longValue());
      assertTrue(tfp.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
    }
    assertTrue(docs.isEmpty());
View Full Code Here

    IndexReader ir = DirectoryReader.open(dir);
    Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME);
    InputIterator tfp = (InputIterator) dictionary.getWordsIterator();
    BytesRef f;
    while((f = tfp.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
      assertEquals(tfp.weight(), doc.getField(WEIGHT_FIELD_NAME).numericValue().longValue());
      assertEquals(tfp.payload(), null);
    }
    assertTrue(docs.isEmpty());
View Full Code Here

    assertEquals(ir.numDocs(), docs.size());
    Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME);
    InputIterator tfp = (InputIterator) dictionary.getWordsIterator();
    BytesRef f;
    while((f = tfp.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
      assertEquals(tfp.weight(), doc.getField(WEIGHT_FIELD_NAME).numericValue().longValue());
      assertEquals(tfp.payload(), null);
    }
    assertTrue(docs.isEmpty());
View Full Code Here

      dpEnum = termsEnum.docsAndPositions(null, dpEnum);
      if (dpEnum == null) {
        throw new IllegalArgumentException(
            "Required TermVector Offset information was not found");
      }
      final String term = text.utf8ToString();

      dpEnum.nextDoc();
      final int freq = dpEnum.freq();
      for(int posUpto=0;posUpto<freq;posUpto++) {
        final int pos = dpEnum.nextPosition();
View Full Code Here

      sdv.get(i, scratch);
      assertEquals(new BytesRef(Integer.toString(i)), scratch);
      ssdv.setDocument(i);
      long ord = ssdv.nextOrd();
      ssdv.lookupOrd(ord, scratch);
      assertEquals(i, Integer.parseInt(scratch.utf8ToString()));
      if (i != 0) {
        ord = ssdv.nextOrd();
        ssdv.lookupOrd(ord, scratch);
        assertEquals(i * 2, Integer.parseInt(scratch.utf8ToString()));
      }
View Full Code Here

      ssdv.lookupOrd(ord, scratch);
      assertEquals(i, Integer.parseInt(scratch.utf8ToString()));
      if (i != 0) {
        ord = ssdv.nextOrd();
        ssdv.lookupOrd(ord, scratch);
        assertEquals(i * 2, Integer.parseInt(scratch.utf8ToString()));
      }
      assertEquals(SortedSetDocValues.NO_MORE_ORDS, ssdv.nextOrd());
    }
   
    reader.close();
View Full Code Here

        for (int j = 0; j < stringValues.length; j++) {
          assert docValues != null;
          long ord = docValues.nextOrd();
          assert ord != NO_MORE_ORDS;
          docValues.lookupOrd(ord, scratch);
          assertEquals(stringValues[j], scratch.utf8ToString());
        }
        assert docValues == null || docValues.nextOrd() == NO_MORE_ORDS;
      }
    }
    ir.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.