Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexableField


  public void testBinaryField() throws Exception {
    Document doc = new Document();
   
    FieldType ft = new FieldType();
    ft.setStored(true);
    IndexableField stringFld = new Field("string", binaryVal, ft);
    IndexableField binaryFld = new StoredField("binary", binaryVal.getBytes("UTF-8"));
    IndexableField binaryFld2 = new StoredField("binary", binaryVal2.getBytes("UTF-8"));
   
    doc.add(stringFld);
    doc.add(binaryFld);
   
    assertEquals(2, doc.getFields().size());
View Full Code Here


    // index the document
    Indexer indexer = new Indexer(indexDirectory);
    try {
      indexer.open();
      if (labelDoc != null) {
        IndexableField existingContent = labelDoc.getField(Indexer.CONTENT_FIELD_NAME);
        indexer.updateDocument(existingContent, sb.toString(), label);
      } else {
        indexer.addDocument(sb.toString(), label);
      }
      indexer.commit();
View Full Code Here

    this.nullMarker = nullMarker;
  }

  @Override
  public Object get(String name, Document document) {
    final IndexableField field = document.getField( name );
    String stringValue = field.stringValue();
    if ( nullMarker.equals( stringValue ) ) {
      return null;
    }
    else {
      return fieldBridge.get( name, document );
View Full Code Here

    return stringBridge.objectToString( object );
  }

  @Override
  public Object get(String name, Document document) {
    final IndexableField field = document.getField( name );
    if ( field == null ) {
      return stringBridge.stringToObject( null );
    }
    else {
      String stringValue = DocumentBuilderHelper.extractStringFromFieldable( field );
View Full Code Here

    //If we still didn't know the value using any bridge, return the raw value or string:
    for ( int index = 0; index < result.length; index++ ) {
      if ( result[index] == NOT_SET ) {
        result[index] = null; // make sure we never return NOT_SET
        if ( document != null ) {
          IndexableField field = document.getField( fields[index] );
          if ( field != null ) {
            result[index] = extractObjectFromFieldable( field );
          }
        }
      }
View Full Code Here

            Document doc = searcher.doc(top.scoreDocs[0].doc);
            String foundPath = doc.get(QueryBuilder.PATH);

            // Only use the definitions if we found an exact match.
            if (path.equals(foundPath)) {
                IndexableField tags = doc.getField(QueryBuilder.TAGS);
                if (tags != null) {
                    return Definitions.deserialize(tags.binaryValue().bytes);
                }
            }
        } finally {
            ireader.close();
        }
View Full Code Here

                out.write(rpath.substring(rpath.lastIndexOf('/') + 1)); // htmlize ???
                out.write("</a></td><td><tt class=\"con\">");
                if (sh.sourceContext != null) {
                    Genre genre = Genre.get(doc.get("t"));
                    Definitions tags = null;
                    IndexableField tagsField = doc.getField("tags");
                    if (tagsField != null) {
                        tags = Definitions.deserialize(tagsField.binaryValue().bytes);
                    }
                    if (Genre.XREFABLE == genre && sh.summerizer != null) {
                        String xtags = getTags(xrefDataDir, rpath, sh.compressed);
                        // FIXME use Highlighter from lucene contrib here,
                        // instead of summarizer, we'd also get rid of
View Full Code Here

                Document doc = docs.get(ii);
                String filename = doc.get(QueryBuilder.PATH);

                Genre genre = Genre.get(doc.get(QueryBuilder.T));
                Definitions tags = null;
                IndexableField tagsField = doc.getField(QueryBuilder.TAGS);
                if (tagsField != null) {
                    tags = Definitions.deserialize(tagsField.binaryValue().bytes);
                }
                int nhits = docs.size();

                if (sourceContext != null) {
                    try {
View Full Code Here

      // Only index the desired fields.
      if (!indexed && !id)
        continue;

      Class<?> type = reader.type();
      IndexableField field;

      Object value = reader.value(t);
      if (id) {
        if (value == null)
          throw new IllegalArgumentException("You must provide an id (disk store does not autopopulate id");
View Full Code Here

  }

  @Override
  public Object get(String name, Document document) {
    StringBuilder sb = new StringBuilder( 7 );
    IndexableField xFieldable = document.getField( getXFieldName( name ) );
    IndexableField yFieldable = document.getField( getYFieldName( name ) );
    appendValue( xFieldable, sb );
    sb.append( ';' );
    appendValue( yFieldable, sb );
    return sb.toString();
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.IndexableField

Copyright © 2018 www.massapicom. 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.