Commit 795944f1 authored by Matija Obreza's avatar Matija Obreza

Elasticsearch indexing updated

- scanDatabase by ModelFilter
- detach entities from entity manager after indexing
- T cleanup
parent 50f6dfa7
......@@ -147,7 +147,7 @@ public class ApiExceptionHandler {
@ExceptionHandler(value = { NotFoundElement.class, org.genesys2.server.exception.NotFoundElement.class })
@ResponseBody
public ApiError<Exception> handleNotFound(final Exception e, final HttpServletRequest request) {
LOG.warn("Element not found {} {}", request.getMethod(), request.getRequestURL(), e);
LOG.warn("Element not found {} {}", request.getMethod(), request.getRequestURL());
return new ApiError<>(e);
}
......@@ -161,7 +161,7 @@ public class ApiExceptionHandler {
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(value = { HttpRequestMethodNotSupportedException.class })
public ApiError<Exception> handleRequestMethodFail(final HttpServletRequest req, final HttpRequestMethodNotSupportedException e) {
LOG.warn("Request method {} not supported for URL {}", e.getMethod(), req.getRequestURL(), e);
LOG.warn("Request method {} not supported for URL {}", e.getMethod(), req.getRequestURL());
return new ApiError<>(e);
}
......
......@@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import javax.annotation.Resource;
......@@ -128,7 +127,8 @@ public class ElasticSearchController {
* @throws IOException
*/
@RequestMapping(method = RequestMethod.POST, value = "/action", params = { "reindex=accn", "filter" })
public String reindexElasticFiltered(@RequestParam(value = "filter", required = true) AccessionFilter accessionFilter) throws IOException {
public String reindexElasticFiltered(@RequestParam(value = "filter", required = true) String jsonfilt) throws IOException {
AccessionFilter accessionFilter = new ObjectMapper().readValue(jsonfilt, AccessionFilter.class);
taskExecutor.execute(() -> {
try {
elasticsearchService.reindex(Accession.class, accessionFilter);
......
......@@ -85,7 +85,7 @@ public interface ElasticsearchService {
* @param searchQuery the search query
* @return the map
*/
<T extends BasicModel> Map<Class<T>, List<T>> search(QueryBuilder shouldMatch, Set<Class<?>> clazzes, String searchQuery);
<T extends BasicModel> Map<Class<BasicModel>, List<T>> search(QueryBuilder shouldMatch, Set<Class<?>> clazzes, String searchQuery);
/**
* Term statistics auto.
......@@ -172,4 +172,6 @@ public interface ElasticsearchService {
List<Class<? extends BasicModel>> getIndexedEntities();
long count(Class<? extends BasicModel> clazz, BasicModelFilter filter);
}
......@@ -12,12 +12,12 @@
<div>Update queue size: <c:out value="${updateQueueSize}" /></div>
<h3>Elastic reindex</h3>
<%-- <form method="post" action="<c:url value="/admin/elastic/action" />">
<form method="post" action="<c:url value="/admin/elastic/action" />">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<input type="text" name="filter" placeholder="Genesys filter {}" value='{"historic":[true,false]}' />
<input type="text" name="filter" placeholder="Genesys filter {}" value='{"holder":{"code":["NGA039"]}}' />
<button type="submit" class="btn btn-default" value="accn" name="reindex">Reindex</button>
<button type="submit" class="btn btn-default" value="accn" name="regenerate">Regenerate</button>
</form> --%>
</form>
<form method="post" action="<c:url value="/admin/elastic/action" />">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment