Skip to main content
Skip table of contents

UC Add Filters to Search [C IG]

Motivation

In order to further narrow down the search results when doing searching we can apply filters to the result. Performance wise, filters give the benefit that these can be cached separately and do not affect the score nor highlighting.

Example

Let’s say that we have three items which all have the metadata field event_type set to some value:

PUT /item?content=metadata&field=event_type

CODE
<ItemSearchDocument xmlns="http://xml.vidispine.com/schema/vidispine">
    <field>
        <name>event_type</name>
        <value>*</value>
    </field>
</ItemSearchDocument>

Gives a result like this

XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ItemListDocument xmlns="http://xml.vidispine.com/schema/vidispine">
    <hits>3</hits>
    <item id="VX-38" start="1200" end="1380">
        <metadata>
            <revision>VX-190,VX-189,VX-192,VX-191,VX-305</revision>
            <timespan start="1200" end="1380">
                <field uuid="91f8a252-2e0d-44b8-a9ce-751dd3bc4602" user="admin" timestamp="2022-05-16T12:41:01.132+02:00" change="VX-305">
                    <name>event_type</name>
                    <value uuid="d553b414-e6d2-4dba-984d-690fc8686d58" user="admin" timestamp="2022-05-16T12:41:01.132+02:00" change="VX-305">goal</value>
                </field>
            </timespan>
        </metadata>
        <timespan start="1200" end="1380"/>
    </item>
    <item id="VX-32" start="-INF" end="+INF">
        <metadata>
            <revision>VX-172,VX-174,VX-173,VX-175,VX-310</revision>
            <timespan start="-INF" end="+INF">
                <field uuid="d5e9b664-96be-48d7-a6a2-a81117295099" user="admin" timestamp="2022-05-16T14:03:16.351+02:00" change="VX-310">
                    <name>event_type</name>
                    <value uuid="f06e329a-d703-4d04-a9fb-e8ec4995a0a9" user="admin" timestamp="2022-05-16T14:03:16.351+02:00" change="VX-310">penalty</value>
                </field>
            </timespan>
        </metadata>
        <timespan start="-INF" end="+INF"/>
    </item>
    <item id="VX-31" start="-INF" end="+INF">
        <metadata>
            <revision>VX-171,VX-166,VX-168,VX-167,VX-311</revision>
            <timespan start="-INF" end="+INF">
                <field uuid="d461ac03-2610-4138-9260-e7b12ee83afe" user="admin" timestamp="2022-05-16T14:03:25.380+02:00" change="VX-311">
                    <name>event_type</name>
                    <value uuid="344ee679-cc8f-4c82-84ad-580ffd39b64f" user="admin" timestamp="2022-05-16T14:03:25.380+02:00" change="VX-311">icing</value>
                </field>
            </timespan>
        </metadata>
        <timespan start="-INF" end="+INF"/>
    </item>
</ItemListDocument>

As seen in the response we get three items matching with the values goal penalty and icing. But in our case we are perhaps only interested in results matching either goal OR penalty. This can be achieved by adding a filter:

PUT /item?content=metadata&field=event_type

CODE
<ItemSearchDocument xmlns="http://xml.vidispine.com/schema/vidispine">
    <filter operation="OR" name="events">
        <field>
            <name>event_type</name>
            <value>penalty</value>
        </field>
        <field>
            <name>event_type</name>
            <value>goal</value>
        </field>
    </filter>
</ItemSearchDocument>

where we set the operation to operation=OR, which gives us the filtered result:

CODE
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ItemListDocument xmlns="http://xml.vidispine.com/schema/vidispine">
    <hits>2</hits>
    <item id="VX-38" start="1200" end="1380">
        <metadata>
            <revision>VX-190,VX-189,VX-192,VX-191,VX-305</revision>
            <timespan start="1200" end="1380">
                <field uuid="91f8a252-2e0d-44b8-a9ce-751dd3bc4602" user="admin" timestamp="2022-05-16T12:41:01.132+02:00" change="VX-305">
                    <name>event_type</name>
                    <value uuid="d553b414-e6d2-4dba-984d-690fc8686d58" user="admin" timestamp="2022-05-16T12:41:01.132+02:00" change="VX-305">goal</value>
                </field>
            </timespan>
        </metadata>
        <timespan start="1200" end="1380"/>
    </item>
    <item id="VX-32" start="-INF" end="+INF">
        <metadata>
            <revision>VX-172,VX-174,VX-173,VX-175,VX-310</revision>
            <timespan start="-INF" end="+INF">
                <field uuid="d5e9b664-96be-48d7-a6a2-a81117295099" user="admin" timestamp="2022-05-16T14:03:16.351+02:00" change="VX-310">
                    <name>event_type</name>
                    <value uuid="f06e329a-d703-4d04-a9fb-e8ec4995a0a9" user="admin" timestamp="2022-05-16T14:03:16.351+02:00" change="VX-310">penalty</value>
                </field>
            </timespan>
        </metadata>
        <timespan start="-INF" end="+INF"/>
    </item>
</ItemListDocument>

Resources

https://apidoc.vidispine.com/latest/item/search.html?#filters

How to

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.