Serhey Dolgushev
|
Friday 29 October 2010 4:49:44 am
Hi everyone! Today i discoverd a troubles with searching non main nodes. I`ll try to explaine the problem: We have object O1 (name: "test"), with multiple locations:
- N1 (main, node_id:101, path:1/2/60/101)
- N2 (node_id:102, path: 1/2/62/102)
- N3 (node_id:103, path: 1/2/63/103)
I`m doing the next:
$solrSearch = new eZSolr();
$searchResult = $solrSearch->search(
'test',
array(
'SearchSubTreeArray' => array( 62 ),
'SpellCheck' => array( true ),
'SearchType' => array( 'fulltext' ),
'SearchLimit' => 10,
'SearchOffset' => 0
)
) $searchResult['SearchResult'] should contain the eZFindResultNode object with node_id = 102. But it contains eZFindResultNode object with node_id = 101. Its because $searchResult['SearchResult'] allways contains just main nodes. In my case i didn`t used score_percent and highlight attributes, so i fixed it the next way:
foreach( $searchResult['SearchResult'] as $key => $node ) {
if( in_array( $parentNodeID, $node->attribute( 'path_array' ) ) === false ) {
$locations = $node->attribute( 'object' )->attribute( 'assigned_nodes' );
foreach( $locations as $locationNode ) {
if( in_array( $parentNodeID, $locationNode->attribute( 'path_array' ) ) === true ) {
$nodeRow = eZContentObjectTreeNode::fetch( $locationNode->attribute( 'node_id' ), false, false );
$findNode = new eZFindResultNode( $nodeRow );
$findNode->setContentObject( new eZContentObject( $nodeRow ) );
$findNode->setAttribute( 'name', $locationNode->attribute( 'name' ) );
$findNode->setAttribute( 'published', $locationNode->attribute( 'published' ) );
$findNode->setAttribute( 'global_url_alias', $locationNode->attribute( 'url_alias' ) );
$findNode->setAttribute( 'language_code', $locationNode->attribute( 'object' )->attribute( 'current_language' ) );
$findNode->setAttribute( 'is_local_installation', true );
$searchResult['SearchResult'][ $key ] = $findNode;
break;
}
}
}
} But i think it will be great if this bug will be fixed in eZ Find, and $searchResult['SearchResult'] will contain no only main nodes :)
|
Paul Borgermans
|
Sunday 31 October 2010 1:23:33 pm
Hi Serhey Can you file a bug report/enhancement request referrring to this thread? Your use case is not the only one, so some flexibility on this should be introduced ... sometimes, the main node is what one really wants. Regards Paul
eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans
|