<!-- 
RSS generated by JIRA (1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d) at Thu Feb 08 23:09:19 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>FOLIO Jira</title>
    <link>https://folio-org.atlassian.net</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>1001.0.0-SNAPSHOT</version>
        <build-number>100246</build-number>
        <build-date>07-02-2024</build-date>
    </build-info>

<item>
            <title>[FOLIO-922] Searching in repeated fields (arrays) in PostgreSQL JSON records. </title>
                <link>https://folio-org.atlassian.net/browse/FOLIO-922</link>
                <project id="10290" key="FOLIO">FOLIO</project>
                    <description>&lt;p&gt;The issue is how to perform searches for records that contain certain values in the elements of an array. &lt;/p&gt;

&lt;p&gt;They can be search along the lines of object identities for sure, like asking for records that have an element that is an object with certain properties containing certain values:&lt;/p&gt;

&lt;p&gt;For example find within array objects with  a property  &quot;value&quot;: &quot;xyz&quot;&lt;/p&gt;

&lt;p&gt;select * from diku_mod_inventory_storage.instance where jsonb-&amp;gt;&apos;identifiers&apos; @&amp;gt; &apos;[&lt;/p&gt;
{&quot;value&quot;: &quot;9780552142352&quot;}
&lt;p&gt;]&apos;;&lt;/p&gt;

&lt;p&gt;Or with two properties - in this example one of the properties is a reference to the identifier type &quot;ISBN&quot;:&lt;/p&gt;

&lt;p&gt;select * from diku_mod_inventory_storage.instance where jsonb-&amp;gt;&apos;identifiers&apos; @&amp;gt; &apos;[&lt;/p&gt;
{&quot;value&quot;: &quot;9780552142352&quot;, &quot;typeId&quot;: &quot;8261054f-be78-422d-bd51-4ed9f33c3422&quot;}
&lt;p&gt;]&apos;;&lt;/p&gt;

&lt;p&gt;But the question is, can we also somehow search with truncation? That would obviously be needed for searching for authors in the &apos;creators&apos; array. &lt;/p&gt;

&lt;p&gt;And how will it perform?&lt;/p&gt;</description>
                <environment></environment>
        <key id="80500">FOLIO-922</key>
            <summary>Searching in repeated fields (arrays) in PostgreSQL JSON records. </summary>
                <type id="10004" iconUrl="https://folio-org.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10300?size=medium">Sub-task</type>
                            <parent id="80503">FOLIO-921</parent>
                                    <priority id="10001" iconUrl="https://dev.folio.org/assets/jira-priority/jira-p2.svg">P2</priority>
                        <status id="6" iconUrl="https://folio-org.atlassian.net/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10001">Duplicate</resolution>
                                                        <assignee accountid="-1">Unassigned</assignee>
                                                                <reporter accountid="5bffed5e2434bf3a1a91d37a">Niels Erik Nielsen</reporter>
                                    <labels>
                            <label>platform-backlog</label>
                    </labels>
                <created>Fri, 3 Nov 2017 10:43:38 +0000</created>
                <updated>Wed, 3 Apr 2019 09:48:51 +0000</updated>
                            <resolved>Wed, 3 Apr 2019 09:48:51 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>5</watches>
                                                                <comments>
                                                            <comment id="190639" author="5ee89462f7aa140abd82d11d" created="Fri, 8 Dec 2017 11:48:06 +0000"  >&lt;p&gt;This shell script searches for all instances where ISBN equals the passed argument &lt;tt&gt;$1&lt;/tt&gt;.&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SERVER=http://localhost:9130
TOKEN=$( curl -D - -H &quot;X-Okapi-Tenant: diku&quot; -H &quot;Content-type: application/json&quot; \
  -d &apos;{&quot;tenant&quot;:&quot;diku&quot;,&quot;username&quot;:&quot;diku_admin&quot;,&quot;password&quot;:&quot;admin&quot;}&apos; $SERVER/authn/login | grep -i &quot;^x-okapi-token: &quot; )
ISBNID=$( curl -H &quot;$TOKEN&quot; -H &quot;X-Okapi-Tenant: diku&quot; $SERVER/identifier-types?query=name==ISBN | sed -E -n &apos;s/.*&quot;id&quot;\s*:\s*&quot;([^&quot;]+)&quot;.*/\1/p&apos; )
ISBN=$1
CQL=$(echo &apos;identifiers==&quot;*\&quot;value\&quot;: \&quot;ISBN\&quot;, \&quot;identifierTypeId\&quot;: \&quot;ISBNID\&quot;*&quot;&apos; | sed &quot;s/ISBN/$ISBN/; s/ISBNID/$ISBNID/&quot; );
echo $CQL
CQL=$(echo &quot;$CQL&quot; | sed &apos;s/ /%20/g; s/&quot;/%22/g; s/\\/%5c/g&apos;)  # urlencode
curl -H &quot;$TOKEN&quot; -H &quot;X-Okapi-Tenant: diku&quot; $SERVER/instance-storage/instances?query=$CQL
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is an example CQL query:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;identifiers==&quot;*\&quot;value\&quot;: \&quot;9783782791120\&quot;, \&quot;identifierTypeId\&quot;: \&quot;8261054f-be78-422d-bd51-4ed9f33c3422\&quot;*&quot;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;tt&gt;value&lt;/tt&gt; is always before &lt;tt&gt;identifierTypeId&lt;/tt&gt; because shorter keys are stored before longer keys: &lt;a href=&quot;https://www.postgresql.org/docs/current/static/datatype-json.html&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.postgresql.org/docs/current/static/datatype-json.html&lt;/a&gt;&lt;/p&gt;</comment>
                                                            <comment id="190642" author="5ee89462f7aa140abd82d11d" created="Fri, 18 Jan 2019 16:36:43 +0000"  >&lt;p&gt;We may use a trigger that automatically extracts the values and writes them into read only fields:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
