mirror of
https://github.com/sismics/docs.git
synced 2025-12-17 19:51:39 +00:00
Closes #227: fix searching by tag
This commit is contained in:
@@ -47,8 +47,9 @@ public class DocumentCriteria {
|
||||
|
||||
/**
|
||||
* Tag IDs.
|
||||
* The first level list will be AND'ed and the second level list will be OR'ed.
|
||||
*/
|
||||
private List<String> tagIdList;
|
||||
private List<List<String>> tagIdList;
|
||||
|
||||
/**
|
||||
* Shared status.
|
||||
@@ -110,11 +111,11 @@ public class DocumentCriteria {
|
||||
this.createDateMax = createDateMax;
|
||||
}
|
||||
|
||||
public List<String> getTagIdList() {
|
||||
public List<List<String>> getTagIdList() {
|
||||
return tagIdList;
|
||||
}
|
||||
|
||||
public void setTagIdList(List<String> tagIdList) {
|
||||
public void setTagIdList(List<List<String>> tagIdList) {
|
||||
this.tagIdList = tagIdList;
|
||||
}
|
||||
|
||||
@@ -162,8 +163,7 @@ public class DocumentCriteria {
|
||||
this.updateDateMax = updateDateMax;
|
||||
}
|
||||
|
||||
public DocumentCriteria setActiveRoute(Boolean activeRoute) {
|
||||
public void setActiveRoute(Boolean activeRoute) {
|
||||
this.activeRoute = activeRoute;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,14 +245,16 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
||||
}
|
||||
if (criteria.getTagIdList() != null && !criteria.getTagIdList().isEmpty()) {
|
||||
int index = 0;
|
||||
List<String> tagCriteriaList = Lists.newArrayList();
|
||||
for (String tagId : criteria.getTagIdList()) {
|
||||
sb.append(String.format("left join T_DOCUMENT_TAG dt%d on dt%d.DOT_IDDOCUMENT_C = d.DOC_ID_C and dt%d.DOT_IDTAG_C = :tagId%d and dt%d.DOT_DELETEDATE_D is null ", index, index, index, index, index));
|
||||
parameterMap.put("tagId" + index, tagId);
|
||||
tagCriteriaList.add(String.format("dt%d.DOT_ID_C is not null", index));
|
||||
index++;
|
||||
for (List<String> tagIdList : criteria.getTagIdList()) {
|
||||
List<String> tagCriteriaList = Lists.newArrayList();
|
||||
for (String tagId : tagIdList) {
|
||||
sb.append(String.format("left join T_DOCUMENT_TAG dt%d on dt%d.DOT_IDDOCUMENT_C = d.DOC_ID_C and dt%d.DOT_IDTAG_C = :tagId%d and dt%d.DOT_DELETEDATE_D is null ", index, index, index, index, index));
|
||||
parameterMap.put("tagId" + index, tagId);
|
||||
tagCriteriaList.add(String.format("dt%d.DOT_ID_C is not null", index));
|
||||
index++;
|
||||
}
|
||||
criteriaList.add("(" + Joiner.on(" OR ").join(tagCriteriaList) + ")");
|
||||
}
|
||||
criteriaList.add("(" + Joiner.on(" OR ").join(tagCriteriaList) + ")");
|
||||
}
|
||||
if (criteria.getShared() != null && criteria.getShared()) {
|
||||
criteriaList.add("s.count > 0");
|
||||
|
||||
Reference in New Issue
Block a user