本文整理汇总了Java中org.apache.solr.client.solrj.response.FacetField.Count.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java Count.getCount方法的具体用法?Java Count.getCount怎么用?Java Count.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.response.FacetField.Count
的用法示例。
在下文中一共展示了Count.getCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSets
import org.apache.solr.client.solrj.response.FacetField.Count; //导入方法依赖的package包/类
/**
* Creates a list with all available values for the given field (minus any blacklisted values).
*
* @return
* @throws SolrServerException
* @should return all values
*/
public List<String> getSets(String field) throws SolrServerException {
List<String> ret = new ArrayList<>();
SolrQuery query = new SolrQuery();
query.setQuery(field + ":* " + DataManager.getInstance().getConfiguration().getCollectionBlacklistFilterSuffix());
query.setStart(0);
query.setRows(0);
query.addFacetField(field);
logger.trace("Set query: {}", query.getQuery());
QueryResponse resp = server.query(query);
FacetField facetField = resp.getFacetField(field);
if (facetField != null) {
for (Count count : facetField.getValues()) {
if (count.getCount() == 0) {
continue;
}
ret.add(count.getName());
}
}
Collections.sort(ret);
logger.trace("{} terms found for {}", ret.size(), field);
return ret;
}
示例2: matches
import org.apache.solr.client.solrj.response.FacetField.Count; //导入方法依赖的package包/类
/**
*
* @param count count (name + count) to check
* @param converter optional converter to apply to value before comparison
* @return true IFF the {@link Count#getCount() } is more than {@link #getMinimalOccurence()
* } {@link Count#getName() } contains {@link #getName() } (case
* insensitive)
*/
@Override
public boolean matches(Count count, IConverter<String> converter) {
if (count.getCount() >= minimalOccurence) {
if (namePattern == null) {
// no pattern to compare to, always matches
return true;
} else {
// convert value if converter is provided
final String value;
if (converter == null) {
value = count.getName();
} else {
value = converter.convertToString(count.getName(), null);
}
return namePattern.matcher(value).find();
}
} else {
// too few occurences, no match
return false;
}
}
示例3: extractAvailableFilters
import org.apache.solr.client.solrj.response.FacetField.Count; //导入方法依赖的package包/类
private Map<String, FacetList> extractAvailableFilters(QueryResponse response) {
Map<String, FacetList> facets = new HashMap<String, FacetList>();
if (response.getFacetFields() != null) {
for (FacetField ff : response.getFacetFields()) {
String field = ff.getName();
List<Facet> facetList = new ArrayList<Facet>(ff.getValueCount());
for (Count c : ff.getValues()) {
if (c.getCount() > 0) {
Facet f = new Facet(ff.getName(), c.getName(), c.getCount());
facetList.add(f);
}
}
facets.put(ff.getName(), new FacetList(field, getFacetLabel(field), facetList));
}
}
return facets;
}
示例4: getReviewingUsers
import org.apache.solr.client.solrj.response.FacetField.Count; //导入方法依赖的package包/类
public static List<String> getReviewingUsers(ReviewService reviewService) {
ModifiableSolrParams solrParams = new ModifiableSolrParams();
QueryResponse response = null;
String queryString = "*:*";
solrParams.set("q", queryString);
solrParams.set("facet", "true");
solrParams.set("facet.field", "user");
solrParams.set("facet.limit", -1);
solrParams.set("facet.mincount", 1);
try {
response = reviewService.getSolrServer().query(solrParams);
} catch (SolrServerException e) {
e.printStackTrace();
}
List<FacetField> facetFields = response.getFacetFields();
// get the first and only facet field -> users
FacetField userFacet = facetFields.get(0);
List<String> users = new ArrayList<String>();
for(Count c : userFacet.getValues()) {
// only cold start users
if (c.getCount() < 11) {
users.add(c.getName());
}
}
return users;
}
示例5: createQueryToFindProdLikedBySimilarUsers
import org.apache.solr.client.solrj.response.FacetField.Count; //导入方法依赖的package包/类
/**
* Step 2 in Collaborative Filtering using SOLR.
* <br/>
* Finds docs which are "liked" by the similar users in Step 1
* @param contentFilter
*/
public static String createQueryToFindProdLikedBySimilarUsers(
List<Count> userOccurences,
String currentUser,
ContentFilter contentFilter,
String usersFieldName,
int maxUserOccurence,
double weightDividor) {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append(usersFieldName + ":(");
if (weightDividor <= 0.0) {
queryBuilder.append("\"\")");
return queryBuilder.toString();
}
// max users
int userOccurenceCount = 0;
long maxUserCount = 0;
long userCountSum = 0;
for (Count userOccurence : userOccurences) {
if ( ! userOccurence.getName().equals(currentUser)) {
if (userOccurenceCount >= maxUserOccurence) {
break;
}
queryBuilder.append("\"" + userOccurence.getName() + "\"^" + (userOccurence.getCount() / weightDividor ) + " OR ");
if (userOccurence.getCount() > maxUserCount) {
maxUserCount = userOccurence.getCount();
}
userCountSum += userOccurence.getCount();
userOccurenceCount++;
}
}
if (contentFilter != null && contentFilter.getFriendsEvaluationMethod() != FriendsEvaluation.NOTHING) {
if (contentFilter.getCustomer() != null && contentFilter.getCustomer().getFriendOf() != null) {
for (String friend : contentFilter.getCustomer().getFriendOf()) {
if (contentFilter.getFriendsEvaluationMethod() == FriendsEvaluation.HIGH) {
queryBuilder.append("\"" + friend + "\"^" + maxUserCount + " OR ");
} else if (contentFilter.getFriendsEvaluationMethod() == FriendsEvaluation.AVERAGE) {
queryBuilder.append("\"" + friend + "\"^" + userCountSum / userOccurenceCount + " OR ");
} else if (contentFilter.getFriendsEvaluationMethod() == FriendsEvaluation.LOW) {
queryBuilder.append("\"" + friend + "\"^" + 1 + " OR ");
}
}
}
}
if (queryBuilder.length() > (usersFieldName + ":(").length()){
queryBuilder.replace(queryBuilder.length() - 3, queryBuilder.length(), "");
} else {
queryBuilder.append("\"\"");
}
queryBuilder.append(")");
return queryBuilder.toString();
}
示例6: createQueryToFindProdLikedBySimilarUsers
import org.apache.solr.client.solrj.response.FacetField.Count; //导入方法依赖的package包/类
/**
* Step 2 in Collaborative Filtering using SOLR.
* <br/>
* Finds docs which are "liked" by the similar users in Step 1
* @param contentFilter
*/
public static String createQueryToFindProdLikedBySimilarUsers(
final List<Count> userOccurences,
final String currentUser,
ContentFilter contentFilter,
String usersFieldName,
int maxUserOccurence,
final double weightDividor) {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append(usersFieldName + ":(");
if (weightDividor <= 0.0) {
queryBuilder.append("\"\")");
return queryBuilder.toString();
}
// max users
int userOccurenceCount = 0;
long maxUserCount = 0;
long userCountSum = 0;
Thread t = new Thread() {
@Override public void run() {
UserSimilarityTracker.getInstance().writeToFile("soc_market_rev", currentUser, userOccurences, weightDividor);
}
};
t.start();
for (Count userOccurence : userOccurences) {
if ( ! userOccurence.getName().equals(currentUser)) {
if (userOccurenceCount >= maxUserOccurence) {
break;
}
queryBuilder.append("\"" + userOccurence.getName() + "\"^" + (userOccurence.getCount() / weightDividor ) + " OR ");
if (userOccurence.getCount() > maxUserCount) {
maxUserCount = userOccurence.getCount();
}
userCountSum += userOccurence.getCount();
userOccurenceCount++;
}
}
if (contentFilter != null && contentFilter.getFriendsEvaluationMethod() != FriendsEvaluation.NOTHING) {
if (contentFilter.getCustomer() != null && contentFilter.getCustomer().getFriendOf() != null) {
for (String friend : contentFilter.getCustomer().getFriendOf()) {
if (contentFilter.getFriendsEvaluationMethod() == FriendsEvaluation.HIGH) {
queryBuilder.append("\"" + friend + "\"^" + maxUserCount + " OR ");
} else if (contentFilter.getFriendsEvaluationMethod() == FriendsEvaluation.AVERAGE) {
queryBuilder.append("\"" + friend + "\"^" + userCountSum / userOccurenceCount + " OR ");
} else if (contentFilter.getFriendsEvaluationMethod() == FriendsEvaluation.LOW) {
queryBuilder.append("\"" + friend + "\"^" + 1 + " OR ");
}
}
}
}
if (queryBuilder.length() > (usersFieldName + ":(").length()){
queryBuilder.replace(queryBuilder.length() - 3, queryBuilder.length(), "");
} else {
queryBuilder.append("\"\"");
}
queryBuilder.append(")");
return queryBuilder.toString();
}