List of usage examples for org.apache.lucene.index SegmentInfo getCodec
public Codec getCodec()
From source file:org.apache.solr.core.TestSimpleTextCodec.java
License:Apache License
public void test() throws Exception { SolrConfig config = h.getCore().getSolrConfig(); String codecFactory = config.get("codecFactory/@class"); assertEquals("Unexpected solrconfig codec factory", "solr.SimpleTextCodecFactory", codecFactory); assertEquals("Unexpected core codec", "SimpleText", h.getCore().getCodec().getName()); RefCounted<IndexWriter> writerRef = h.getCore().getSolrCoreState().getIndexWriter(h.getCore()); try {//from w w w . j av a 2 s .com IndexWriter writer = writerRef.get(); assertEquals("Unexpected codec in IndexWriter config", "SimpleText", writer.getConfig().getCodec().getName()); } finally { writerRef.decref(); } assertU(add(doc("id", "1", "text", "textual content goes here"))); assertU(commit()); RefCounted<SolrIndexSearcher> searcherRef = h.getCore().getSearcher(); try { SolrIndexSearcher searcher = searcherRef.get(); SegmentInfos infos = SegmentInfos.readLatestCommit(searcher.getIndexReader().directory()); SegmentInfo info = infos.info(infos.size() - 1).info; assertEquals("Unexpected segment codec", "SimpleText", info.getCodec().getName()); } finally { searcherRef.decref(); } assertQ(req("q", "id:1"), "*[count(//doc)=1]"); }