use of com.google.appengine.api.search.ScoredDocument in project blogwt by billy1380.
the class PageService method search.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.server.service.search.ISearch#search(java.lang.
* String, java.lang.Integer, java.lang.Integer, java.lang.String,
* com.willshex.blogwt.shared.api.SortDirectionType) */
@Override
public List<Page> search(String query, Integer start, Integer count, String sortBy, SortDirectionType direction) {
Results<ScoredDocument> matches = SearchHelper.getIndex().search(query);
List<Page> pages = new ArrayList<Page>();
String id;
Page page;
int limit = count;
final String pageServiceName = getName();
for (ScoredDocument scoredDocument : matches) {
if (limit == 0) {
break;
}
if ((id = scoredDocument.getId()).startsWith(getName())) {
page = getPage(Long.valueOf(id.replace(pageServiceName, "")));
if (page != null) {
pages.add(page);
}
}
limit--;
}
return pages;
}
use of com.google.appengine.api.search.ScoredDocument in project blogwt by billy1380.
the class UserService method search.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.server.service.search.ISearch#search(java.lang.
* String, java.lang.Integer, java.lang.Integer, java.lang.String,
* com.willshex.blogwt.shared.api.SortDirectionType) */
@Override
public List<User> search(String query, Integer start, Integer count, String sortBy, SortDirectionType direction) {
Results<ScoredDocument> matches = SearchHelper.getIndex().search(query);
List<User> users = new ArrayList<User>();
String id;
User user;
int limit = count;
final String userServiceName = getName();
for (ScoredDocument scoredDocument : matches) {
if (limit == 0) {
break;
}
if ((id = scoredDocument.getId()).startsWith(userServiceName)) {
user = getUser(Long.valueOf(id.replace(userServiceName, "")));
if (user != null) {
users.add(user);
}
}
limit--;
}
return users;
}
Aggregations