Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge commit '051478556ab3dc62332335cd6d8c8b473f0beee7' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanata Build Server committed Oct 15, 2015
2 parents b6819e7 + 0514785 commit a1c2d3b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Expand Up @@ -28,6 +28,7 @@

public class DateBridge implements TwoWayStringBridge {

// TODO include milliseconds for more precision (".SSS")
private final static String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";

private final SimpleDateFormat dateFormat = new SimpleDateFormat(
Expand Down
Expand Up @@ -128,8 +128,10 @@ public class TranslationMemoryServiceImpl implements TranslationMemoryService {
private static final Version LUCENE_VERSION = Version.LUCENE_29;

// sort desc by lastChanged of HTextFlowTarget
private final Sort lastChangedSort = new Sort(new SortField(
IndexFieldLabels.LAST_CHANGED_FIELD, SortField.STRING, true));
private final Sort lastChangedSort = new Sort(
SortField.FIELD_SCORE,
new SortField(IndexFieldLabels.LAST_CHANGED_FIELD,
SortField.STRING, true));

private final TermQuery newStateQuery = new TermQuery(new Term(
IndexFieldLabels.CONTENT_STATE_FIELD, ContentState.New.toString()));
Expand Down Expand Up @@ -607,13 +609,31 @@ private List<Object[]> getSearchResult(TransMemoryQuery query,

List<Object[]> resultList = (List<Object[]>) ftQuery.getResultList();
if (!resultList.isEmpty() && resultList.size() == maxResult) {
log.info(
"Lucene query returned exactly {} results. Increasing {} might produce more matches.",
resultList.size(), SysProperties.TM_MAX_RESULTS);
log.warn(
"Lucene query returned {} results (out of approx {}). " +
"Increasing {} might produce more matches.",
resultList.size(), ftQuery.getResultSize(),
SysProperties.TM_MAX_RESULTS);
logQueryResults(resultList);
}
return resultList;
}

private void logQueryResults(List<Object[]> resultList) {
if (log.isTraceEnabled()) {
// resultList.get() could be a little slow if resultList is a
// LinkedList, but in practice HSearch seems to use ArrayLists,
// plus we only iterate up to 10 elements.
int numToLog = Math.min(resultList.size(), 10);
for (int i = 0; i < numToLog; i++) {
Object[] arr = resultList.get(i);
Number score = (Number) arr[0];
Object entity = arr[1];
log.trace("{}[{}]: {}", i, score, entity);
}
}
}

/**
* Generate the query to match all source contents in all the searchable
* indexes. (HTextFlowTarget and TransMemoryUnit)
Expand Down

0 comments on commit a1c2d3b

Please sign in to comment.