Package org.apache.lucene.document

Examples of org.apache.lucene.document.FieldSelector


        for (int i = 0; i < bin.length; i++) {
          assertEquals(bin[i], data1[i + b1.getBinaryOffset()]);
        }
        Set lazyFields = new HashSet();
        lazyFields.add("bin1");
        FieldSelector sel = new SetBasedFieldSelector(new HashSet(), lazyFields);
        doc = reader.document(reader.maxDoc() - 1, sel);
        Fieldable[] fieldables = doc.getFieldables("bin1");
        assertNotNull(fieldables);
        assertEquals(1, fieldables.length);
        Fieldable fb1 = fieldables[0];
View Full Code Here


    if (mergeDocStores) {

      // for merging we don't want to compress/uncompress the data, so to tell the FieldsReader that we're
      // in  merge mode, we use this FieldSelector
      FieldSelector fieldSelectorMerge = new FieldSelector() {
          public FieldSelectorResult accept(String fieldName) {
            return FieldSelectorResult.LOAD_FOR_MERGE;
          }       
        };
View Full Code Here

        for (int i = 0; i < bin.length; i++) {
          assertEquals(bin[i], data1[i + b1.getBinaryOffset()]);
        }
        Set<String> lazyFields = new HashSet<String>();
        lazyFields.add("bin1");
        FieldSelector sel = new SetBasedFieldSelector(new HashSet<String>(), lazyFields);
        doc = reader.document(reader.maxDoc() - 1, sel);
        Fieldable[] fieldables = doc.getFieldables("bin1");
        assertNotNull(fieldables);
        assertEquals(1, fieldables.length);
        Fieldable fb1 = fieldables[0];
View Full Code Here

     * @return
     * @throws SearchException
     */
    public DBpediaResource getDBpediaResource(int docNo, String[] fieldsToLoad) throws SearchException {

        FieldSelector fieldSelector = new MapFieldSelector(fieldsToLoad);
        Document document = getDocument(docNo, fieldSelector);
        Field uriField = document.getField(LuceneManager.DBpediaResourceField.URI.toString());
        if (uriField==null)
            throw new SearchException("Cannot find URI for document "+document);

View Full Code Here

//        return resource;
//    }

    public SurfaceForm getSurfaceForm(int docNo) throws SearchException {
        String[] onlyUriAndTypes = {LuceneManager.DBpediaResourceField.SURFACE_FORM.toString()};
        FieldSelector fieldSelector = new MapFieldSelector(onlyUriAndTypes);
        Document document = getDocument(docNo,fieldSelector);
        Field sfField = document.getField(LuceneManager.DBpediaResourceField.SURFACE_FORM.toString());
        if (sfField==null)
            throw new SearchException("Cannot find SurfaceForm for document "+document);
View Full Code Here

     * @param res
     * @return
     * @throws SearchException
     */
    public int getSupport(DBpediaResource res) throws SearchException {
        FieldSelector fieldSelector = new MapFieldSelector(uriAndCount);
        int support = 0;

        //if (res.support()>0) return res.support(); //TODO what happens if value is already set?

        List<Document> uris = getDocuments(res, fieldSelector);
View Full Code Here

                                                String idField) throws IOException {
    int numDocs = reader.numDocs();

    OpenBitSet bitset = new OpenBitSet(numDocs);

    FieldSelector idFieldSelector =
        new SetBasedFieldSelector(Collections.singleton(idField), Collections.<String>emptySet());

    for (int i = 0; i < numDocs; i++) {
      String id;
      // Use Lucene's internal ID if idField is not specified. Else, get it from the document.
View Full Code Here

 
  public void testLoadSize() throws IOException {
    FieldsReader reader = new FieldsReader(dir, TEST_SEGMENT_NAME, fieldInfos);
    Document doc;
   
    doc = reader.doc(0, new FieldSelector(){
      public FieldSelectorResult accept(String fieldName) {
        if (fieldName.equals(DocHelper.TEXT_FIELD_1_KEY) ||
            fieldName.equals(DocHelper.LAZY_FIELD_BINARY_KEY))
          return FieldSelectorResult.SIZE;
        else if (fieldName.equals(DocHelper.TEXT_FIELD_3_KEY))
View Full Code Here

      }
     
      // check if field was decompressed after optimize
      for(int i=0; i<reader.maxDoc(); i++) {
        if (!reader.isDeleted(i)) {
          Document d = reader.document(i, new FieldSelector() {
            public FieldSelectorResult accept(String fieldName) {
              return ("compressed".equals(fieldName)) ? FieldSelectorResult.SIZE : FieldSelectorResult.LOAD;
            }
          });
          if (d.get("content3") != null) continue;
View Full Code Here

 
  public void testLoadSize() throws IOException {
    FieldsReader reader = new FieldsReader(dir, TEST_SEGMENT_NAME, fieldInfos);
    Document doc;
   
    doc = reader.doc(0, new FieldSelector(){
      public FieldSelectorResult accept(String fieldName) {
        if (fieldName.equals(DocHelper.TEXT_FIELD_1_KEY) ||
            fieldName.equals(DocHelper.LAZY_FIELD_BINARY_KEY))
          return FieldSelectorResult.SIZE;
        else if (fieldName.equals(DocHelper.TEXT_FIELD_3_KEY))
View Full Code Here

TOP

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

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.