Here you can find the source of createOrderedQuery(String attributeName, List
public static String createOrderedQuery(String attributeName, List<String> ids)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static int MAX_SAME_PRODUCT_COUNT = 2900; /**/*from www . j a va 2 s .co m*/ * Step 1 in Collaborative Filtering using SOLR. * <br/> * Finds similar users who like the same document */ public static String createOrderedQuery(String attributeName, List<String> ids) { StringBuilder queryBuilder = new StringBuilder(); if (ids != null) { queryBuilder.append(attributeName + ":("); int productCounter = 0; int weight = ids.size(); for (String product : ids) { if (productCounter >= MAX_SAME_PRODUCT_COUNT) { break; } queryBuilder.append("\"" + product + "\"^" + weight + " OR "); productCounter++; weight--; } if (ids != null && ids.size() > 0) { queryBuilder.replace(queryBuilder.length() - 3, queryBuilder.length(), ""); } queryBuilder.append(")"); } return queryBuilder.toString(); } }