Package org.apache.lucene.index

Examples of org.apache.lucene.index.TermDocs


   * @param searchCRID crid.
   * @return document.
   */
  private Document getUniqueDocument(final IndexReader indexReader, final Term idTerm, final String searchCRID) {
    try {
      TermDocs docs = indexReader.termDocs(idTerm);
      while (docs.next()) {
        Document doc = indexReader.document(docs.doc());
        String crID = doc.get(CR_FIELD_KEY);
        if (crID != null && crID.equals(searchCRID)) {
          return doc;
        }
      }
View Full Code Here


    indexAccessor = indexLocation.getAccessor();
    IndexReader reader = null;
    try {
      reader = indexAccessor.getReader(true);

      TermDocs termDocs = reader.termDocs(new Term(termKey, termValue));
      log.debug("Fetching sorted documents from index...");
      docs = fetchSortedDocs(termDocs, reader, idAttribute);
      log.debug("Fetched sorted docs from index");
      docIT = docs.keySet().iterator();
View Full Code Here

        super(delegatee);
        this.cache = cache;
        this.inSegmentParents = new int[delegatee.maxDoc()];
        Arrays.fill(this.inSegmentParents, -1);
        this.shareableNodes = new BitSet();
        TermDocs tDocs = delegatee.termDocs(
                new Term(FieldNames.SHAREABLE_NODE, ""));
        try {
            while (tDocs.next()) {
                shareableNodes.set(tDocs.doc());
            }
        } finally {
            tDocs.close();
        }
        this.cacheInitializer = new CacheInitializer(delegatee);
        if (initCache) {
            cacheInitializer.run();
        }
View Full Code Here

                if (shareableNodes.get(n)) {
                    parent = DocId.create(parentUUIDs);
                } else {
                    if (!existing) {
                        Term id = new Term(FieldNames.UUID, parentUUIDs[0]);
                        TermDocs docs = termDocs(id);
                        try {
                            while (docs.next()) {
                                if (!deleted.get(docs.doc())) {
                                    plainDocId = docs.doc();
                                    parent = DocId.create(plainDocId);
                                    break;
                                }
                            }
                        } finally {
                            docs.close();
                        }
                    }
                    // if still null, then parent is not in this index, or existing
                    // DocId was invalid. thus, only allowed to create DocId from uuid
                    if (parent == null) {
View Full Code Here

                        return new SingleTermDocs(e.doc);
                    }
                }

                // not in cache or invalid
                TermDocs docs = in.termDocs(term);
                try {
                    if (docs.next()) {
                        // put to cache
                        cache.put(term.text(), this, docs.doc());
                        // and return
                        return new SingleTermDocs(docs.doc());
                    } else {
                        return EmptyTermDocs.INSTANCE;
                    }
                } finally {
                    docs.close();
                }
            }
        }
        return termDocsCache.termDocs(term);
    }
View Full Code Here

         */
        private void collectTermDocs(IndexReader reader,
                                     Term start,
                                     TermDocsCollector collector)
                throws IOException {
            TermDocs tDocs = reader.termDocs();
            try {
                TermEnum terms = reader.terms(start);
                try {
                    int count = 0;
                    do {
                        Term t = terms.term();
                        if (t != null && t.field() == start.field()) {
                            tDocs.seek(terms);
                            collector.collect(t, tDocs);
                        } else {
                            break;
                        }
                        // once in a while check if we should quit
                        if (++count % 10000 == 0) {
                            if (stopRequested) {
                                break;
                            }
                        }
                    } while (terms.next());
                } finally {
                    terms.close();
                }
            } finally {
                tDocs.close();
            }
        }
View Full Code Here

            try {
                CachingMultiIndexReader reader = index.getIndexReader();
                try {
                    Term aggregateIds =
                        new Term(FieldNames.AGGREGATED_NODE_UUID, "");
                    TermDocs tDocs = reader.termDocs();
                    try {
                        ItemStateManager ism = getContext().getItemStateManager();
                        for (NodeId id : removedIds) {
                            aggregateIds =
                                aggregateIds.createTerm(id.toString());
                            tDocs.seek(aggregateIds);
                            while (tDocs.next()) {
                                Document doc = reader.document(
                                        tDocs.doc(), FieldSelectors.UUID);
                                NodeId nId = new NodeId(doc.get(FieldNames.UUID));
                                map.put(nId, (NodeState) ism.getItemState(nId));
                                found++;
                            }
                        }
                    } finally {
                        tDocs.close();
                    }
                } finally {
                    reader.release();
                }
            } catch (Exception e) {
View Full Code Here

            throws IOException {
        IndexReader reader = index.getIndexReader();
        try {
            checkRewritten(reader);
            Term idTerm = new Term(FieldNames.UUID, id.toString());
            TermDocs tDocs = reader.termDocs(idTerm);
            int docNumber;
            Document doc;
            try {
                if (tDocs.next()) {
                    docNumber = tDocs.doc();
                    doc = reader.document(docNumber);
                } else {
                    // node not found in index
                    return null;
                }
            } finally {
                tDocs.close();
            }
            Fieldable[] fields = doc.getFieldables(FieldNames.FULLTEXT);
            if (fields.length == 0) {
                log.debug("Fulltext field not stored, using {}",
                        SimpleExcerptProvider.class.getName());
View Full Code Here

                        entries = state.getChildNodeEntries();
                    }
                    for (ChildNodeEntry entry : entries) {
                        NodeId childId = entry.getId();
                        Term uuidTerm = TermFactory.createUUIDTerm(childId.toString());
                        TermDocs docs = reader.termDocs(uuidTerm);
                        try {
                            if (docs.next()) {
                                childrenHits.set(docs.doc());
                            }
                        } finally {
                            docs.close();
                        }
                    }
                } catch (ItemStateException e) {
                    // does not exist anymore -> ignore
                }
View Full Code Here

                    public void collect(int doc, float score) {
                        subQueryHits.set(doc);
                    }
                });

                TermDocs termDocs = reader.termDocs(new Term(FieldNames.PROPERTIES_SET, refProperty));
                String prefix = FieldNames.createNamedValue(refProperty, "");
                while (termDocs.next()) {
                    int doc = termDocs.doc();
                    
                    String[] values = reader.document(doc).getValues(FieldNames.PROPERTIES);
                    if (values == null) {
                        // no reference properties at all on this node
                        continue;
                    }
                    for (int v = 0; v < values.length; v++) {
                        if (values[v].startsWith(prefix)) {
                            String uuid = values[v].substring(prefix.length());
                           
                            TermDocs node = reader.termDocs(TermFactory.createUUIDTerm(uuid));
                            try {
                                while (node.next()) {
                                    if (subQueryHits.get(node.doc())) {
                                        hits.set(doc);
                                    }
                                }
                            } finally {
                                node.close();
                            }
                        }
                    }
                }
               
View Full Code Here

TOP

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

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.