7 - Using RefinementId

Build 1501 on 14/Nov/2017  This topic last edited on: 15/Mar/2016, at 11:49

This example illustrates how to use the context and the refinementId to return only the list of stories from the search results.

Executing this command:

http://localhost/tark4/do.ashx?cmd=search&name=folderObjects&from=0&count=10&pars=param:jackson

returns 263 results:

<?xml version="1.0" encoding="utf-8" ?>

<result

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns="http://www.teradp.com/schemas/GN4/1/Results.xsd">

  <searchResult n="263" from="0" count="10" context="eJw9xs12Q0AYANDvVZzTRWu...!9olMR" queryTimeSpan="30000">

...

    <categories>

     <Category type="Source" id="cSource/16867630274464995265" title="story" occurrences="162" state="Displayed" />

     <Category type="Source" id="cSource/16869313064066963393" title="image" occurrences="62" state="Displayed" />

     <Category type="Source" id="cSource/16870158577805744065" title="video" occurrences="38" state="Displayed" />

     <Category type="Source" id="cSource/16870151980768909249" title="audio" occurrences="1" state="Displayed" />

 

The context is returned in the searchResult node:

context="eJw9xs12Q0AYANDvVZzTRWulaLFEiVCENKXZ9GDGP4MxkeTpm1VX987w3GZFR8n4Aj3gEUZAuMxYv8JUkxGvTQEC9HgYsofZNC3k!ggFoMUAI77gBdD*njaKZ8Du1W596m2tHsWp2t8tIs0*HHL1bz6KMaulIxGS43CPo6BcXg1zVkKWmrLSnHsWeHRiufVOrHkkbie!VXtDXSfK!MTzpYgpJ5E7eFvGr!ZeS6eLVYlh7jmHc!NrJ4QaUga6GnzVOaoSa9nZH3wnR*ouRLc!NmTN8ZwlzQuOFyTlU!T1wK5!4Q!9olMR

 

The refinement ids for each object type are found in the <categories> node as type Source:

<Category type="Source" id="cSource/16867630274464995265" title="story" occurrences="162" state="Displayed" />

TRY THIS:

To retrieve only the 162 stories from the results, add the context parameter and the refinementId for the story source:

http://localhost/tark4/do.ashx?cmd=search&name=folderObjects&from=0&count=10&pars=param:jackson&context=eJw9xs12Q0AYANDvVZzTRWulaLFEiVCENKXZ9GDGP4MxkeTpm1VX987w3GZFR8n4Aj3gEUZAuMxYv8JUkxGvTQEC9HgYsofZNC3k!ggFoMUAI77gBdD*njaKZ8Du1W596m2tHsWp2t8tIs0*HHL1bz6KMaulIxGS43CPo6BcXg1zVkKWmrLSnHsWeHRiufVOrHkkbie!VXtDXSfK!MTzpYgpJ5E7eFvGr!ZeS6eLVYlh7jmHc!NrJ4QaUga6GnzVOaoSa9nZH3wnR*ouRLc!NmTN8ZwlzQuOFyTlU!T1wK5!4Q!9olMR&refinementid=%2BcSource/16867630274464995265

NOTE: The '+' character cannot be written in the URL, you must use the character code, '%2B'

The 162 story results are returned:

<searchResult n="162" from="0" count="10" context="eJw9xstWgkAYAOD*...!m71A3!n01rV" queryTimeSpan="30000">

   ...      

  <categories>

      <Category type="Source" id="cSource/16867630274464995265" title="story" occurrences="162" state="Refined" />

NOTE: the <categories> node reflects that the results have been refined to only stories.

TRY THIS:

To exclude the 162 stories from these results, use the syntax:

