Menu

benchLucene / Blog: Recent posts

New version coming soon

We will be releasing a new version soon.

Posted by Dovestech 2011-10-01

benchMethod

public static double bench(String dir, String field)
{
    double queryLength = 0;
    String search = UUID.randomUUID().toString();
    double startQuery = System.currentTimeMillis();
    try
    {
        File file = new File(dir);
        FSDirectory directory = FSDirectory.open(file);
        IndexSearcher isearcher = new IndexSearcher(directory, true);
        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31);
        ScoreDoc[] hits;
        MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_31, new String[] {field}, analyzer);
        Query query = parser.parse(search);
        hits = isearcher.search(query, 2000000).scoreDocs;
        queryLength = System.currentTimeMillis() - startQuery;
        queryLength = queryLength / 1000;
        isearcher.close();
        directory.close();
    }
    catch (Exception e)
    {
        System.err.println(e);
    }
    return queryLength;
}
Posted by Dovestech 2011-08-25
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.