-
Notifications
You must be signed in to change notification settings - Fork 11
SOLR-110 : Allow multiple filter queries in SearchApp confs #2
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ public class SolrSearchAppConf | |
private String _strTemplate = SolrConstants.CONSTANT_DEFAULT_TEMPLATE; | ||
private boolean _bExtraMappingQuery = SolrConstants.CONSTANT_DEFAULT_EXTRA_MAPPING_QUERY; | ||
private List<String> _listAddonBeanNames = new ArrayList<String>( ); | ||
private List<String> _listFilterQuery = new ArrayList<String>( ); | ||
|
||
/** | ||
* Returns the code | ||
|
@@ -107,6 +108,15 @@ public void setFilterQuery( String strFilterQuery ) | |
_strFilterQuery = strFilterQuery; | ||
} | ||
|
||
/** | ||
* Add the filter query to the current filter query list | ||
* @param strFilterQuery filter query to add | ||
*/ | ||
public void addFilterQuery( String strFilterQuery ) | ||
{ | ||
getListFilterQuery( ).add( strFilterQuery ); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should replace the old system |
||
/** | ||
* Returns the boolean indicating if we need an extra query for mapping | ||
* @return the boolean indicating if we need an extra query for mapping | ||
|
@@ -138,4 +148,18 @@ public List<String> getAddonBeanNames() { | |
public void setAddonBeanNames(List<String> listAddonBeanNames) { | ||
this._listAddonBeanNames = listAddonBeanNames; | ||
} | ||
|
||
/** | ||
* @return the Filter Query list | ||
*/ | ||
public List<String> getListFilterQuery() { | ||
return _listFilterQuery; | ||
} | ||
|
||
/** | ||
* @param listFilterQuery the Filter Query list to set | ||
*/ | ||
public void setListFilterQuery(List<String> listFilterQuery) { | ||
this._listFilterQuery = listFilterQuery; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace the old system |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ public class SolrSearchAppConfService | |
private static final String DSKEY_PREFIX = "solr.app.conf."; | ||
private static final String DSKEY_INSTALLED = ".installed"; | ||
private static final String DSKEY_FQ = ".fq"; | ||
private static final String DSKEY_FQ_REGULAR_EXPR = "solr\\.app\\.conf\\..*\\.fq\\.\\d"; | ||
private static final String DSKEY_TEMPLATE = ".template"; | ||
private static final String DSKEY_MAPPING = ".mapping"; | ||
private static final String DSKEY_ADDON_BEANS = ".addonBeans."; | ||
|
@@ -80,6 +81,10 @@ public static SolrSearchAppConf loadConfiguration( String code ) | |
{ | ||
conf.setFilterQuery( referenceItemName ); | ||
} | ||
else if ( referenceItemCode.matches( DSKEY_FQ_REGULAR_EXPR ) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency, it's better to do it the same way as the addonBeans, ie computing the full prefix and use startsWith instead of a regexp |
||
{ | ||
conf.addFilterQuery( referenceItemName ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to update SaveConfiguration as well even though it's not called yet. |
||
} | ||
else if ( referenceItemCode.endsWith( DSKEY_TEMPLATE ) ) | ||
{ | ||
conf.setTemplate( referenceItemName ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,8 +284,13 @@ public static Map<String, Object> getSearchResultModel(HttpServletRequest reques | |
// } | ||
// } | ||
} | ||
facetQuery = new String[facetQueryTmp.size()]; | ||
facetQuery = facetQueryTmp.toArray(facetQuery); | ||
|
||
if ( !conf.getListFilterQuery( ).isEmpty( ) ) | ||
{ | ||
facetQueryTmp.addAll( conf.getListFilterQuery( ) ); | ||
} | ||
facetQuery = new String[ facetQueryTmp.size( ) ]; | ||
facetQuery = facetQueryTmp.toArray( facetQuery ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should replace the previous code for a single filter query |
||
|
||
if ( StringUtils.isNotBlank( conf.getFilterQuery( ) ) ) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should replace the old system (_strFilterQuery)