Package org.apache.lucene.index

Examples of org.apache.lucene.index.TermDocs


               {
                  CachingMultiIndexReader reader = index.getIndexReader();
                  try
                  {
                     Term aggregateUUIDs = new Term(FieldNames.AGGREGATED_NODE_UUID, "");
                     TermDocs tDocs = reader.termDocs();
                     try
                     {
                        ItemDataConsumer ism = getContext().getItemStateManager();
                        for (Iterator<String> it = removedNodeIds.iterator(); it.hasNext();)
                        {
                           String id = it.next();
                           aggregateUUIDs = aggregateUUIDs.createTerm(id);
                           tDocs.seek(aggregateUUIDs);
                           while (tDocs.next())
                           {
                              Document doc = reader.document(tDocs.doc(), FieldSelectors.UUID);
                              String uuid = doc.get(FieldNames.UUID);
                              ItemData itd = ism.getItemData(uuid);
                              if (itd == null)
                              {
                                 continue;
                              }
                              if (!itd.isNode())
                              {
                                 throw new RepositoryException("Item with id:" + uuid + " is not a node");
                              }
                              map.put(uuid, (NodeData)itd);
                              found++;
                           }
                        }
                     }
                     finally
                     {
                        tDocs.close();
                     }
                  }
                  finally
                  {
                     reader.release();
View Full Code Here


                              }
                           }
                           // if indexReader exists (it is possible that no persisted indexes exists on start)
                           if (indexReader != null)
                           {
                              TermDocs termDocs = null;
                              try
                              {
                                 // reader from resisted index should be
                                 termDocs = indexReader.termDocs(new Term(FieldNames.UUID, uuid));
                                 // node should be indexed if not found in persistent index
                                 addDoc = !termDocs.next();
                              }
                              catch (Exception e)
                              {
                                 log.debug("Some exception occured, during index check");
                              }
                              finally
                              {
                                 if (termDocs != null)
                                    termDocs.close();
                              }
                           }
                        }

                        if (addDoc)
