Skip to content

Commit

Permalink
Merge pull request #181 from ezsystems/EZP-23644
Browse files Browse the repository at this point in the history
Fix EZP-23644: add proper handling for hidden nodes in subtree fetches a...
  • Loading branch information
andrerom committed Mar 23, 2015
2 parents d6f40c1 + adeb87c commit ce64d88
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
7 changes: 5 additions & 2 deletions classes/ezfezpsolrquerybuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra
$params['Filter'] = array( $params['Filter'] );
}

$pathFieldName = eZSolr::getMetaFieldName( $ignoreVisibility ? 'path' : 'visible_path' );


$filterQuery = array();
Expand All @@ -191,7 +192,7 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra
$subtreeQueryParts = array();
foreach ( $subtrees as $subtreeNodeID )
{
$subtreeQueryParts[] = eZSolr::getMetaFieldName( 'path' ) . ':' . $subtreeNodeID;
$subtreeQueryParts[] = $pathFieldName . ':' . $subtreeNodeID;
}

$filterQuery[] = implode( ' OR ', $subtreeQueryParts );
Expand Down Expand Up @@ -1533,6 +1534,8 @@ protected function policyLimitationFilterQuery( $limitation = null, $ignoreVisib
$filterQuery = false;
$policies = array();

$pathFieldName = $ignoreVisibility ? eZSolr::getMetaFieldName( 'path' ) : eZSolr::getMetaFieldName( 'visible_path' );

if ( is_array( $limitation ) )
{
if ( empty( $limitation ) )
Expand Down Expand Up @@ -1606,7 +1609,7 @@ protected function policyLimitationFilterQuery( $limitation = null, $ignoreVisib
$pathArray = explode( '/', $pathString );
// we only take the last node ID in the path identification string
$subtreeNodeID = array_pop( $pathArray );
$policyLimitationsOnLocations[] = eZSolr::getMetaFieldName( 'path' ) . ':' . $subtreeNodeID;
$policyLimitationsOnLocations[] = $pathFieldName . ':' . $subtreeNodeID;
if ( isset( $this->searchPluginInstance->postSearchProcessingData['subtree_limitations'] ) )
$this->searchPluginInstance->postSearchProcessingData['subtree_limitations'][] = $subtreeNodeID;
else
Expand Down
7 changes: 6 additions & 1 deletion java/solr/ezp-default/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

<!-- A Trie based date field for faster date range queries and date faceting. -->
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

<!--
Note:
These should only be used for compatibility with existing indexes (created with older Solr versions)
Expand Down Expand Up @@ -564,6 +564,11 @@
<field name="meta_is_hidden_b" type="boolean" indexed="true" stored="true" multiValued="true"/>
<field name="meta_is_invisible_b" type="boolean" indexed="true" stored="true" multiValued="true"/>
<field name="meta_priority_si" type="sint" indexed="true" stored="true" multiValued="true"/>
<!-- denormalised fields for hidden and visible path elements -->
<field name="meta_visible_path_si" type="sint" indexed="true" stored="true" multiValued="true"/> <!-- Visible Location path IDs -->
<field name="meta_visible_path_string_ms" type="mstring" indexed="true" stored="true" multiValued="true"/> <!-- Visible Location path string -->
<field name="meta_hidden_path_si" type="sint" indexed="true" stored="true" multiValued="true"/> <!-- Hidden Location path IDs -->
<field name="meta_hidden_path_string_ms" type="mstring" indexed="true" stored="true" multiValued="true"/> <!-- Hidden Location path string -->

<!-- Here, default is used to create a "timestamp" field indicating
When each document was indexed.
Expand Down
27 changes: 26 additions & 1 deletion search/plugins/ezsolr/ezsolr.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ static function getMetaAttributeType( $name, $context = 'search' )
'owner_name' => 'text',
'owner_group_id' => 'sint',
'path' => 'sint',
'object_states' => 'sint'),
'object_states' => 'sint',
'visible_path' => 'sint',
'hidden_path' => 'sint',
'visible_path_string' => 'mstring',
'hidden_path_string' => 'mstring' ),
self::metaAttributes(),
self::nodeAttributes() ),
'facet' => array(
Expand Down Expand Up @@ -465,6 +469,11 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
$mainNodeID = $mainNode->attribute( 'node_id' );
// initialize array of parent node path ids, needed for multivalued path field and subtree filters
$nodePathArray = array();
// eZ Find 5.4+ expanding on nodePathArray, collect them in different visibility arrays
$invisibleNodePathArray = array();
$visibleNodePathArray = array();
$invisibleNodePathString = array();
$visibleNodePathString = array();

//included in $nodePathArray
//$pathArray = $mainNode->attribute( 'path_array' );
Expand All @@ -485,6 +494,16 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
'fieldType' => $fieldType );
}
$nodePathArray[] = $contentNode->attribute( 'path_array' );
if ( $contentNode->attribute( 'is_hidden' ) || $contentNode->attribute( 'is_invisible' ) )
{
$invisibleNodePathArray = array_merge( $invisibleNodePathArray, $contentNode->attribute( 'path_array' ) );
$invisibleNodePathString[]= $contentNode->attribute( 'path_string' );
}
else
{
$visibleNodePathArray = array_merge( $visibleNodePathArray, $contentNode->attribute( 'path_array' ) );
$visibleNodePathString[] = $contentNode->attribute( 'path_string' );
}

}

Expand Down Expand Up @@ -628,6 +647,12 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
$doc->addField( 'meta_main_path_element_' . $key . '_si', $pathNodeID );

}
// Since eZ Find 5.4

$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'visible_path' ), $visibleNodePathArray );
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'visible_path_string' ), $visibleNodePathString );
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'hidden_path' ), $invisibleNodePathArray );
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'hidden_path_string' ), $invisibleNodePathString );

eZContentObject::recursionProtectionStart();

Expand Down

0 comments on commit ce64d88

Please sign in to comment.