1. I have corrected the e-mail settings so that outgoing e-mails from these forums should be sent now. If you tried to Register or Reset your Password, please try again!
    Dismiss Notice

Query Strings

Discussion in 'Census: Developer Announcements' started by DanKinney, Dec 9, 2011.

  1. DanKinney

    DanKinney Guest

    A revised version of this thread can be found here:
    http://forums.eq2wire.com/index.php?threads/query-strings-and-commands.212587/


    Each request for data may take an additional query string that allows one to specify parameters for a particular query. These take the standard form of "field=value". Multiple values may be provided separated by the ampersand ("&") character. The "field" portion of a query string corresponds to a particular field within a particular object within the collection. Please refer to the game specific documentation for a description of available fields.

    If the field has a hierarchy, it can be referenced using a dot (".") notation. For example, considering the following data:

    "item": { "id": 4126241497, "typeinfo": { "equip_optional": 1, "name": "expendable", "casttime": 1.0 }}

    In order to find all objects that have the name "expendable" within typeinfo, one would use the following query string:

    ?typeinfo.name=expendable

    If multiple search conditions are provided within the query string, they will be combined as a Boolean ‘AND' operation. For instance, consider the following values within the following query string:

    ?field=]10&field=[50

    This request would return data where the value of the "field" attribute was between 10 and 50 (inclusively).

    <img src="file:///page9image11712" width="4.559998" height="0.720000" />

    Search Modifier

    A modifier may be used in front of the value portion of the Query String to further enhance the results provided. Only one modifier may be used - the second modifier character would be considered to be part of the value.


    Modifier Example Description
    [ field=[10 Include objects where the field value is less than 10
    [ field=[10 Include objects where the field value is less than or equal to 10
    ] field=]10 Include objects where the field value is greater than 10
    ] field=]10 Include objects where the field value is greater than or equal to 10
    [ field=[10 Include objects where the field value is less than 10
    / field=/string/ Include objects where the field contains a particular string
    ^ field=^string Include objects where the field value starts with "string"
    ! field=!string Include objects where the value does NOT match "string"
    * field=*regex Use a regular expression to match values within the field
    Regular expressions, or "regex", provide a great deal of power for searching for objects. Specifically, the system supports Perl-compatible regular expressions. The "/" and "^" modifiers are examples of regular expressions.

    To search for a substring case insensitively, try the following: i/string/

    census.daybreakgames.com/xml/get/eq2/guild/?nam...nt/&c:show=name

    There are a number of resources available to learn about regular expressions, including here, here and here.
     
    Last edited by a moderator: Dec 14, 2016
  2. DanKinney

    DanKinney Guest

    Added link to the Perl-compatible regular expression spec.  While this is the spec that is used, it is not implemented in perl.  The regular expressions are evaluated directly within the database engine at the core of the system for maximum performance.

    -dan

     
  3. NeillM

    NeillM Guest

    The field=^string syntax doesn't seem to be working today, although it can be replicated with field=*^string

     
  4. Lantis

    Lantis Guest

    Did you try with a proper regexp instead (now that the backend supports it)?

     
  5. DanKinney

    DanKinney Guest

    Both should work.  We did muck around with the ^ modifier code when we were doing the regex stuff, but it shouldn't have changed.

    We are still seeing some performance issues because of some internal (I think) issues on our network today.  I'm still trying to get to the bottom of it.

    -dan

     
  6. NeillM

    NeillM Guest

    They both seem to be working now... guess it must have been related to the problems.

     
  7. lokiracer

    lokiracer Guest

    <field=<10Include objects where the field value is less than 10
    Is listed twice.
     
    Last edited by a moderator: Dec 14, 2016
  8. feldon30

    feldon30 Guest

    It's twice as useful as the others. ;) j/k

     
  9. lokiracer

    lokiracer Guest

    Haha. Fair enough, I will now implement a forced usage of =< on my site due to it's usefulness.
     

Share This Page