if (printDocid) sbuffer.append(doc.getDocid()); sbuffer.append(" ");
if (printDocid) sbuffer.append(doc.getDocid()); sbuffer.append(" ");
} else if (index == null && q instanceof Request) { final MetaIndex metaIndex = ((Request)q).getIndex().getMetaIndex(); docnos = metaIndex.getItems(metaIndexDocumentKey, results.stream().mapToInt(doc -> doc.getDocid()).toArray()); } else if (index != null) { docnos = index.getMetaIndex().getItems(metaIndexDocumentKey, results.stream().mapToInt(doc -> doc.getDocid()).toArray()); } else { throw new IllegalStateException("No source for " +metaIndexDocumentKey+ " found. Perhaps you need to set control decorate:on");
} else if (index == null && q instanceof Request) { final MetaIndex metaIndex = ((Request)q).getIndex().getMetaIndex(); docnos = metaIndex.getItems(metaIndexDocumentKey, results.stream().mapToInt(doc -> doc.getDocid()).toArray()); } else if (index != null) { docnos = index.getMetaIndex().getItems(metaIndexDocumentKey, results.stream().mapToInt(doc -> doc.getDocid()).toArray()); } else { throw new IllegalStateException("No source for " +metaIndexDocumentKey+ " found. Perhaps you need to set control decorate:on");
JSONObject result = new JSONObject(); result.put("rank", rank); result.put("docid", doc.getDocid()); result.put("score", doc.getScore()); for(String meta : metakeys)
JSONObject result = new JSONObject(); result.put("rank", rank); result.put("docid", doc.getDocid()); result.put("score", doc.getScore()); for(String meta : metakeys)
@Test public void testRequirementsFields() throws Exception { ApplicationSetup.setProperty("FieldTags.process", "title,content"); Index index = IndexTestUtils.makeIndexFields( new String[]{"doc1", "doc2"}, new String[]{ "<title>Animal</title><content>The quick brown fox jumps over the lazy dog</content>", //doc1 "<title>Dog</title><content>how much is that animal in the window</content>"}); //doc2 Manager m = new LocalManager(index); SearchRequest srq = null; //4, are documents retrieved: two terms, one of which is negative requirement srq = m.newSearchRequest("test1", "dog -title:Animal"); srq.setControl(SearchRequest.CONTROL_WMODEL, PL2.class.getName()); srq.setControl(SearchRequest.CONTROL_MATCHING, getMatchingClass().getName()); m.runSearchRequest(srq); //System.err.println(srq.getResultSet().getResultSize()); /*for (int i =0; i<srq.getResultSet().getDocids().length; i++) { System.err.println(" "+srq.getResultSet().getDocids()[i]+" "+srq.getResultSet().getScores()[i]); }*/ assertEquals(1, srq.getResults().size()); assertEquals(1, srq.getResults().get(0).getDocid()); }
@Test public void testOneDocumentTwoKeys() throws Exception { Index index = createIndexAbstract(); Manager m = new LocalManager(index); SearchRequest srq = m.newSearchRequest("test", "fox"); srq.setControl(SearchRequest.CONTROL_WMODEL, TF_IDF.class.getName()); m.runSearchRequest(srq); ResultSet rs = ((Request) srq).getResultSet(); assertEquals(1, rs.getResultSize()); SimpleDecorate decorate = new SimpleDecorate(); decorate.new_query(m, srq, rs); decorate.filter(m, srq, rs, 0, rs.getDocids()[0]); assertEquals(2, rs.getMetaKeys().length); assertEquals("doc1", rs.getMetaItems("filename")[0]); assertEquals("The quick brown fox jumps over the lazy dog", StringTools.escape(ESCAPE.JAVA, rs.getMetaItems("abstract")[0])); ScoredDocList res2 = srq.getResults(); assertEquals(1, res2.size()); ScoredDoc doc1 = res2.get(0); assertEquals(0, doc1.getDocid()); assertEquals("doc1", doc1.getMetadata("filename")); assertEquals("The quick brown fox jumps over the lazy dog", doc1.getMetadata("abstract")); }