From 05dab4a95ba516c120486b8e11c2ac5f0564d8e6 Mon Sep 17 00:00:00 2001 From: dogukan10 Date: Fri, 26 Jun 2020 15:54:40 +0300 Subject: [PATCH 1/3] modified select method to handle class index join --- .../eu/nimble/indexing/service/impl/SolrServiceImpl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java b/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java index 2e2078a..b114921 100644 --- a/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java +++ b/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java @@ -151,14 +151,17 @@ public SearchResult select(String query, List filterQueries, List select(String query, List filterQueries, List facetFields, List sortFields, int facetLimit, int facetMinCount, Pageable page) { + JoinHelper joinHelper = new JoinHelper(getCollection()); // expand main query to a wild card search when it is only a single word if (query.indexOf(":") == -1 && query.indexOf("*") == -1 && query.indexOf(" ") == -1) { query = String.format("*%s*", query); } - + else if (query.indexOf("classification.") != -1) { + //parse the query with a join on class index for synonyms + query = joinHelper.parseQuery(query); + } + Criteria qCriteria = new SimpleStringCriteria(query); - // - JoinHelper joinHelper = new JoinHelper(getCollection()); if ( filterQueries != null && !filterQueries.isEmpty()) { // From 87107c1e50185d1047fb9046c408809a5e85e4ff Mon Sep 17 00:00:00 2001 From: dogukan10 Date: Sat, 27 Jun 2020 14:17:00 +0300 Subject: [PATCH 2/3] rest endpoints to clear item/party indexes --- .../nimble/indexing/service/SolrService.java | 200 +++++++++--------- .../service/impl/SolrServiceImpl.java | 5 + .../web/controller/IndexController.java | 24 +++ 3 files changed, 131 insertions(+), 98 deletions(-) diff --git a/src/main/java/eu/nimble/indexing/service/SolrService.java b/src/main/java/eu/nimble/indexing/service/SolrService.java index 2253933..f2b5a6d 100644 --- a/src/main/java/eu/nimble/indexing/service/SolrService.java +++ b/src/main/java/eu/nimble/indexing/service/SolrService.java @@ -1,98 +1,102 @@ -package eu.nimble.indexing.service; - -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import org.springframework.data.domain.Pageable; - -import eu.nimble.service.model.solr.FacetResult; -import eu.nimble.service.model.solr.IndexField; -import eu.nimble.service.model.solr.Search; -import eu.nimble.service.model.solr.SearchResult; - -public interface SolrService { - - /** - * Obtain an item based on it's identifier - * @param uri - * @return - */ - public Optional get(String uri); - /** - * Store an item - * @param item - */ - public void set(T item); - /** - * Store a list of items - * @param items - */ - public boolean set(List items); - /** - * Delete an item from the index - * @param uri - */ - public void remove(String uri); - /** - * Retrieve the {@link IndexField} descriptors for the - * collection. The {@link IndexField} denotes - *
    - *
  • fieldName: as used in the collection - *
  • dataType: one of string, int, double, boolean - *
  • docCount: the number of documents containing this field - *
  • dynamicBase: the dynamic field used for deriving the fieldName - *
- * @return - */ - public Collection fields(); - /** - * Retrieve the {@link IndexField} descritors for the collection. Perform - * filtering based on the provided list. - * @param fields A list of fieldNames to return, wildcards are allowed as the first/last character. - * @return - */ - public Collection fields(Set fields); - /** - * Perform a search against the collection - * @param search The search definition holding query, filterQuery and faceting parameters - * @return - */ - public SearchResult search(Search search); - /** - * Perform a select query against the collection - * @param query The query term used with the q query parameter - * @param filterQueries The filter terms uses as fq query parameters - * @param facetFields The names used for faceting, e.g. facet.field parameters - * @param facetLimit The number of facet elements to return for each facet - * @param facetMinCount The minimum number of facet occurrences to be included in the result - * @param page The {@link Pageable} pointing to the current page & size - * @return - */ - public SearchResult select(String query, List filterQueries, List facetFields, int facetLimit, int facetMinCount, Pageable page); - - /** - * Perform a select query against the collection - * @param query The query term used with the q query parameter - * @param filterQueries The filter terms uses as fq query parameters - * @param facetFields The names used for faceting, e.g. facet.field parameters - * @param sortFields Set of attributes for search pointing to the current page & size - * @param facetLimit The number of facet elements to return for each facet - * @param facetMinCount The minimum number of facet occurrences to be included in the result - * @param page The {@link Pageable} pointing to the current page & size - * @return - */ - public SearchResult select(String query, List filterQueries, List facetFields,List sortFields, int facetLimit, int facetMinCount, Pageable page); - - /** - * Perform a auto suggest query - * @param query The query term used with the q query parameter - * @param filterQueries The filter terms uses as fq query parameters - * @param facetFields The names used for faceting, e.g. facet.field parameters - * @param facetLimit The number of facet elements to return for each facet - * @param facetMinCount The minimum number of facet occurrences to be included in the result - * @return A {@link FacetResult} denoting name, facet and facet count - */ - public FacetResult suggest(String query, String facetField, int facetLimit, int facetMinCount); -} +package eu.nimble.indexing.service; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import org.springframework.data.domain.Pageable; + +import eu.nimble.service.model.solr.FacetResult; +import eu.nimble.service.model.solr.IndexField; +import eu.nimble.service.model.solr.Search; +import eu.nimble.service.model.solr.SearchResult; + +public interface SolrService { + + /** + * Obtain an item based on it's identifier + * @param uri + * @return + */ + public Optional get(String uri); + /** + * Store an item + * @param item + */ + public void set(T item); + /** + * Store a list of items + * @param items + */ + public boolean set(List items); + /** + * Delete an item from the index + * @param uri + */ + public void remove(String uri); + /** + * Clear the index + */ + public void clearIndex(); + /** + * Retrieve the {@link IndexField} descriptors for the + * collection. The {@link IndexField} denotes + *
    + *
  • fieldName: as used in the collection + *
  • dataType: one of string, int, double, boolean + *
  • docCount: the number of documents containing this field + *
  • dynamicBase: the dynamic field used for deriving the fieldName + *
+ * @return + */ + public Collection fields(); + /** + * Retrieve the {@link IndexField} descritors for the collection. Perform + * filtering based on the provided list. + * @param fields A list of fieldNames to return, wildcards are allowed as the first/last character. + * @return + */ + public Collection fields(Set fields); + /** + * Perform a search against the collection + * @param search The search definition holding query, filterQuery and faceting parameters + * @return + */ + public SearchResult search(Search search); + /** + * Perform a select query against the collection + * @param query The query term used with the q query parameter + * @param filterQueries The filter terms uses as fq query parameters + * @param facetFields The names used for faceting, e.g. facet.field parameters + * @param facetLimit The number of facet elements to return for each facet + * @param facetMinCount The minimum number of facet occurrences to be included in the result + * @param page The {@link Pageable} pointing to the current page & size + * @return + */ + public SearchResult select(String query, List filterQueries, List facetFields, int facetLimit, int facetMinCount, Pageable page); + + /** + * Perform a select query against the collection + * @param query The query term used with the q query parameter + * @param filterQueries The filter terms uses as fq query parameters + * @param facetFields The names used for faceting, e.g. facet.field parameters + * @param sortFields Set of attributes for search pointing to the current page & size + * @param facetLimit The number of facet elements to return for each facet + * @param facetMinCount The minimum number of facet occurrences to be included in the result + * @param page The {@link Pageable} pointing to the current page & size + * @return + */ + public SearchResult select(String query, List filterQueries, List facetFields,List sortFields, int facetLimit, int facetMinCount, Pageable page); + + /** + * Perform a auto suggest query + * @param query The query term used with the q query parameter + * @param filterQueries The filter terms uses as fq query parameters + * @param facetFields The names used for faceting, e.g. facet.field parameters + * @param facetLimit The number of facet elements to return for each facet + * @param facetMinCount The minimum number of facet occurrences to be included in the result + * @return A {@link FacetResult} denoting name, facet and facet count + */ + public FacetResult suggest(String query, String facetField, int facetLimit, int facetMinCount); +} diff --git a/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java b/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java index b114921..0b0dd44 100644 --- a/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java +++ b/src/main/java/eu/nimble/indexing/service/impl/SolrServiceImpl.java @@ -90,6 +90,11 @@ public void remove(String uri) { } } + @Override + public void clearIndex() { + solr.deleteAll(); + } + @Override public SearchResult search(Search search) { if(search.getSort() != null) { diff --git a/src/main/java/eu/nimble/indexing/web/controller/IndexController.java b/src/main/java/eu/nimble/indexing/web/controller/IndexController.java index b68a158..d5b8287 100644 --- a/src/main/java/eu/nimble/indexing/web/controller/IndexController.java +++ b/src/main/java/eu/nimble/indexing/web/controller/IndexController.java @@ -446,6 +446,18 @@ public ResponseEntity searchParty( return ResponseEntity.ok(result); } + @ApiOperation(value = "", notes = "Clear party index", response = Boolean.class) + @DeleteMapping("/party/clear") + public ResponseEntity clearPartyIndex( + @RequestHeader(value = "Authorization") String bearerToken) throws Exception { + + if (identityService.hasAnyRole(bearerToken, PLATFORM_MANAGER,LEGAL_REPRESENTATIVE,NIMBLE_USER, + PUBLISHER,COMPANY_ADMIN,EFACTORYUSER) == false) + return new ResponseEntity<>("User Not Allowed To Clear Party Index", HttpStatus.UNAUTHORIZED); + partyService.clearIndex(); + return ResponseEntity.ok(Boolean.TRUE); + } + @ApiOperation(value = "", notes = "Retrieve a specific party identified by the given uri", response = PartyType.class) @GetMapping("/party") public ResponseEntity getParty( @@ -798,6 +810,18 @@ public ResponseEntity getItem( return ResponseEntity.of(result); } + @ApiOperation(value = "", notes = "Clear item index", response = Boolean.class) + @DeleteMapping("/item/clear") + public ResponseEntity clearItemIndex( + @RequestHeader(value = "Authorization") String bearerToken) throws Exception { + + if (identityService.hasAnyRole(bearerToken, PLATFORM_MANAGER,LEGAL_REPRESENTATIVE,NIMBLE_USER, + PUBLISHER,COMPANY_ADMIN,EFACTORYUSER) == false) + return new ResponseEntity<>("User Not Allowed To Clear Item Index", HttpStatus.UNAUTHORIZED); + itemService.clearIndex(); + return ResponseEntity.ok(Boolean.TRUE); + } + @ApiOperation(value = "", notes = "Detele an item", response = Boolean.class) @DeleteMapping("/item") public ResponseEntity removeItem( From c3c8791758145d5090ff9a0f5eaaa4f996dc1ff1 Mon Sep 17 00:00:00 2001 From: dogukan10 Date: Sat, 27 Jun 2020 14:17:50 +0300 Subject: [PATCH 3/3] modified .gitignore file --- .gitignore | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d5a056e..7cc2317 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -# Created by .ignore support plugin (hsz.mobi) -/target/ -/.classpath -/.project +# Created by .ignore support plugin (hsz.mobi) +/target/ +/.classpath +/.project +.idea/ +*.iml \ No newline at end of file