Skip to content

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<groupId>fr.paris.lutece.plugins</groupId>
<artifactId>plugin-solr</artifactId>
<packaging>lutece-plugin</packaging>
<version>3.1.4-SNAPSHOT</version>
<version>3.1.4a-SNAPSHOT</version>
<name>Lutece solr search plugin</name>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>( );
Copy link
Member Author

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)


/**
* Returns the code
Expand Down Expand Up @@ -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 );
}

Copy link
Member Author

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

/**
* Returns the boolean indicating if we need an extra query for mapping
* @return the boolean indicating if we need an extra query for mapping
Expand Down Expand Up @@ -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;
}
Copy link
Member Author

Choose a reason for hiding this comment

The 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
Expand Up @@ -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.";
Expand Down Expand Up @@ -80,6 +81,10 @@ public static SolrSearchAppConf loadConfiguration( String code )
{
conf.setFilterQuery( referenceItemName );
}
else if ( referenceItemCode.matches( DSKEY_FQ_REGULAR_EXPR ) )
Copy link
Member Author

Choose a reason for hiding this comment

The 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 );
Copy link
Member Author

Choose a reason for hiding this comment

The 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.
Adding tests would be an even better bonus :)

}
else if ( referenceItemCode.endsWith( DSKEY_TEMPLATE ) )
{
conf.setTemplate( referenceItemName );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Copy link
Member Author

Choose a reason for hiding this comment

The 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( ) ) )
{
Expand Down