public SearchResults proposeMatches(String id, int type) {
DocumentContainer docContainer = DocumentContainer.getInstance();
// get shingle cloud from context
ShingleCloud sCloud = SearchManager.getInstance().getShingleCloudForDerived(type);
// get needle
Element elToMatch = docContainer.getElementFor(id, DocumentContainer.MASTER);
String needle = elToMatch.getTextContent();
// perform match
sCloud.match(needle);
// prepare list of matches
double threshold = PropertiesProvider.getInstance().getRatingThresholdForProposals();
if(type == SearchManager.TYPE_FUZZY)
threshold = 0;
// dirty fix
int maxNumberOfMatches = 100;
List<MatchProposal> matches = new ArrayList<MatchProposal>();
for(ShingleCloudMatch sm : sCloud.getMatches()){
if(sm.hasUpperBound() && maxNumberOfMatches > matches.size()){
// create proposal
MatchProposal proposal = new MatchProposal(sm.getUpperBound().getId());
proposal.setDirectRating(sm.getRating() * 100);
if(sCloud.getNeedleShingles().size() > 0)
proposal.setIndirectRating(sm.getContainmentInNeedle());
// add proposal if rating is good enough
if(proposal.getIndirectRating() >= threshold){
String text = docContainer.getElementAsStringFor(sm.getUpperBound().getId(), DocumentContainer.DERIVED);