mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 01:36:18 +00:00
Closes #305: exclude tags from search
This commit is contained in:
@@ -51,6 +51,12 @@ public class DocumentCriteria {
|
||||
*/
|
||||
private List<List<String>> tagIdList;
|
||||
|
||||
/**
|
||||
* Tag IDs to excluded.
|
||||
* The first and second level list will be excluded.
|
||||
*/
|
||||
private List<List<String>> excludedTagIdList;
|
||||
|
||||
/**
|
||||
* Shared status.
|
||||
*/
|
||||
@@ -119,6 +125,15 @@ public class DocumentCriteria {
|
||||
this.tagIdList = tagIdList;
|
||||
}
|
||||
|
||||
public List<List<String>> getExcludedTagIdList() {
|
||||
return excludedTagIdList;
|
||||
}
|
||||
|
||||
public DocumentCriteria setExcludedTagIdList(List<List<String>> excludedTagIdList) {
|
||||
this.excludedTagIdList = excludedTagIdList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getShared() {
|
||||
return shared;
|
||||
}
|
||||
|
||||
@@ -309,6 +309,19 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
||||
criteriaList.add("(" + Joiner.on(" OR ").join(tagCriteriaList) + ")");
|
||||
}
|
||||
}
|
||||
if (criteria.getExcludedTagIdList() != null && !criteria.getExcludedTagIdList().isEmpty()) {
|
||||
int index = 0;
|
||||
for (List<String> tagIdList : criteria.getExcludedTagIdList()) {
|
||||
List<String> tagCriteriaList = Lists.newArrayList();
|
||||
for (String tagId : tagIdList) {
|
||||
sb.append(String.format("left join T_DOCUMENT_TAG dtex%d on dtex%d.DOT_IDDOCUMENT_C = d.DOC_ID_C and dtex%d.DOT_IDTAG_C = :tagIdEx%d and dtex%d.DOT_DELETEDATE_D is null ", index, index, index, index, index));
|
||||
parameterMap.put("tagIdEx" + index, tagId);
|
||||
tagCriteriaList.add(String.format("dtex%d.DOT_ID_C is null", index));
|
||||
index++;
|
||||
}
|
||||
criteriaList.add("(" + Joiner.on(" AND ").join(tagCriteriaList) + ")");
|
||||
}
|
||||
}
|
||||
if (criteria.getShared() != null && criteria.getShared()) {
|
||||
criteriaList.add("s.count > 0");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user