Indexes document in file system using lucene.

@param metadata
the metadata
@param document
the document
482540
public void indexDocument(EntityMetadata metadata, Document document)
    {
        if (log.isDebugEnabled())
        {
            log.debug("Indexing document: {} for in file system using Lucene", document);
        }

        IndexWriter w = getIndexWriter();
        try
        {
            w.addDocument(document);
        }
        catch (Exception e)
        {
            log.error("Error while indexing document {} into Lucene, Caused by:{} ", document, e);
            throw new LuceneIndexingException("Error while indexing document " + document + " into Lucene.", e);
        }
    }
12219
public void addDocument(Document doc) throws IOException {
		// needs to differenciate SimpleDocuments from MultiField ones
		// each class has its own way of serializing
		String serial = doc.getStringSerialization();
		raw_file_buffer.write(serial);
	}
469547
private void addSuperColumnNameToDocument(String superColumnName, Document currentDoc) {
        Field luceneField = new Field(SUPERCOLUMN_INDEX, superColumnName, Store.YES, Field.Index.NO);
        currentDoc.add(luceneField);
    }
1289036
@Override
    public void beginMetaData(MetaData metadata)
    {
        for (Listener listener : this.listeners) {
            listener.beginMetaData(metadata);
        }
    }
1031498
public function index($document, $overwrite = null, $commitWithin = null, $buffer = 1500)
	{
		$this->initBufferAdd($overwrite, $commitWithin, $buffer);
		$this->addDocument($document);
	}
1306795
private void addNodeIndex(EntityMetadata entityMetadata, Node node, Index<Node> nodeIndex, MetamodelImpl metaModel)
    {
//        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
//                entityMetadata.getPersistenceUnit());

        // ID attribute has to be indexed necessarily
        String idColumnName = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();
        nodeIndex.add(node, idColumnName, node.getProperty(idColumnName));

        // Index all other fields, for whom indexing is enabled
        for (Attribute attribute : metaModel.entity(entityMetadata.getEntityClazz()).getSingularAttributes())
        {
            Field field = (Field) attribute.getJavaMember();
            if (!attribute.isCollection() && !attribute.isAssociation()
                    && entityMetadata.getIndexProperties().keySet().contains(field.getName()))
            {
                String columnName = ((AbstractAttribute) attribute).getJPAColumnName();
                nodeIndex.add(node, columnName, node.getProperty(columnName));
            }
        }
    }
1337364
public final void remove(EntityMetadata metadata, Object entity, Object key)
    {
        if (indexer != null)
        {
            if (indexer.getClass().getName().equals(IndexingConstants.LUCENE_INDEXER))
            {
                ((com.impetus.kundera.index.lucene.Indexer) indexer).unindex(metadata, key, kunderaMetadata, null);
            }
            else
            {
                indexer.unIndex(metadata.getEntityClazz(), entity, metadata, (MetamodelImpl) kunderaMetadata
                        .getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit()));
            }
        }
    }
380956
def setdocument(self, doc):
        
        assert isinstance(doc, Document)

        if not self.doc:
            self.doc = doc
            if self.id:
                if self.id in doc:
                    raise DuplicateIDError(self.id)
                else:
                    self.doc.index[id] = self

        for e in self: #recursive for all children
            if isinstance(e,AbstractElement): e.setdocument(doc)
782110
public static void addAll(Document document) {
        List<Element> elementList = getElements(document);

        List<String> elementIds = getElementsId(elementList);

        addAll(elementList);
    }
1163126
protected function addToDocument($document)
    {
        parent::addToDocument($document);

        $this->getRangeKey()->getPropertyMetadata()->setValue(
            $document,
            $this->getRangeValue()
        );
    }
