Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2014-02-07 15:27:08

AMRoche
Member
Registered: 2014-02-06
Posts: 4

Advanced Search to return all results that are images

Hi guys, so i'm trying to retrieve all the images which match the search query. To do this i'm using the advanced search, and have the text search part working, but the second part is returning all filetypes.

I've written the following request, but as you can see the request is failing;

string '{
"apiVersion":"1.0",
"sessionId":"SESSION_ID_HERE",
"inParams":{"query":[{"fieldId":17,"conditionId":20,"value":"device"},{"fieldId":19,"conditionId":-1,"value":""}],"exactMatches":"false","fields":{"metadata":"true"}},
"action":"Search.AdvancedSearch"
}' (length=272)
object(stdClass)[125]
  public 'result' =>
    object(stdClass)[130]
      public 'api' => string 'OK' (length=2)
      public 'action' => string 'SEARCH_QUERY_FIELD_CONDITION_REQUIRE_VALUE' (length=42)

when I take out the {"fieldId":19,"conditionId":-1,"value":""} hash, the request works just fine.

My question is as follows;

What would the value be for the value key here?

For reference, here is the relevant section of the GetSearchConfiguration response;

23 =>
        array (size=7)
          0 => string 'File type' (length=9)
          1 => int 19
          2 =>
            array (size=5)
              0 =>
                array (size=3)
                  0 => string 'IS AN IMAGE' (length=11)
                  1 => int -1
                  2 => int 0
              1 =>
                array (size=3)
                  0 => string 'IS AN AUDIO FILE' (length=16)
                  1 => int -2
                  2 => int 0
              2 =>
                array (size=3)
                  0 => string 'IS A VIDEO FILE' (length=15)
                  1 => int -3
                  2 => int 0
              3 =>
                array (size=3)
                  0 => string 'IS A DOCUMENT' (length=13)
                  1 => int -5
                  2 => int 0
              4 =>
                array (size=3)
                  0 => string 'IS AN OTHER FILE TYPE' (length=21)
                  1 => int -6
                  2 => int 0
          3 => int 6
          4 =>

On another note, is there an equivalent to a wildcard "match anything" parameter that I can pass through to the API as a value for the value key, or would I just omit any text searches i'm also sending (In this case, the first hash in the query array)?

Last edited by AMRoche (2014-02-07 15:27:25)

Offline

#2 2014-02-12 14:09:12

AMRoche
Member
Registered: 2014-02-06
Posts: 4

Re: Advanced Search to return all results that are images

To add a response to this, passing though "-1" to both parameters sorts the problem, both returning all filetypes that are images and functioning as a wildcard search.

Offline

#3 2014-02-12 14:52:48

ben
Third Light Staff
From: Third Light
Registered: 2013-06-06
Posts: 66

Re: Advanced Search to return all results that are images

Hi, I'm just looking at this now. Thanks for the extra detail - I'm not sure why that would be the case but will have a look at the code.
Ben

Offline

#4 2014-02-12 16:05:40

ben
Third Light Staff
From: Third Light
Registered: 2013-06-06
Posts: 66

Re: Advanced Search to return all results that are images

Hi again,
In short, what you discovered is the correct thing to do i.e. supply -1 for both conditionId and value. This means you are searching for image files that match any image type.

The section from the GetSearchConfiguration response also contains a large nested array detailing the options for this field (included below). And from this you can infer, for example, that if you want to search only for PNG files then you'd need -1 for the conditionId and 3 for the value.

I hope this helps and apologies for any confusion,
Ben


[
  [
    -1,
    [
      [-1,"All types"],
      [2,"JPEG"],
      [3,"PNG"],
      [1,"GIF"],
      [7,"TIFF"],
      [9,"JPC"],
      [10,"JP2"],
      [21,"TGA"],
      [11,"OpenEXR"],
      [12,"WebP"],
      [13,"WebP"],
      [1002,"AI"],
      [1003,"PSD"],
      [1004,"SVG"],
      [1001,"RAW"]
    ]
  ],
  [
    -2,
    [
      [-2,"All types"],
      [5001,"MP3"],
      [5002,"WAV"],
      [5003,"OGG"],
      [5004,"AAC"],
      [5005,"WMA"]
    ]
  ],
  [
    -3,
    [
      [-3,"All types"],
      [2001,"WMV"],
      [2002,"MOV"],
      [2003,"AVI"],
      [2004,"MPEG-1"],
      [2005,"MPEG-2"],
      [2006,"MPEG-4"],
      [2007,"FLV"],
      [2008,"RealVideo"],
      [2009,"M4V"],
      [2010,"H.264"],
      [2011,"OGV"]
    ]
  ],
  [
    -5,
    [
      [-5,"All types"],
      [3001,"Text"],
      [3002,"Word"],
      [3003,"Excel"],
      [3004,"Powerpoint"],
      [3005,"PDF"],
      [1002,"AI"],
      [3006,"EPS"]
    ]
  ],
  [
    -6,
    []
  ]
]

Offline

Board footer