Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ea 3982 fix boolean queries #290

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ target/

# Local user-specific configuration
**/europeana.user.properties
**/europeana.user.3D.properties
**/europeana.user.BK.properties
**/europeana.user.localhost.properties
**/europeana.user.prod.properties
**/europeana.user.test.properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void logConfiguration() {
* The main properties are in the europeana.properties file, but since this is committed on GitHub this must not
* hold any usernames and passwords. These can be placed in the europeana.user.properties file which is never
* committed
* @return PropertSourcePlaceholderConfigurere bean
* @return PropertySourcePlaceholderConfigurer bean
*/
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ public ModelAndView searchJsonGet(
if (StringUtils.isBlank(queryString)) {
throw new SolrQueryException(ProblemType.SEARCH_QUERY_EMPTY);
}

// fix for EA-3979
queryString = queryString.replaceAll("\\+"," ");
queryString = "(" + StringUtils.strip(queryString, "()") + ")";

// validate boost Param
BoostParamUtils.validateBoostParam(boostParam);
Expand Down Expand Up @@ -326,6 +330,13 @@ public ModelAndView searchJsonGet(
if (qfArray != null && qfArray.length != refinementArray.length) {
refinementArray = qfArray;
}

// EA-3979 fix bug where + (instead of spaces) inside refinements breaks them
if (null != refinementArray && (refinementArray.length > 0)) {
for (int i=0; i<refinementArray.length; i++) {
refinementArray[i] = refinementArray[i].replaceAll("\\+"," ");
}
}

if (StringUtils.isNotBlank(theme)) {
if (StringUtils.containsAny(theme, "+ #%^&*-='\"<>`!@[]{}\\/|")) {
Expand Down Expand Up @@ -572,8 +583,6 @@ public ModelAndView searchJsonGetV3(
throw new SolrQueryException(ProblemType.SEARCH_QUERY_EMPTY);
}



// validate boost Param
BoostParamUtils.validateBoostParam(boostParam);

Expand Down Expand Up @@ -679,8 +688,7 @@ public ModelAndView searchJsonGetV3(
"Please make sure you encode the cursor value before sending it to the API.");
}
}




// TODO April '22 - this issue is now over 11 years old and I'm quite certain that we can stop checking this
// TODO check whether this is still necessary? <= about time we did that!
Expand All @@ -690,6 +698,7 @@ public ModelAndView searchJsonGetV3(
if (qfArray != null && qfArray.length != refinementArray.length) {
refinementArray = qfArray;
}

if (StringUtils.isNotBlank(theme)) {
if (StringUtils.containsAny(theme, "+ #%^&*-='\"<>`!@[]{}\\/|")) {
throw new SolrQueryException(ProblemType.SEARCH_THEME_MULTIPLE);
Expand Down Expand Up @@ -866,7 +875,7 @@ public ModelAndView searchJsonGetV3(
}

SearchResults<? extends IdBean> result = createResults(apiKey, profiles, query, clazz, request.getServerName(),
translateTargetLang, filterLanguages, request, response,isRefinementDivisionRequired );
translateTargetLang, filterLanguages, request, response, isRefinementDivisionRequired, true);

if (profiles.contains(Profile.PARAMS)) {
result.addParams(RequestUtils.getParameterMap(request), "apikey");
Expand Down Expand Up @@ -1321,17 +1330,17 @@ private <T extends IdBean> SearchResults<T> createResults(
List<Language> filterLanguages,
HttpServletRequest servletRequest,
HttpServletResponse servletResponse,
boolean isToDivideQueryRefinements,boolean isV3) throws EuropeanaException {

boolean isToDivideQueryRefinements,
boolean isV3) throws EuropeanaException {
SearchResults<T> response = new SearchResults<>(apiKey);
ResultSet<T> resultSet;

SolrClient solrClient = getSolrClient(requestRoute);

if (profiles.contains(Profile.DEBUG)) {
resultSet = searchService.search(solrClient, clazz, query, true,isToDivideQueryRefinements);
resultSet = searchService.search(solrClient, clazz, query, true, isToDivideQueryRefinements);
} else {
resultSet = searchService.search(solrClient, clazz, query,isToDivideQueryRefinements);
resultSet = searchService.search(solrClient, clazz, query, isToDivideQueryRefinements);
}
response.totalResults = resultSet.getResultSize();
if (StringUtils.isNotBlank(resultSet.getCurrentCursorMark()) &&
Expand Down