public boolean merge() throws FileNotFoundException, IOException {
		
		//Select your favourate Jersey No to assign it to the final Index. :)
		//Ok we need similarity and we reuse indexreaders for merging so using the same constructor.
		int fileNumber = 2;
		
		//Modify here to expand for a distributed index structure.
		//Distributed index, would give you the advantage of higher throughput.
		File folder = new File(outputDirectory, "FinalIndex");
		folder.mkdir();
		outputDirectory = folder.getAbsolutePath();
		File outputFile = new File(outputDirectory,String.valueOf(fileNumber));
		BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(outputFile));
		ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(new File(outputDirectory+"Lexicon")));
		int currentFileOffset = 0;
		
		List<Integer> docVector = new LinkedList<Integer>();
		List<Integer> freqVector = new LinkedList<Integer>();
		//List<Integer> offsetVector = new LinkedList<Integer>();
		//List<Integer> contextVector = new LinkedList<Integer>();
		
		// Iterate for all terms discussed in lexicon
		for (Integer termID : inputLexicon.keySet()) {
			System.out.println("Now Merging for term :"+termID);
			List<BlockInfo> list = inputLexicon.get(termID);
			PriorityQueue<WrapperIndexEntry> pQueue = new PriorityQueue<WrapperIndexEntry>(
					list.size(), new Comparator<WrapperIndexEntry>() {

						@Override
						public int compare(WrapperIndexEntry o1, WrapperIndexEntry o2) {
							if(o1.getDocID(o1.getCurrentPosition())==o2.getDocID(o2.getCurrentPosition()))
								return 0;
							return( ( (o1.getDocID(o1.getCurrentPosition())-o2.getDocID(o2.getCurrentPosition())) )>0)?1:-1;
							
						}
					});
			int i=0;
			for(BlockInfo blockInfo:list){
				WrapperIndexEntry indexEntry = new WrapperIndexEntry(readerMap.get(blockInfo.getFileNumber()).openList(termID));
				pQueue.add(indexEntry);
				if(pQueue.size()>=2)
					pQueue.remove();
				i++;
				
			}
			
			while(!pQueue.isEmpty()){
				
				WrapperIndexEntry indexEntry = pQueue.poll();
					docVector.add(WrapperIndexEntry.currentDoc(indexEntry));
					freqVector.add(WrapperIndexEntry.currentFrequency(indexEntry));
					//offsetVector.addAll(WrapperIndexEntry.currentOffsets(indexEntry));
					//contextVector.addAll(WrapperIndexEntry.currentContexts(indexEntry));
					
					//If there is another docid in indexentry, we add the the indexentry back into the pQueue
					// Notice the fact that now the lastDocChecked has incremented and hence, would the values for docId as well
					// This helps us find the lowest docIds from a list of IndexEntries, and then we continue th process till we have pQueue emptied up
					
					
					if(WrapperIndexEntry.incrIndex(indexEntry))
						pQueue.add(indexEntry);
			}
			
			//Now we write the vectors to a block and store the info back into the lexicon.
			//The merging is complete for a term, now we flush it and update lexicon :)
			//System.out.println("Royal Flush *****************"+docVector.size());
			currentFileOffset = PostingWriter.writePosting(termID, docVector, freqVector, stream, currentFileOffset, fileNumber, outputLexicon);
			
		}
		
		objectOutputStream.writeObject(outputLexicon);
		objectOutputStream.close();
		stream.close();
		System.gc();
		return true;
	}