http://localhost/tark4/do.ashx?cmd=search&name=folderObjects&from=0&count=10&pars=param:jackson&context=eJw9xs12Q0AYANDvVZzTRWulaLFEiVCENKXZ9GDGP4MxkeTpm1VX987w3GZFR8n4Aj3gEUZAuMxYv8JUkxGvTQEC9HgYsofZNC3k!ggFoMUAI77gBdD*njaKZ8Du1W596m2tHsWp2t8tIs0*HHL1bz6KMaulIxGS43CPo6BcXg1zVkKWmrLSnHsWeHRiufVOrHkkbie!VXtDXSfK!MTzpYgpJ5E7eFvGr!ZeS6eLVYlh7jmHc!NrJ4QaUga6GnzVOaoSa9nZH3wnR*ouRLc!NmTN8ZwlzQuOFyTlU!T1wK5!4Q!9olMR&refinementid=-cSource/16867630274464995265

The remaining 101 results are returned:

<searchResult n="101" from="0" count="10" context="eJw9xstyg...MH23!oE*qata1w__" queryTimeSpan="30000">

...

 

 <categories>

        <Category type="Source" id="cSource/16867630274464995265"

                 title="story" occurrences="0" state="Excluded" />

        <Category type="Source" id="cSource/16869313064066963393"

                 title="image" occurrences="62" state="Displayed" />

        <Category type="Source" id="cSource/16870158577805744065"

                 title="video" occurrences="38" state="Displayed" />

        <Category type="Source" id="cSource/16870151980768909249"

                 title="audio" occurrences="1" state="Displayed" />

 

NOTE: the <categories> node reflects that the results Excluded the story objects.

TRY THIS:

To clear all refinements and return the full context results, use the syntax:

http://localhost/tark4/do.ashx?cmd=search&name=folderObjects&from=0&count=10&pars=param:jackson&context=eJw9xs12Q0AYANDvVZzTRWulaLFEiVCENKXZ9GDGP4MxkeTpm1VX987w3GZFR8n4Aj3gEUZAuMxYv8JUkxGvTQEC9HgYsofZNC3k!ggFoMUAI77gBdD*njaKZ8Du1W596m2tHsWp2t8tIs0*HHL1bz6KMaulIxGS43CPo6BcXg1zVkKWmrLSnHsWeHRiufVOrHkkbie!VXtDXSfK!MTzpYgpJ5E7eFvGr!ZeS6eLVYlh7jmHc!NrJ4QaUga6GnzVOaoSa9nZH3wnR*ouRLc!NmTN8ZwlzQuOFyTlU!T1wK5!4Q!9olMR&refinementid=cSource/16867630274464995265

The complete 263 results are returned:

<searchResult n="263" from="0" count="10" context="eJw9xs12Q0AYANDvVZzTRWu...!9olMR">

...

TRY THIS:

As a last example, given that the <categories>  node includes:

   <Category type="People" id="cPeople/10425802659562253727"

           title="Rich Rundles" occurrences="6" state="Displayed" />

   <Category type="People" id="cPeople/13163860737112781871"

           title="Steven Jackson" occurrences="6" state="Displayed" />

   <Category type="People" id="cPeople/13250368167757173146"

           title="Janet Jackson" occurrences="5" state="Displayed" />

   

To return only those results containing 'Janet Jackson', add the context and refinementId parameters:

http://localhost/tark4/do.ashx?cmd=search&name=folderObjects&from=0&count=10&pars=param:jackson&context=eJw9xs12Q0AYANDvVZzTRWulaLFEiVCENKXZ9GDGP4MxkeTpm1VX987w3GZFR8n4Aj3gEUZAuMxYv8JUkxGvTQEC9HgYsofZNC3k!ggFoMUAI77gBdD*njaKZ8Du1W596m2tHsWp2t8tIs0*HHL1bz6KMaulIxGS43CPo6BcXg1zVkKWmrLSnHsWeHRiufVOrHkkbie!VXtDXSfK!MTzpYgpJ5E7eFvGr!ZeS6eLVYlh7jmHc!NrJ4QaUga6GnzVOaoSa9nZH3wnR*ouRLc!NmTN8ZwlzQuOFyTlU!T1wK5!4Q!9olMR&refinementid=%2CcPeople/13250368167757173146