508357
public void processDocument(BufferedReader document) throws IOException {
        if (wordToTransformedVector != null) {
            throw new IllegalStateException("Cannot add new documents to a " +
                "GenericWordSpace whose vectors have been transformed");
        }

        Queue<String> prevWords = new ArrayDeque<String>(windowSize);
        Queue<String> nextWords = new ArrayDeque<String>(windowSize);

        Iterator<String> documentTokens = 
            IteratorFactory.tokenizeOrdered(document);

        String focusWord = null;

        // prefetch the first windowSize words 
        for (int i = 0; i < windowSize && documentTokens.hasNext(); ++i)
            nextWords.offer(documentTokens.next());
        
        while (!nextWords.isEmpty()) {
            focusWord = nextWords.remove();

            // shift over the window to the next word
            if (documentTokens.hasNext()) {
                String windowEdge = documentTokens.next(); 
                nextWords.offer(windowEdge);
            }    

            // If we are filtering the semantic vectors, check whether this word
            // should have its semantics calculated.  In addition, if there is a
            // filter and it would have excluded the word, do not keep its
            // semantics around
            boolean calculateSemantics =
                (semanticFilter.isEmpty() || semanticFilter.contains(focusWord))
                && !focusWord.equals(IteratorFactory.EMPTY_TOKEN);
            
            if (calculateSemantics) {
                SparseIntegerVector focusSemantics = 
                    getSemanticVector(focusWord);

                // Keep track of the relative position of the focus word in case
                // word ordering is being used.
                int position = -prevWords.size(); // first word is furthest
                for (String word : prevWords) {
                    // Skip the addition of any words that are excluded from the
                    // filter set.  Note that by doing the exclusion here, we
                    // ensure that the token stream maintains its existing
                    // ordering, which is necessary when word order is taken
                    // into account.
                    if (word.equals(IteratorFactory.EMPTY_TOKEN)) {
                        position++;
                        continue;
                    }
                    
                    int dimension = basisMapping.getDimension(
                        new Duple<String,Integer>(word, position));
                    synchronized(focusSemantics) {
                        focusSemantics.add(dimension, 1);
                    }
                    position++;
                }
            
                // Repeat for the words in the forward window.
                position = 1;
                for (String word : nextWords) {
                    // Skip the addition of any words that are excluded from the
                    // filter set.  Note that by doing the exclusion here, we
                    // ensure that the token stream maintains its existing
                    // ordering, which is necessary when word order is taken
                    // into account.
                    if (word.equals(IteratorFactory.EMPTY_TOKEN)) {
                        ++position;
                        continue;
                    }
                
                    int dimension = basisMapping.getDimension(
                        new Duple<String,Integer>(word, position));
                    synchronized(focusSemantics) {
                        focusSemantics.add(dimension, 1);
                    }
                    position++;
                }
            }

            // Last put this focus word in the prev words and shift off the
            // front of the previous word window if it now contains more words
            // than the maximum window size
            prevWords.offer(focusWord);
            if (prevWords.size() > windowSize) {
                prevWords.remove();
            }
        }    

        document.close();
    }
59070
public function addDocument(Zend_Search_Lucene_Document $document)
    {
        if ($this->_documentDistributorCallBack !== null) {
            $index = call_user_func($this->_documentDistributorCallBack, $document, $this->_indices);
        } else {
            $index = $this->_indices[array_rand($this->_indices)];
        }

        $index->addDocument($document);
    }
514421
private function addDocumentToIndex($doc, MetaInformationInterface $metaInformation, Event $event)
    {
        try {
            $indexName = $metaInformation->getIndex();

            $client = new SolariumMulticoreClient($this->solrClientCore);
            $client->update($doc, $indexName);

        } catch (\Exception $e) {
            $errorEvent = new ErrorEvent(null, $metaInformation, json_encode($this->solrClientCore->getOptions()), $event);
            $errorEvent->setException($e);

            $this->eventManager->dispatch(Events::ERROR, $errorEvent);

            throw new SolrException($e->getMessage(), $e->getCode(), $e);
        }
    }
891136
public void add(DOCUMENT doc) {
      if (doc != null) {
         documents.add(doc);
         int id = documents.size() - 1;
         for (KEY key : documentMapper.apply(doc)) {
            index.put(key, id);
         }
      }
   }
688823
public void read(final URI filename, final Document doc) {
        currentFile = filename;
        rootScope = null;
        // TODO: use KeyScope implementation that retains order
        KeyScope keyScope = readScopes(doc);
        keyScope = cascadeChildKeys(keyScope);
        // TODO: determine effective key definitions here
        keyScope = inheritParentKeys(keyScope);
        rootScope = resolveIntermediate(keyScope);
    }
573642
void addDocuments(final Document[] docs) throws IOException
   {
      final IndexWriter writer = getIndexWriter();

      IOException ioExc = null;
      try
      {
         for (Document doc : docs)
         {
            try
            {
               writer.addDocument(doc);
            }
            catch (Throwable e) //NOSONAR
            {
               if (ioExc == null)
               {
                  if (e instanceof IOException)
                  {
                     ioExc = (IOException)e;
                  }
                  else
                  {
                     ioExc = Util.createIOException(e);
                  }
               }

               log.warn("Exception while inverting document", e);
            }
         }
      }
      finally
      {
         invalidateSharedReader();
      }

      if (ioExc != null)
      {
         throw ioExc;
      }
   }
780218
def setMetadata(doc, m):
    """"""
    if doc.isClosed or doc.isEncrypted:
        raise ValueError("operation on closed or encrypted document")
    if type(m) is not dict:
        raise ValueError("arg2 must be a dictionary")
    for k in m.keys():
        if not k in ("author", "producer", "creator", "title", "format",
                     "encryption", "creationDate", "modDate", "subject",
                     "keywords"):
            raise ValueError("invalid dictionary key: " + k)
    d = "<</Author"
    d += getPDFstr(m.get("author", "none"))
    d += "/CreationDate"
    d += getPDFstr(m.get("creationDate", "none"))
    d += "/Creator"
    d += getPDFstr(m.get("creator", "none"))
    d += "/Keywords"
    d += getPDFstr(m.get("keywords", "none"))
    d += "/ModDate"
    d += getPDFstr(m.get("modDate", "none"))
    d += "/Producer"
    d += getPDFstr(m.get("producer", "none"))
    d += "/Subject"
    d += getPDFstr(m.get("subject", "none"))
    d += "/Title"
    d += getPDFstr(m.get("title", "none"))
    d += ">>"
    doc._setMetadata(d)
    doc.initData()
    return