Пример #1
0
  public void testSearch() throws IOException {
    int docNumber = 1;
    MetricSpacesInvertedListIndexing ms = MetricSpacesInvertedListIndexing.getDefaultInstance();
    MetricSpacesInvertedListIndexing.numReferenceObjectsUsed = 10;
    MetricSpacesInvertedListIndexing.numReferenceObjects = 50;
    IndexReader reader = ms.getIndexReader(indexPath);
    TopDocs docs = ms.search(reader.document(docNumber), indexPath);

    // print the results
    BufferedWriter bw = new BufferedWriter(new FileWriter("out.html"));
    bw.write("<html><body>");
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      ScoreDoc scoreDoc = docs.scoreDocs[i];
      bw.write(
          "<img title=\"ID: "
              + scoreDoc.doc
              + ", "
              + "Score: "
              + scoreDoc.score
              + "\" src=\"file:///"
              + reader.document(scoreDoc.doc).getValues("descriptorImageIdentifier")[0]
              + "\"> ");
    }
    bw.write("</body></html>");
    bw.close();
    showUrl("out.html");
  }
Пример #2
0
  public void testMetrics() throws IOException {
    String smallIdx = "wang-cedd";
    MetricSpacesInvertedListIndexing ms = MetricSpacesInvertedListIndexing.getDefaultInstance();
    MetricSpacesInvertedListIndexing.numReferenceObjectsUsed = 10;
    MetricSpacesInvertedListIndexing.numReferenceObjects = 50;

    TopDocs docs = ms.search(ImageIO.read(new FileInputStream("wang-data-1000/10.jpg")), smallIdx);
    IndexReader ir = IndexReader.open(FSDirectory.open(new File(smallIdx)));
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      ScoreDoc scoreDoc = docs.scoreDocs[i];
      String identifier =
          ir.document(scoreDoc.doc).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0];
      System.out.println(scoreDoc.score + ": " + identifier + " \t(" + scoreDoc.doc + ")");
    }
  }
Пример #3
0
  public void testPerformance() throws IOException {
    MetricSpacesInvertedListIndexing mes = MetricSpacesInvertedListIndexing.getDefaultInstance();
    int numSearches = 10;
    IndexReader reader = mes.getIndexReader(indexPath);
    System.out.println(reader.maxDoc() + " documents");
    TopDocs docs;

    long ms = System.currentTimeMillis();
    for (int i = 0; i < numSearches; i++) {
      docs = mes.search(reader.document(i), indexPath);
    }
    ms = System.currentTimeMillis() - ms;
    System.out.println("ms = " + ms);

    ImageSearcher ceddSearcher = ImageSearcherFactory.createCEDDImageSearcher(100);
    ms = System.currentTimeMillis();
    for (int i = 0; i < numSearches; i++) {
      ceddSearcher.search(reader.document(i), reader);
    }
    ms = System.currentTimeMillis() - ms;
    System.out.println("ms = " + ms);
  }