UPDATE instance SET jsonb=jsonb_set(jsonb_set(
  jsonb,
  &lt;span class=&quot;code-quote&quot;&gt;&apos;{identifiervalues}&apos;&lt;/span&gt;,
  ( SELECT COALESCE(jsonb_agg(value), &lt;span class=&quot;code-quote&quot;&gt;&apos;[]&apos;&lt;/span&gt;)
    FROM jsonb_to_recordset(jsonb-&amp;gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;)
    AS x(key text, value text)
    WHERE value IS NOT NULL
  )),
  &lt;span class=&quot;code-quote&quot;&gt;&apos;{identifiervaluesisbn}&apos;&lt;/span&gt;,
  ( SELECT COALESCE(jsonb_agg(value), &lt;span class=&quot;code-quote&quot;&gt;&apos;[]&apos;&lt;/span&gt;)
    FROM jsonb_to_recordset(jsonb-&amp;gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;)
      AS y(key text, value text)
    WHERE key=&lt;span class=&quot;code-quote&quot;&gt;&apos;26978ebf-eceb-4537-b5a7-9482c2cce893&apos;&lt;/span&gt;
   )
);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A record like this&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
{
  &lt;span class=&quot;code-quote&quot;&gt;&quot;identifiers&quot;&lt;/span&gt;: 
  [{&lt;span class=&quot;code-quote&quot;&gt;&quot;key&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;26978ebf-eceb-4537-b5a7-9482c2cce893&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;020163385X&quot;&lt;/span&gt;},
   {&lt;span class=&quot;code-quote&quot;&gt;&quot;key&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;26978ebf-eceb-4537-b5a7-9482c2cce893&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;9780201633856&quot;&lt;/span&gt;},
   {&lt;span class=&quot;code-quote&quot;&gt;&quot;key&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;1e276ff3-48d5-41c3-483a-58298be393a8&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;ocn294998755&quot;&lt;/span&gt;}
  ]
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;becomes&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
{
  &lt;span class=&quot;code-quote&quot;&gt;&quot;identifiers&quot;&lt;/span&gt;: 
  [{&lt;span class=&quot;code-quote&quot;&gt;&quot;key&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;26978ebf-eceb-4537-b5a7-9482c2cce893&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;020163385X&quot;&lt;/span&gt;},
   {&lt;span class=&quot;code-quote&quot;&gt;&quot;key&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;26978ebf-eceb-4537-b5a7-9482c2cce893&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;9780201633856&quot;&lt;/span&gt;},
   {&lt;span class=&quot;code-quote&quot;&gt;&quot;key&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;1e276ff3-48d5-41c3-483a-58298be393a8&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;ocn294998755&quot;&lt;/span&gt;}
  ],
  &lt;span class=&quot;code-quote&quot;&gt;&quot;identifiervalues&quot;&lt;/span&gt;: [&lt;span class=&quot;code-quote&quot;&gt;&quot;020163385X&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;9780201633856&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;ocn294998755&quot;&lt;/span&gt;],
  &lt;span class=&quot;code-quote&quot;&gt;&quot;identifiervaluesisbn&quot;&lt;/span&gt;: [&lt;span class=&quot;code-quote&quot;&gt;&quot;020163385X&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;9780201633856&quot;&lt;/span&gt;]
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;These new fields can be indexed and used with full text search including right truncation.&lt;/p&gt;</comment>
                                                            <comment id="190645" author="557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d" created="Wed, 3 Apr 2019 09:48:41 +0000"  >&lt;p&gt;Duplicate of 
    &lt;span class=&quot;jira-issue-macro resolved&quot; data-jira-key=&quot;RMB-380&quot; &gt;
                &lt;a href=&quot;https://folio-org.atlassian.net/browse/RMB-380&quot; class=&quot;jira-issue-macro-key issue-link&quot;  title=&quot;implement new approach for searching array-of-strings and array-of-objects fields&quot; &gt;
            &lt;img class=&quot;icon&quot; src=&quot;https://folio-org.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium&quot; /&gt;
            RMB-380
        &lt;/a&gt;
                                                    &lt;span class=&quot;aui-lozenge aui-lozenge-subtle aui-lozenge-success jira-macro-single-issue-export-pdf&quot;&gt;Closed&lt;/span&gt;
            &lt;/span&gt;
&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10002">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="57046">RMB-380</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10003">
                    <name>Relates</name>
                                            <outwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="37561">CQLPG-42</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="55808">MODINVSTOR-182</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10000" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummarycf">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10057" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Development Team</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10144"><![CDATA[Core: Platform]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10019" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|hzy2db:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10020" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10024" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>[CHART] Date of First Response</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 8 Dec 2017 11:48:06 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10025" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>[CHART] Time in Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>