当前位置: 首页>>代码示例>>Java>>正文


Java SearchResult类代码示例

本文整理汇总了Java中com.gitblit.models.SearchResult的典型用法代码示例。如果您正苦于以下问题:Java SearchResult类的具体用法?Java SearchResult怎么用?Java SearchResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SearchResult类属于com.gitblit.models包,在下文中一共展示了SearchResult类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSearchResult

import com.gitblit.models.SearchResult; //导入依赖的package包/类
private SearchResult createSearchResult(Document doc, float score, int hitId, int totalHits) throws ParseException {
	SearchResult result = new SearchResult();
	result.hitId = hitId;
	result.totalHits = totalHits;
	result.score = score;
	result.date = DateTools.stringToDate(doc.get(FIELD_DATE));
	result.summary = doc.get(FIELD_SUMMARY);
	result.author = doc.get(FIELD_AUTHOR);
	result.committer = doc.get(FIELD_COMMITTER);
	result.type = SearchObjectType.fromName(doc.get(FIELD_OBJECT_TYPE));
	result.branch = doc.get(FIELD_BRANCH);
	result.commitId = doc.get(FIELD_COMMIT);
	result.path = doc.get(FIELD_PATH);
	if (doc.get(FIELD_TAG) != null) {
		result.tags = StringUtils.getStringsFromValue(doc.get(FIELD_TAG));
	}
	return result;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:19,代码来源:LuceneService.java

示例2: createSearchResult

import com.gitblit.models.SearchResult; //导入依赖的package包/类
private SearchResult createSearchResult(Document doc, float score, int hitId, int totalHits) throws ParseException {
	SearchResult result = new SearchResult();
	result.hitId = hitId;
	result.totalHits = totalHits;
	result.score = score;
	result.date = DateTools.stringToDate(doc.get(FIELD_DATE));
	result.summary = doc.get(FIELD_SUMMARY);		
	result.author = doc.get(FIELD_AUTHOR);
	result.committer = doc.get(FIELD_COMMITTER);
	result.type = SearchObjectType.fromName(doc.get(FIELD_OBJECT_TYPE));
	result.branch = doc.get(FIELD_BRANCH);
	result.commitId = doc.get(FIELD_COMMIT);
	result.issueId = doc.get(FIELD_ISSUE);
	result.path = doc.get(FIELD_PATH);
	if (doc.get(FIELD_TAG) != null) {
		result.tags = StringUtils.getStringsFromValue(doc.get(FIELD_TAG));
	}
	if (doc.get(FIELD_LABEL) != null) {
		result.labels = StringUtils.getStringsFromValue(doc.get(FIELD_LABEL));
	}
	return result;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:23,代码来源:LuceneExecutor.java

示例3: testMultiSearch

import com.gitblit.models.SearchResult; //导入依赖的package包/类
@Test
public void testMultiSearch() throws Exception {
	LuceneExecutor lucene = newLuceneExecutor();
	List<String> list = new ArrayList<String>();
	Repository repository = GitBlitSuite.getHelloworldRepository();
	list.add(newRepositoryModel(repository).name);
	repository.close();

	repository = GitBlitSuite.getJGitRepository();
	list.add(newRepositoryModel(repository).name);
	repository.close();

	List<SearchResult> results = lucene.search("test", 1, 10, list);
	lucene.close();
	assertEquals(10, results.size());
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:17,代码来源:LuceneExecutorTest.java

示例4: testIndex

import com.gitblit.models.SearchResult; //导入依赖的package包/类
@Test
public void testIndex() throws Exception {
	LuceneExecutor lucene = newLuceneExecutor();
	
	// reindex helloworld
	Repository repository = GitBlitSuite.getHelloworldRepository();
	RepositoryModel model = newRepositoryModel(repository);
	lucene.reindex(model, repository);
	repository.close();
	
	SearchResult result = lucene.search("type:blob AND path:bit.bit", 1, 1, model.name).get(0);		
	assertEquals("Mike Donaghy", result.author);
	result = lucene.search("type:blob AND path:clipper.prg", 1, 1, model.name).get(0);		
	assertEquals("tinogomes", result.author);		

	// reindex theoretical physics
	repository = GitBlitSuite.getTheoreticalPhysicsRepository();
	model = newRepositoryModel(repository);
	lucene.reindex(model, repository);
	repository.close();
	
	// reindex JGit
	repository = GitBlitSuite.getJGitRepository();
	model = newRepositoryModel(repository);
	lucene.reindex(model, repository);
	repository.close();
	
	lucene.close();
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:30,代码来源:LuceneExecutorTest.java

示例5: testQuery

import com.gitblit.models.SearchResult; //导入依赖的package包/类
@Test
public void testQuery() throws Exception {
	LuceneExecutor lucene = new LuceneExecutor(null, GitBlitSuite.REPOSITORIES);
	
	// 2 occurrences on the master branch
	Repository repository = GitBlitSuite.getHelloworldRepository();				
	RepositoryModel model = newRepositoryModel(repository);
	repository.close();
	
	List<SearchResult> results = lucene.search("ada", 1, 10, model.name);
	assertEquals(2, results.size());
	for (SearchResult res : results) {
		assertEquals("refs/heads/master", res.branch);
	}

	// author test
	results = lucene.search("author: tinogomes AND type:commit", 1, 10, model.name);
	assertEquals(2, results.size());
	
	// blob test
	results = lucene.search("type: blob AND \"import std.stdio\"", 1, 10, model.name);
	assertEquals(1, results.size());
	assertEquals("d.D", results.get(0).path);
	
	// 1 occurrence on the gh-pages branch
	repository = GitBlitSuite.getTheoreticalPhysicsRepository();
	model = newRepositoryModel(repository);
	repository.close();
	
	results = lucene.search("\"add the .nojekyll file\"", 1, 10, model.name);
	assertEquals(1, results.size());
	assertEquals("Ondrej Certik", results.get(0).author);
	assertEquals("2648c0c98f2101180715b4d432fc58d0e21a51d7", results.get(0).commitId);
	assertEquals("refs/heads/gh-pages", results.get(0).branch);
	
	results = lucene.search("type:blob AND \"src/intro.rst\"", 1, 10, model.name);
	assertEquals(4, results.size());
	
	// hash id tests
	results = lucene.search("commit:57c4f26f157ece24b02f4f10f5f68db1d2ce7ff5", 1, 10, model.name);
	assertEquals(1, results.size());

	results = lucene.search("commit:57c4f26f157*", 1, 10, model.name);
	assertEquals(1, results.size());		
	
	// annotated tag test
	repository = GitBlitSuite.getJGitRepository();
	model = newRepositoryModel(repository);
	repository.close();
	
	results = lucene.search("I663208919f297836a9c16bf458e4a43ffaca4c12", 1, 10, model.name);
	assertEquals(1, results.size());
	assertEquals("[v1.3.0.201202151440-r]", results.get(0).tags.toString());		
	
	lucene.close();
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:57,代码来源:LuceneExecutorTest.java

示例6: search

import com.gitblit.models.SearchResult; //导入依赖的package包/类
/**
 * Searches the specified repositories for the given text or query
 * 
 * @param text
 *            if the text is null or empty, null is returned
 * @param page
 *            the page number to retrieve. page is 1-indexed.
 * @param pageSize
 *            the number of elements to return for this page
 * @param repositories
 *            a list of repositories to search. if no repositories are specified null is returned.
 * @return a list of SearchResults in order from highest to the lowest score
 * 
 */
public List<SearchResult> search(String text, int page, int pageSize, List<String> repositories) {
	if (ArrayUtils.isEmpty(repositories)) {
		return null;
	}
	return search(text, page, pageSize, repositories.toArray(new String[0]));
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:21,代码来源:LuceneService.java

示例7: search

import com.gitblit.models.SearchResult; //导入依赖的package包/类
/**
 * Searches the specified repositories for the given text or query
 * 
 * @param text
 *            if the text is null or empty, null is returned
 * @param page
 *            the page number to retrieve. page is 1-indexed.
 * @param pageSize
 *            the number of elements to return for this page
 * @param repositories
 *            a list of repositories to search. if no repositories are
 *            specified null is returned.
 * @return a list of SearchResults in order from highest to the lowest score
 * 
 */
public List<SearchResult> search(String text, int page, int pageSize, List<String> repositories) {
	if (ArrayUtils.isEmpty(repositories)) {
		return null;
	}
	return search(text, page, pageSize, repositories.toArray(new String[0]));
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:22,代码来源:LuceneExecutor.java

示例8: search

import com.gitblit.models.SearchResult; //导入依赖的package包/类
/**
 * Search the specified repositories using the Lucene query.
 * 
 * @param query
 * @param page
 * @param pageSize
 * @param repositories
 * @return
 */
public List<SearchResult> search(String query, int page, int pageSize, List<String> repositories) {		
	List<SearchResult> srs = luceneExecutor.search(query, page, pageSize, repositories);
	return srs;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:14,代码来源:GitBlit.java


注:本文中的com.gitblit.models.SearchResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。