Package org.apache.lucene.document

Examples of org.apache.lucene.document.MapFieldSelector


    Directory dir2 = getDir2();
    ParallelReader pr = new ParallelReader();
    pr.add(IndexReader.open(dir1));
    pr.add(IndexReader.open(dir2));

    Document doc11 = pr.document(0, new MapFieldSelector(new String[] {"f1"}));
    Document doc24 = pr.document(1, new MapFieldSelector(Arrays.asList(new String[] {"f4"})));
    Document doc223 = pr.document(1, new MapFieldSelector(new String[] {"f2", "f3"}));
   
    assertEquals(1, doc11.getFields().size());
    assertEquals(1, doc24.getFields().size());
    assertEquals(2, doc223.getFields().size());
   
View Full Code Here


    }
    return fragments.toArray( new String[fragments.size()] );
  }
 
  protected String[] getFieldValues( IndexReader reader, int docId, String fieldName) throws IOException {
    Document doc = reader.document( docId, new MapFieldSelector( new String[]{ fieldName } ) );
    return doc.getValues( fieldName ); // according to Document class javadoc, this never returns null
  }
View Full Code Here

    if ( projectionSize != 0 ) {
      for ( String projectedField : projection ) {
        fields.put( projectedField, FieldSelectorResult.LOAD );
      }
    }
    this.fieldSelector = new MapFieldSelector( fields );
  }
View Full Code Here

      // so apply an additional optimization using LOAD_AND_BREAK instead:
      String key = fields.keySet().iterator().next();
      fields.put( key, FieldSelectorResult.LOAD_AND_BREAK );
    }
    if ( fields.size() != 0 ) {
      this.fieldSelector = new MapFieldSelector( fields );
    }
    // else: this.fieldSelector = null; //We need no fields at all
  }
View Full Code Here

   * @throws IOException
   */
  private String forceClassNameExtraction(int scoreDocIndex) throws IOException {
    Map<String, FieldSelectorResult> fields = new HashMap<String, FieldSelectorResult>( 1 );
    fields.put( ProjectionConstants.OBJECT_CLASS, FieldSelectorResult.LOAD_AND_BREAK );
    MapFieldSelector classOnly = new MapFieldSelector( fields );
    Document doc = queryHits.doc( scoreDocIndex, classOnly );
    return doc.get( ProjectionConstants.OBJECT_CLASS );
  }
View Full Code Here

      // so apply an additional optimization using LOAD_AND_BREAK instead:
      String key = fields.keySet().iterator().next();
      fields.put( key, FieldSelectorResult.LOAD_AND_BREAK );
    }
    if ( fields.size() != 0 ) {
      this.fieldSelector = new MapFieldSelector( fields );
    }
    // else: this.fieldSelector = null; //We need no fields at all
  }
View Full Code Here

   * @throws IOException
   */
  private String forceClassNameExtraction(int scoreDocIndex) throws IOException {
    Map<String, FieldSelectorResult> fields = new HashMap<String, FieldSelectorResult>( 1 );
    fields.put( ProjectionConstants.OBJECT_CLASS, FieldSelectorResult.LOAD_AND_BREAK );
    MapFieldSelector classOnly = new MapFieldSelector( fields );
    Document doc = queryHits.doc( scoreDocIndex, classOnly );
    return doc.get( ProjectionConstants.OBJECT_CLASS );
  }
View Full Code Here

    if ( projectionSize != 0 ) {
      for ( String projectedField : projection ) {
        fields.put( projectedField, FieldSelectorResult.LOAD );
      }
    }
    this.fieldSelector = new MapFieldSelector( fields );
  }
View Full Code Here

    public Q load(Path<?>... paths) {
        List<String> fields = new ArrayList<String>(paths.length);
        for (Path<?> path : paths) {
            fields.add(serializer.toField(path));
        }
        this.fieldSelector = new MapFieldSelector(fields);
        return (Q)this;
    }
View Full Code Here

        assertNull(document.get("year"));
    }

    @Test
    public void Load_List_FieldSelector() {
        Document document = query.where(title.ne("")).load(new MapFieldSelector("title")).list().get(0);
        assertNotNull(document.get("title"));
        assertNull(document.get("year"));
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.document.MapFieldSelector

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.