Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-1229

deletedPkQuery feature does not work when pk and uniqueKey field do not have the same value

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.4
    • Labels:
      None

      Description

      Problem doing a delta-import such that records marked as "deleted" in the database are removed from Solr using deletedPkQuery.

      Here's a config I'm using against a mocked test database:

      <dataConfig>
       <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/db"/>
       <document name="tests">
         <entity name="test"
                 pk="board_id"
                 transformer="TemplateTransformer"
                 deletedPkQuery="select board_id from boards where deleted = 'Y'"
                 query="select * from boards where deleted = 'N'"
                 deltaImportQuery="select * from boards where deleted = 'N'"
                 deltaQuery="select * from boards where deleted = 'N'"
                 preImportDeleteQuery="datasource:board">
           <field column="id" template="board-${test.board_id}"/>
           <field column="datasource" template="board"/>
           <field column="title" />
         </entity>
       </document>
      </dataConfig>
      

      Note that the uniqueKey in Solr is the "id" field. And its value is a template board-<PK>.

      I noticed the javadoc comments in DocBuilder#collectDelta it says "Note: In our definition, unique key of Solr document is the primary key of the top level entity". This of course isn't really an appropriate assumption.

        Attachments

        1. SOLR-1229.patch
          0.8 kB
          Noble Paul
        2. SOLR-1229.patch
          2 kB
          Erik Hatcher
        3. SOLR-1229.patch
          2 kB
          Erik Hatcher
        4. tests.patch
          38 kB
          Lance Norskog
        5. SOLR-1229.patch
          3 kB
          Noble Paul
        6. SOLR-1229.patch
          41 kB
          Erik Hatcher
        7. SOLR-1229.patch
          4 kB
          Noble Paul

          Activity

            People

            • Assignee:
              ehatcher Erik Hatcher
              Reporter:
              ehatcher Erik Hatcher
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: