How to find all image objects with multi-language set to it, using ishremote?

I'm trying to use ishremote to FIND all images objects in TridionDocs, which the field DOC-LANGUAGE's value is multiple value (e.g. "zh_CN, en_US, es") rather than single value (e.g. "zh_CN").

If I use Set-IshMetadataFilterField -Name 'DOC-LANGUAGE'-level 'Lng' -ValueType 'Value' -FilterOperator 'In' -Value 'zh_CN, en_US, es', the image object with single language value will also be returned, which is not expected.

Due to we now have a large quantity of image objects with multivalue DOC-LANGUAGE, fetch the whole image objects then inspect every object's  DOC-LANGUAGE property, is actually time-consuming.

Is there any good advices on composing powershell scripts?

emoji
Parents
  • Hi,

    The idea of "Language Applicability" is a powerful concept on single-sourcing content objects in the repository. In essence you are marking an image Logical-Version-Language entity with multiple languages so that it can be repurposed in all kinds of completion operations, status, workflow... this all without actual metadata and image file (and resolutions) duplication saving quite some governance and disk space.

    The "in" clause ishoperator is in essence an OR among "zh_CN" and "en_US" and "es" as you noticed.

    If you want an AND expression, then you need to offer more filter criteria. So every object has to pass all given filters with success. So can you try:

    $metadataFilter = Set-IshMetadataFilterField -Name 'DOC-LANGUAGE'-level 'Lng' -ValueType 'Value' -FilterOperator 'Equal' -Value 'zh_CN' |
                      Set-IshMetadataFilterField -Name 'DOC-LANGUAGE'-level 'Lng' -ValueType 'Value' -FilterOperator 'Equal' -Value 'en_US' |
                      Set-IshMetadataFilterField -Name 'DOC-LANGUAGE'-level 'Lng' -ValueType 'Value' -FilterOperator 'Equal' -Value 'es'
    

    If you need to go through a lot of material, I would advise to recursively iterate the folder structure to have bite-size chunks of information. The one call Find-IshDocumentObj could theoretically pull a full copy of your repository in memory which is for sure not advised. Some inspiration is on https://github.com/RWS/ISHRemote/blob/master/Doc/ReleaseNotes-ISHRemote-0.13.md#sample---custom-actions-across-folder-and-subfolders 

    Best wishes,
    Dave

    emoji
  • Thanks Dave, the code you provided works well.

    I had tried to performed a solr query before receiving your reply.

    curl -o result.csv "">127.0.0.1:8078/.../select

    then search for the "result.csv", to filter out image objs with multiplue values of LNG_DOC-LANGUAGE_STRMV

    emoji
  • Hi ... Perhaps best to avoid direct Solr calls as you in turn skip business logic, security and more

    But what about :) 

    $xmlQuery = @"
        <ishquery>
          <and>
            <ishfield name='DOC-LANGUAGE' level='lng' ishoperator='equal'>en</ishfield>
            <ishfield name='DOC-LANGUAGE' level='lng' ishoperator='equal'>de</ishfield>
          </and>
          <ishsort>
            <ishsortfield name='ISHSCORE' level='none' ishorder='d'/>
            <ishsortfield name='FTITLE' level='logical' ishorder='d'/>
          </ishsort>
          <ishobjectfilters>
            <ishversionfilter>AllVersions</ishversionfilter>
            <ishtypefilter>ISHIllustration</ishtypefilter>
            <ishlanguagefilter>en</ishlanguagefilter>
          </ishobjectfilters>
        </ishquery>
    "@
    (Search-IshDocumentObj -XmlQuery $xmlQuery -MaxHitsToReturn 100).doclanguage
    

    emoji
Reply
  • Hi ... Perhaps best to avoid direct Solr calls as you in turn skip business logic, security and more

    But what about :) 

    $xmlQuery = @"
        <ishquery>
          <and>
            <ishfield name='DOC-LANGUAGE' level='lng' ishoperator='equal'>en</ishfield>
            <ishfield name='DOC-LANGUAGE' level='lng' ishoperator='equal'>de</ishfield>
          </and>
          <ishsort>
            <ishsortfield name='ISHSCORE' level='none' ishorder='d'/>
            <ishsortfield name='FTITLE' level='logical' ishorder='d'/>
          </ishsort>
          <ishobjectfilters>
            <ishversionfilter>AllVersions</ishversionfilter>
            <ishtypefilter>ISHIllustration</ishtypefilter>
            <ishlanguagefilter>en</ishlanguagefilter>
          </ishobjectfilters>
        </ishquery>
    "@
    (Search-IshDocumentObj -XmlQuery $xmlQuery -MaxHitsToReturn 100).doclanguage
    

    emoji
Children
No Data