Forums / Extensions / eZ Find / Problem with not main nodes in SearchSubTreeArray

Problem with not main nodes in SearchSubTreeArray

Author Message

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 :)

Nicolas Pastorino

Friday 29 October 2010 7:02:29 am

Hi Serhey,

Which version of eZ Find are you using ?

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Serhey Dolgushev

Saturday 30 October 2010 3:58:17 am

Its 2.2-0

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

Serhey Dolgushev

Thursday 04 November 2010 3:58:01 pm

Hi Paul. I did it: http://issues.ez.no/IssueView.php?Id=17576&activeItem=3

Paul Borgermans

Saturday 06 November 2010 3:08:21 am

Thanks Serhey!

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans