Skip to content
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: 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 @@ -48,10 +48,10 @@
public class SolrSearchAppConf
{
private String _strCode = SolrSearchAppConfService.EMPTY_CODE;
private String _strFilterQuery = SolrConstants.CONSTANT_DEFAULT_FILTER_QUERY;
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 @@ -89,24 +89,6 @@ public void setTemplate( String template )
_strTemplate = template;
}

/**
* Returns the filter query
* @return the filter query
*/
public String getFilterQuery( )
{
return _strFilterQuery;
}

/**
* Sets the filter query
* @param filter query the code
*/
public void setFilterQuery( String strFilterQuery )
{
_strFilterQuery = strFilterQuery;
}

/**
* 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 +120,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 @@ -52,10 +52,10 @@ public class SolrSearchAppConfService
public static final String EMPTY_CODE = "";
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_TEMPLATE = ".template";
private static final String DSKEY_MAPPING = ".mapping";
private static final String DSKEY_ADDON_BEANS = ".addonBeans.";
private static final String DSKEY_FQ_LIST = ".fq.";

public static SolrSearchAppConf loadConfiguration( String code )
{
Expand All @@ -72,15 +72,12 @@ public static SolrSearchAppConf loadConfiguration( String code )
conf.setCode( strSafeCode );

String strAddonPrefix = strPrefix + DSKEY_ADDON_BEANS;
String strFqListPrefix = strPrefix + DSKEY_FQ_LIST;
for ( ReferenceItem referenceItem : referenceList )
{
String referenceItemCode = referenceItem.getCode( );
String referenceItemName = referenceItem.getName( );
if ( referenceItemCode.endsWith( DSKEY_FQ ) )
{
conf.setFilterQuery( referenceItemName );
}
else if ( referenceItemCode.endsWith( DSKEY_TEMPLATE ) )
if ( referenceItemCode.endsWith( DSKEY_TEMPLATE ) )
{
conf.setTemplate( referenceItemName );
}
Expand All @@ -92,6 +89,10 @@ else if ( referenceItemCode.startsWith( strAddonPrefix ) )
{
conf.getAddonBeanNames().add ( referenceItemName );
}
else if ( referenceItemCode.startsWith( strFqListPrefix ) )
{
conf.getListFilterQuery( ).add ( referenceItemName );
}
}

return conf;
Expand All @@ -102,13 +103,16 @@ public static void saveConfiguration( SolrSearchAppConf conf )
String strSafeCode = ( conf.getCode( ) != null ) ? conf.getCode( ) : EMPTY_CODE;
String strPrefix = DSKEY_PREFIX + strSafeCode;
DatastoreService.setDataValue( strPrefix + DSKEY_INSTALLED, SolrConstants.CONSTANT_TRUE );
DatastoreService.setDataValue( strPrefix + DSKEY_FQ, conf.getFilterQuery( ) );
DatastoreService.setDataValue( strPrefix + DSKEY_TEMPLATE, conf.getTemplate( ) );
DatastoreService.setDataValue( strPrefix + DSKEY_MAPPING,
conf.getExtraMappingQuery( ) ? SolrConstants.CONSTANT_TRUE : SolrConstants.CONSTANT_FALSE );
List<String> listAddonBeanNames = conf.getAddonBeanNames();
for ( int i = 0; i < listAddonBeanNames.size(); i++ ) {
DatastoreService.setDataValue( strPrefix + DSKEY_ADDON_BEANS + i , listAddonBeanNames.get( i ) );
}
List<String> listFilterQuery = conf.getListFilterQuery( );
for ( int i = 0; i < listFilterQuery.size(); i++ ) {
DatastoreService.setDataValue( strPrefix + DSKEY_FQ_LIST + i , listFilterQuery.get( i ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,13 @@ public static Map<String, Object> getSearchResultModel(HttpServletRequest reques
// }
// }
}
facetQuery = new String[facetQueryTmp.size()];
facetQuery = facetQueryTmp.toArray(facetQuery);

if ( StringUtils.isNotBlank( conf.getFilterQuery( ) ) )
{
int nNewLength = ( facetQuery == null ) ? 1 : ( facetQuery.length + 1 );
String[] newFacetQuery = new String[nNewLength];

for ( int i = 0; i < ( nNewLength - 1 ); i++ )
{
newFacetQuery[i] = facetQuery[i];
}

newFacetQuery[newFacetQuery.length - 1] = conf.getFilterQuery( );
facetQuery = newFacetQuery;
}

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


boolean bEncodeUri = Boolean.parseBoolean(AppPropertiesService.getProperty(PROPERTY_ENCODE_URI,
Boolean.toString(DEFAULT_ENCODE_URI)));
Expand Down