View Full Code Here

      IndexReader reader = index.getIndexReader();
      try
      {
         checkRewritten(reader);
         Term idTerm = new Term(FieldNames.UUID, id);
         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 == null)
         {
View Full Code Here

            // collect the doc ids of all target nodes. we reuse the existing
            // bitset.
            hits.clear();
            for (Iterator it = uuids.iterator(); it.hasNext();)
            {
               TermDocs node = reader.termDocs(new Term(FieldNames.UUID, (String)it.next()));
               try
               {
                  while (node.next())
                  {
                     hits.set(node.doc());
                  }
               }
               finally
               {
                  node.close();
               }
            }
            // filter out the target nodes that do not match the name test
            // if there is any name test at all.
            if (nameTestScorer != null)
View Full Code Here

         {
            // process node uuids one-by-one
            try
            {
               String uuid = node.getIdentifier();
               TermDocs docs = indexReader.termDocs(new Term(FieldNames.UUID, uuid));

               if (docs.next())
               {
                  indexedNodes.add(uuid);
                  docs.doc();
                  if (docs.next())
                  {
                     //multiple entries
                     report.logComment("Multiple entires.");
                     report.logBrokenObjectAndSetInconsistency("ID=" + uuid);
                  }
View Full Code Here

            Set sortedDocs = new TreeSet();
            try {
                while ((node = hits.nextScoreNode()) != null) {
                    String uuid = node.getNodeId();
                    Term id = new Term(FieldNames.UUID, uuid);
                    TermDocs tDocs = reader.termDocs(id);
                    try {
                        if (tDocs.next()) {
                            Integer doc = new Integer(tDocs.doc());
                            sortedDocs.add(doc);
                            scores.put(doc, new Float(node.getScore()));
                        }
                    } finally {
                        tDocs.close();
                    }
                }
            } finally {
                hits.close();
            }
View Full Code Here

            {
               if (nameTest != null && version.getVersion() >= IndexFormatVersion.V4.getVersion())
               {
                  StringBuilder path = new StringBuilder(256);
                  path.append(uuid == null ? "" : uuid).append('/').append(nameTest.getAsString());
                  TermDocs docs = reader.termDocs(new Term(FieldNames.PATH, path.toString()));
                  try
                  {
                     while (docs.next())
                     {
                        childrenHits.set(docs.doc());
                     }

                  }
                  finally
                  {
                     docs.close();
                  }
               }
               else
               {
                  long time = System.currentTimeMillis();
                  NodeData state = (NodeData)itemMgr.getItemData(uuid);
                  time = System.currentTimeMillis() - time;
                  LOG.debug("got NodeState with id {} in {} ms.", uuid, new Long(time));
                  Iterator<NodeData> entries;
                  if (nameTest != null)
                  {
                     List<NodeData> childs = itemMgr.getChildNodesData(state);

                     List<NodeData> datas = new ArrayList<NodeData>();
                     if (childs != null)
                     {
                        for (NodeData nodeData : childs)
                        {
                           if (nameTest.equals(nodeData.getQPath().getName()))
                              datas.add(nodeData);
                        }
                     }
                     entries = datas.iterator();
                  }
                  else
                  {
                     // get all children
                     entries = itemMgr.getChildNodesData(state).iterator();
                  }
                  while (entries.hasNext())
                  {
                     String childId = entries.next().getIdentifier();
                     Term uuidTerm = new Term(FieldNames.UUID, childId);
                     TermDocs docs = reader.termDocs(uuidTerm);
                     try
                     {
                        if (docs.next())
                        {
                           childrenHits.set(docs.doc());
                        }
                     }
                     finally
                     {
                        docs.close();
                     }
                  }
               }
            }
            catch (RepositoryException e)
View Full Code Here

         {
            // process node uuids one-by-one
            try
            {
               String uuid = node.getIdentifier();
               TermDocs docs = indexReader.termDocs(new Term(FieldNames.UUID, uuid));

               if (docs.next())
               {
                  indexedNodes.add(uuid);
                  docs.doc();
                  if (docs.next())
                  {
                     //multiple entries
                     report.logComment("Multiple entires.");
                     report.logBrokenObjectAndSetInconsistency("ID=" + uuid);
                  }
View Full Code Here

         {
            // process node uuids one-by-one
            try
            {
               String uuid = node.getIdentifier();
               TermDocs docs = indexReader.termDocs(new Term(FieldNames.UUID, uuid));

               if (docs.next())
               {
                  indexedNodes.add(uuid);
                  docs.doc();
                  if (docs.next())
                  {
                     //multiple entries
                     report.logComment("Multiple entires.");
                     report.logBrokenObjectAndSetInconsistency("ID=" + uuid);
                  }
View Full Code Here

               {
                  CachingMultiIndexReader reader = index.getIndexReader();
                  try
                  {
                     Term aggregateUUIDs = new Term(FieldNames.AGGREGATED_NODE_UUID, "");
                     TermDocs tDocs = reader.termDocs();
                     try
                     {
                        ItemDataConsumer ism = getContext().getItemStateManager();
                        for (Iterator<String> it = removedNodeIds.iterator(); it.hasNext();)
                        {
                           String id = it.next();
                           aggregateUUIDs = aggregateUUIDs.createTerm(id);
                           tDocs.seek(aggregateUUIDs);
                           while (tDocs.next())
                           {
                              Document doc = reader.document(tDocs.doc(), FieldSelectors.UUID);
                              String uuid = doc.get(FieldNames.UUID);
                              ItemData itd = ism.getItemData(uuid);
                              if (itd == null)
                              {
                                 continue;
                              }
                              if (!itd.isNode())
                              {
                                 throw new RepositoryException("Item with id:" + uuid + " is not a node");
                              }
                              map.put(uuid, (NodeData)itd);
                              found++;
                           }
                        }
                     }
                     finally
                     {
                        tDocs.close();
                     }
                  }
                  finally
                  {
                     reader.release();
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.