diff --git a/Comment/_4u.cfe b/Comment/_4u.cfe
new file mode 100644
index 0000000..bd8ee06
Binary files /dev/null and b/Comment/_4u.cfe differ
diff --git a/Comment/_4u.cfs b/Comment/_4u.cfs
new file mode 100644
index 0000000..1439beb
Binary files /dev/null and b/Comment/_4u.cfs differ
diff --git a/Comment/_4u.si b/Comment/_4u.si
new file mode 100644
index 0000000..52ba712
Binary files /dev/null and b/Comment/_4u.si differ
diff --git a/Comment/_4v.cfe b/Comment/_4v.cfe
new file mode 100644
index 0000000..f256ab2
Binary files /dev/null and b/Comment/_4v.cfe differ
diff --git a/Comment/_4v.cfs b/Comment/_4v.cfs
new file mode 100644
index 0000000..6f4c8f8
Binary files /dev/null and b/Comment/_4v.cfs differ
diff --git a/Comment/_4v.si b/Comment/_4v.si
new file mode 100644
index 0000000..d2d718f
Binary files /dev/null and b/Comment/_4v.si differ
diff --git a/Comment/_4y.cfe b/Comment/_4y.cfe
new file mode 100644
index 0000000..e3bb6ae
Binary files /dev/null and b/Comment/_4y.cfe differ
diff --git a/Comment/_4y.cfs b/Comment/_4y.cfs
new file mode 100644
index 0000000..8b588bb
Binary files /dev/null and b/Comment/_4y.cfs differ
diff --git a/Comment/_4y.si b/Comment/_4y.si
new file mode 100644
index 0000000..551da31
Binary files /dev/null and b/Comment/_4y.si differ
diff --git a/Comment/_4z.fdm b/Comment/_4z.fdm
new file mode 100644
index 0000000..f73ab7a
Binary files /dev/null and b/Comment/_4z.fdm differ
diff --git a/Comment/_4z.fdt b/Comment/_4z.fdt
new file mode 100644
index 0000000..aa3393c
Binary files /dev/null and b/Comment/_4z.fdt differ
diff --git a/Comment/_4z.fdx b/Comment/_4z.fdx
new file mode 100644
index 0000000..ed41f3d
Binary files /dev/null and b/Comment/_4z.fdx differ
diff --git a/Comment/_4z.fnm b/Comment/_4z.fnm
new file mode 100644
index 0000000..a112a98
Binary files /dev/null and b/Comment/_4z.fnm differ
diff --git a/Comment/_4z.nvd b/Comment/_4z.nvd
new file mode 100644
index 0000000..c23bff0
Binary files /dev/null and b/Comment/_4z.nvd differ
diff --git a/Comment/_4z.nvm b/Comment/_4z.nvm
new file mode 100644
index 0000000..23e83b9
Binary files /dev/null and b/Comment/_4z.nvm differ
diff --git a/Comment/_4z.si b/Comment/_4z.si
new file mode 100644
index 0000000..a2cc560
Binary files /dev/null and b/Comment/_4z.si differ
diff --git a/Comment/_4z_Lucene80_0.dvd b/Comment/_4z_Lucene80_0.dvd
new file mode 100644
index 0000000..82df1d1
Binary files /dev/null and b/Comment/_4z_Lucene80_0.dvd differ
diff --git a/Comment/_4z_Lucene80_0.dvm b/Comment/_4z_Lucene80_0.dvm
new file mode 100644
index 0000000..9916e2b
Binary files /dev/null and b/Comment/_4z_Lucene80_0.dvm differ
diff --git a/Comment/_4z_Lucene84_0.doc b/Comment/_4z_Lucene84_0.doc
new file mode 100644
index 0000000..16f5ca7
Binary files /dev/null and b/Comment/_4z_Lucene84_0.doc differ
diff --git a/Comment/_4z_Lucene84_0.pos b/Comment/_4z_Lucene84_0.pos
new file mode 100644
index 0000000..54379d8
Binary files /dev/null and b/Comment/_4z_Lucene84_0.pos differ
diff --git a/Comment/_4z_Lucene84_0.tim b/Comment/_4z_Lucene84_0.tim
new file mode 100644
index 0000000..0f55b01
Binary files /dev/null and b/Comment/_4z_Lucene84_0.tim differ
diff --git a/Comment/_4z_Lucene84_0.tip b/Comment/_4z_Lucene84_0.tip
new file mode 100644
index 0000000..8398ace
Binary files /dev/null and b/Comment/_4z_Lucene84_0.tip differ
diff --git a/Comment/_4z_Lucene84_0.tmd b/Comment/_4z_Lucene84_0.tmd
new file mode 100644
index 0000000..cc682ce
Binary files /dev/null and b/Comment/_4z_Lucene84_0.tmd differ
diff --git a/Comment/segments_1d b/Comment/segments_1d
new file mode 100644
index 0000000..b2e7a64
Binary files /dev/null and b/Comment/segments_1d differ
diff --git a/Comment/write.lock b/Comment/write.lock
new file mode 100644
index 0000000..e69de29
diff --git a/Entry/_4d.cfe b/Entry/_4d.cfe
new file mode 100644
index 0000000..f21e641
Binary files /dev/null and b/Entry/_4d.cfe differ
diff --git a/Entry/_4d.cfs b/Entry/_4d.cfs
new file mode 100644
index 0000000..f19e276
Binary files /dev/null and b/Entry/_4d.cfs differ
diff --git a/Entry/_4d.si b/Entry/_4d.si
new file mode 100644
index 0000000..52b4015
Binary files /dev/null and b/Entry/_4d.si differ
diff --git a/Entry/_4h.cfe b/Entry/_4h.cfe
new file mode 100644
index 0000000..f66dda4
Binary files /dev/null and b/Entry/_4h.cfe differ
diff --git a/Entry/_4h.cfs b/Entry/_4h.cfs
new file mode 100644
index 0000000..007ec6b
Binary files /dev/null and b/Entry/_4h.cfs differ
diff --git a/Entry/_4h.si b/Entry/_4h.si
new file mode 100644
index 0000000..a26bbe1
Binary files /dev/null and b/Entry/_4h.si differ
diff --git a/Entry/_4k.fdm b/Entry/_4k.fdm
new file mode 100644
index 0000000..bd0bebc
Binary files /dev/null and b/Entry/_4k.fdm differ
diff --git a/Entry/_4k.fdt b/Entry/_4k.fdt
new file mode 100644
index 0000000..b8f6a30
Binary files /dev/null and b/Entry/_4k.fdt differ
diff --git a/Entry/_4k.fdx b/Entry/_4k.fdx
new file mode 100644
index 0000000..9afd155
Binary files /dev/null and b/Entry/_4k.fdx differ
diff --git a/Entry/_4k.fnm b/Entry/_4k.fnm
new file mode 100644
index 0000000..a051f44
Binary files /dev/null and b/Entry/_4k.fnm differ
diff --git a/Entry/_4k.nvd b/Entry/_4k.nvd
new file mode 100644
index 0000000..817da3b
Binary files /dev/null and b/Entry/_4k.nvd differ
diff --git a/Entry/_4k.nvm b/Entry/_4k.nvm
new file mode 100644
index 0000000..bcef35d
Binary files /dev/null and b/Entry/_4k.nvm differ
diff --git a/Entry/_4k.si b/Entry/_4k.si
new file mode 100644
index 0000000..4f9900b
Binary files /dev/null and b/Entry/_4k.si differ
diff --git a/Entry/_4k_Lucene80_0.dvd b/Entry/_4k_Lucene80_0.dvd
new file mode 100644
index 0000000..2859534
Binary files /dev/null and b/Entry/_4k_Lucene80_0.dvd differ
diff --git a/Entry/_4k_Lucene80_0.dvm b/Entry/_4k_Lucene80_0.dvm
new file mode 100644
index 0000000..0a28a08
Binary files /dev/null and b/Entry/_4k_Lucene80_0.dvm differ
diff --git a/Entry/_4k_Lucene84_0.doc b/Entry/_4k_Lucene84_0.doc
new file mode 100644
index 0000000..e53cb47
Binary files /dev/null and b/Entry/_4k_Lucene84_0.doc differ
diff --git a/Entry/_4k_Lucene84_0.pos b/Entry/_4k_Lucene84_0.pos
new file mode 100644
index 0000000..a3c932d
Binary files /dev/null and b/Entry/_4k_Lucene84_0.pos differ
diff --git a/Entry/_4k_Lucene84_0.tim b/Entry/_4k_Lucene84_0.tim
new file mode 100644
index 0000000..dd8e732
Binary files /dev/null and b/Entry/_4k_Lucene84_0.tim differ
diff --git a/Entry/_4k_Lucene84_0.tip b/Entry/_4k_Lucene84_0.tip
new file mode 100644
index 0000000..f78288a
Binary files /dev/null and b/Entry/_4k_Lucene84_0.tip differ
diff --git a/Entry/_4k_Lucene84_0.tmd b/Entry/_4k_Lucene84_0.tmd
new file mode 100644
index 0000000..e3fd854
Binary files /dev/null and b/Entry/_4k_Lucene84_0.tmd differ
diff --git a/Entry/segments_19 b/Entry/segments_19
new file mode 100644
index 0000000..a8075f7
Binary files /dev/null and b/Entry/segments_19 differ
diff --git a/Entry/write.lock b/Entry/write.lock
new file mode 100644
index 0000000..e69de29
diff --git a/pom.xml b/pom.xml
index 6a37175..24e410f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
UTF-8
11
- 1.2.0
+ 1.3.0
@@ -57,6 +57,19 @@
spring-session-jdbc
+
+
+ org.hibernate.search
+ hibernate-search-mapper-orm
+ 6.0.7.Final
+
+
+
+ org.hibernate.search
+ hibernate-search-backend-lucene
+ 6.0.7.Final
+
+
com.querydsl
diff --git a/src/main/java/de/bstly/board/businesslogic/CommentManager.java b/src/main/java/de/bstly/board/businesslogic/CommentManager.java
index dea020f..3a583cb 100644
--- a/src/main/java/de/bstly/board/businesslogic/CommentManager.java
+++ b/src/main/java/de/bstly/board/businesslogic/CommentManager.java
@@ -19,13 +19,13 @@ import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import de.bstly.board.model.Comment;
-import de.bstly.board.model.FlaggedStatus;
import de.bstly.board.model.QComment;
import de.bstly.board.model.QEntry;
import de.bstly.board.model.QFlag;
import de.bstly.board.model.QVote;
-import de.bstly.board.model.Types;
-import de.bstly.board.model.VoteType;
+import de.bstly.board.model.support.FlaggedStatus;
+import de.bstly.board.model.support.Types;
+import de.bstly.board.model.support.VoteType;
import de.bstly.board.repository.CommentRepository;
import de.bstly.board.repository.VoteRepository;
diff --git a/src/main/java/de/bstly/board/businesslogic/EntryManager.java b/src/main/java/de/bstly/board/businesslogic/EntryManager.java
index a81f5b8..af403c1 100644
--- a/src/main/java/de/bstly/board/businesslogic/EntryManager.java
+++ b/src/main/java/de/bstly/board/businesslogic/EntryManager.java
@@ -27,12 +27,12 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
import de.bstly.board.controller.model.EntryFilter;
import de.bstly.board.model.Bookmarks;
import de.bstly.board.model.Entry;
-import de.bstly.board.model.FlaggedStatus;
import de.bstly.board.model.QEntry;
import de.bstly.board.model.QFlag;
import de.bstly.board.model.QVote;
-import de.bstly.board.model.Types;
-import de.bstly.board.model.VoteType;
+import de.bstly.board.model.support.FlaggedStatus;
+import de.bstly.board.model.support.Types;
+import de.bstly.board.model.support.VoteType;
import de.bstly.board.repository.EntryRepository;
import de.bstly.board.repository.VoteRepository;
@@ -104,7 +104,7 @@ public class EntryManager {
* @param asc the asc
* @return the page
*/
- public Page fetchByRanking(String username, EntryFilter filter, double gravity, int page,
+ public Page fetchByRanking(String username, EntryFilter filter, float gravity, int page,
int size, boolean asc) {
Query query = createEntryQuery(RANK_CALCULATION_QUERY, username, filter,
asc ? "ranking ASC, entry.created ASC" : "ranking DESC, entry.created DESC");
@@ -152,7 +152,7 @@ public class EntryManager {
* @param asc the asc
* @return the page
*/
- public Page fetchByComments(String username, EntryFilter filter, double gravity,
+ public Page fetchByComments(String username, EntryFilter filter, float gravity,
int page, int size, boolean asc) {
Query query = createEntryQuery(COMMENT_CALCULATION_QUERY, username, filter,
asc ? "ranking ASC, entry.created ASC" : "ranking DESC, entry.created DESC");
@@ -247,6 +247,24 @@ public class EntryManager {
+ tagsString
+ ")";
}
+
+ String fixedTagsString = "";
+ if (filter.getFixedTags() != null && !filter.getFixedTags().isEmpty()) {
+ for (int index = 0; index < filter.getFixedTags().size(); index++) {
+ fixedTagsString += "'"
+ + filter.getFixedTags().get(index)
+ + "'";
+ if (index < filter.getFixedTags().size() - 1) {
+ fixedTagsString += ",";
+ }
+ }
+ }
+
+ if (StringUtils.hasText(fixedTagsString)) {
+ filterString += " INNER JOIN tags as fixedTag ON entry.id = fixedTag.target AND fixedTag.tag IN ("
+ + fixedTagsString
+ + ")";
+ }
boolean author = false;
if (filter.getDate() != null) {
@@ -289,6 +307,24 @@ public class EntryManager {
+ excludedTagsString
+ "))";
}
+
+ String fixedExcludedTagsString = "";
+ if (filter.getFixedExcludedTags() != null && !filter.getFixedExcludedTags().isEmpty()) {
+ for (int index = 0; index < filter.getFixedExcludedTags().size(); index++) {
+ fixedExcludedTagsString += "'"
+ + filter.getFixedExcludedTags().get(index)
+ + "'";
+ if (index < filter.getFixedExcludedTags().size() - 1) {
+ fixedExcludedTagsString += ",";
+ }
+ }
+ }
+
+ if (StringUtils.hasText(fixedExcludedTagsString)) {
+ filterString += " AND NOT EXISTS (SELECT * FROM tags as fixedExcludedTag WHERE entry.id = fixedExcludedTag.target AND fixedExcludedTag.tag IN ("
+ + fixedExcludedTagsString
+ + "))";
+ }
if (StringUtils.hasText(orderBy)) {
filterString += " ORDER BY "
diff --git a/src/main/java/de/bstly/board/businesslogic/FlagManager.java b/src/main/java/de/bstly/board/businesslogic/FlagManager.java
index 13555e4..7234d8e 100644
--- a/src/main/java/de/bstly/board/businesslogic/FlagManager.java
+++ b/src/main/java/de/bstly/board/businesslogic/FlagManager.java
@@ -10,10 +10,10 @@ import org.springframework.util.Assert;
import de.bstly.board.model.Comment;
import de.bstly.board.model.Entry;
import de.bstly.board.model.Flag;
-import de.bstly.board.model.FlaggedStatus;
import de.bstly.board.model.QComment;
import de.bstly.board.model.QFlag;
-import de.bstly.board.model.Types;
+import de.bstly.board.model.support.FlaggedStatus;
+import de.bstly.board.model.support.Types;
import de.bstly.board.repository.CommentRepository;
import de.bstly.board.repository.FlagRepository;
diff --git a/src/main/java/de/bstly/board/businesslogic/SearchManager.java b/src/main/java/de/bstly/board/businesslogic/SearchManager.java
new file mode 100644
index 0000000..c2b1ed8
--- /dev/null
+++ b/src/main/java/de/bstly/board/businesslogic/SearchManager.java
@@ -0,0 +1,113 @@
+/**
+ *
+ */
+package de.bstly.board.businesslogic;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.transaction.Transactional;
+
+import org.hibernate.search.engine.search.query.SearchResult;
+import org.hibernate.search.mapper.orm.Search;
+import org.hibernate.search.mapper.orm.massindexing.MassIndexer;
+import org.hibernate.search.mapper.orm.session.SearchSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.SmartInitializingSingleton;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
+import com.google.common.collect.Lists;
+
+import de.bstly.board.model.Comment;
+import de.bstly.board.model.Entry;
+import de.bstly.board.model.support.Types;
+
+/**
+ * The Class SearchManager.
+ */
+@Component
+public class SearchManager implements SmartInitializingSingleton {
+
+ private Logger logger = LoggerFactory.getLogger(SearchManager.class);
+
+ @Autowired
+ private EntityManager em;
+ @Autowired
+ private SettingsManager settingsManager;
+ private SearchSession searchSession;
+
+ /*
+ * @see org.springframework.beans.factory.SmartInitializingSingleton#
+ * afterSingletonsInstantiated()
+ */
+ /*
+ * @see org.springframework.beans.factory.SmartInitializingSingleton#
+ * afterSingletonsInstantiated()
+ */
+ @Override
+ public void afterSingletonsInstantiated() {
+ searchSession = Search.session(em);
+ }
+
+ /**
+ * On application event.
+ *
+ * @param event the event
+ */
+ @EventListener(ContextRefreshedEvent.class)
+ @Transactional
+ public void onApplicationEvent(ContextRefreshedEvent event) {
+ MassIndexer indexer = searchSession.massIndexer().idFetchSize(150)
+ .batchSizeToLoadObjects(25).threadsToLoadObjects(12);
+ try {
+ logger.info("start indexing!");
+ indexer.startAndWait();
+ logger.info("finished indexing!");
+ } catch (InterruptedException e) {
+ logger.error("error on indexing!", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ @Transactional
+ public SearchResult