Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-21700

Search API returning duplicate content ids

    XMLWordPrintable

Details

    Description

      We are creating a query with this criterion:

      new CriterionLanguageCode($this->contentHelper->getCurrentLanguageFromRequest())

      where $this->contentHelper->getCurrentLanguageFromRequest() is either 'eng-GB' or 'rus-RU'.

      This is the query object:

      object(eZPublishAPIRepositoryValuesContentQuery)#537 (6) {
      ["criterion"]=>
      object(eZPublishAPIRepositoryValuesContentQueryCriterionLogicalAnd)#538 (4) {
      ["criteria"]=>
      array(4) {
      [0]=>
      object(eZPublishAPIRepositoryValuesContentQueryCriterionContentTypeIdentifier)#539 (3) {
      ["operator"]=>
      string(1) "="
      ["value"]=>
      array(1) {
      [0]=>
      string(14) "in_or_out_post"
      }
      ["target"]=>
      NULL
      }
      [1]=>
      object(eZPublishAPIRepositoryValuesContentQueryCriterionLanguageCode)#531 (3) {
      ["operator"]=>
      string(1) "="
      ["value"]=>
      array(1) {
      [0]=>
      string(6) "eng-GB"
      }
      ["target"]=>
      NULL
      }
      [2]=>
      object(eZPublishAPIRepositoryValuesContentQueryCriterionVisibility)#532 (3) {
      ["operator"]=>
      string(1) "="
      ["value"]=>
      array(1) {
      [0]=>
      int(0)
      }
      ["target"]=>
      NULL
      }
      [3]=>
      object(eZPublishAPIRepositoryValuesContentQueryCriterionField)#536 (3) {
      ["operator"]=>
      string(2) "<="
      ["value"]=>
      int(1379966002)
      ["target"]=>
      string(12) "publish_date"
      }
      }
      ["operator"]=>
      NULL
      ["value"]=>
      NULL
      ["target"]=>
      NULL
      }
      ["sortClauses"]=>
      array(1) {
      [0]=>
      object(eZPublishAPIRepositoryValuesContentQuerySortClauseField)#526 (3) {
      ["direction"]=>
      string(10) "descending"
      ["target"]=>
      string(5) "field"
      ["targetData"]=>
      object(eZPublishAPIRepositoryValuesContentQuerySortClauseTargetFieldTarget)#525 (2) {
      ["typeIdentifier"]=>
      string(14) "in_or_out_post"
      ["fieldIdentifier"]=>
      string(12) "publish_date"
      }
      }
      }
      ["facetBuilders"]=>
      array(0) {
      }
      ["offset"]=>
      int(0)
      ["limit"]=>
      int(20)
      ["spellcheck"]=>
      NULL
      }
      

      This is the query that is being executed:

      SELECT `ezcontentobject`.`id`, `sort_table_0`.`sort_key_int` AS `sort_column_0`, `sort_table_0`.`sort_key_string` AS `sort_column_0_bis` FROM `ezcontentobject` INNER JOIN ezcontentobject_version ON ezcontentobject.id = ezcontentobject_version.contentobject_id INNER JOIN `ezcontentobject_attribute` AS `sort_table_0` ON ( `sort_table_0`.`contentobject_id` = `ezcontentobject`.`id` AND `sort_table_0`.`version` = `ezcontentobject`.`current_version` ) INNER JOIN `ezcontentclass_attribute` AS `cc_attr_0` ON ( `sort_table_0`.`contentclassattribute_id` = `cc_attr_0`.`id` AND `cc_attr_0`.`identifier` = 'publish_date' ) INNER JOIN `ezcontentclass` AS `cc_0` ON ( `cc_attr_0`.`contentclass_id` = `cc_0`.`id` AND `cc_0`.`identifier` = 'in_or_out_post' ) WHERE ( ( `ezcontentobject`.`contentclass_id` IN ( SELECT `id` FROM `ezcontentclass` WHERE `identifier` IN ( 'in_or_out_post' ) ) AND ( `ezcontentobject`.`language_mask` & 2 ) > 0 AND `ezcontentobject`.`id` IN ( SELECT `contentobject_id` FROM `ezcontentobject_tree` WHERE ( `ezcontentobject_tree`.`is_hidden` = 0 AND `ezcontentobject_tree`.`is_invisible` = 0 ) ) AND `ezcontentobject`.`id` IN ( SELECT `contentobject_id` FROM `ezcontentobject_attribute` WHERE ( `contentclassattribute_id` IN ( '310', '327' ) AND `sort_key_int` <= '1379967524' ) ) AND ( `ezcontentobject`.`section_id` IN ( '1' ) OR ( `ezcontentobject`.`contentclass_id` IN ( '27', '35' ) AND `ezcontentobject`.`section_id` IN ( '3' ) ) ) ) AND ezcontentobject_version.status = 1 ) ORDER BY `sort_column_0` DESC, `sort_column_0_bis` DESC LIMIT 20 OFFSET 0;
      

      These are the database results that are being returned:

      id language_mask language_code sort_column_0 sort_column_0_bis
      101 2 eng-GB 1379547145
      100 6 eng-GB 1379547144
      100 6 rus-RU 1379547144
      103 2 eng-GB 1379374347
      102 6 eng-GB 1379374346
      102 6 rus-RU 1379374346
      105 2 eng-GB 1379201549
      104 6 eng-GB 1379201548
      

      As you can see, I'm getting back duplicate ids for any content object that is available in more than one language which causes me to get fewer results than I need. If I set new CriterionLanguageCode('eng-GB'), I expect to only get back results with a language code of 'eng-GB'. How can I ensure this?

      Attachments

        1. SearchCommand.php
          3 kB
        2. PostQuery.php
          4 kB
        3. AbstractQuery.php
          4 kB

        Activity

          People

            Unassigned Unassigned
            gunnstein.lye@ibexa.co Gunnstein Lye
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 7 hours, 25 minutes
                2d 7h 25m