[Geoserver-users] CQL Filter (new user)

I'm trying to use a cql_filter for an Ajax request to access table data.

var myrequest = "http://xxxxxx.xxxx:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter="\+myFilter;

myFilter attempts
  "bm_end>='2010-04-23'" OR
  "bm_end>='2010-04-23' && owner_id<>1" OR
  "bm_end>='2010-04-23' && owner_id!=1"

Neither of the filters above seem to be working properly - no errors but not the correct results either.

Is the date format correct?

Where is this stuff documented including date comparisons?

What am I doing wrong?

Thanks,
Joe

On Apr 23, 2010, at 8:49 AM, Joseph Wolter wrote:

I'm trying to use a cql_filter for an Ajax request to access table data.

var myrequest = "http://xxxxxx.xxxx:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter=&quot;\+myFilter;

myFilter attempts
"bm_end>='2010-04-23'" OR
"bm_end>='2010-04-23' && owner_id<>1" OR
"bm_end>='2010-04-23' && owner_id!=1"

Neither of the filters above seem to be working properly - no errors but not the correct results either.

Is the date format correct?

Where is this stuff documented including date comparisons?

What am I doing wrong?

Thanks,
Joe

I'm not very familiar with GeoServer's implementation of CQL, but there's a good description of the basic CQL language itself at http://zing.z3950.org/cql/intro.html.

I think that GeoServer uses CQL-Java, http://zing.z3950.org/cql/java/. You'd probably have to dig in more there to find out about what kinds of date operations it supports.

There's also some interesting discussion at http://zing.z3950.org/cql/profiles.html about extending CQL outside of its bibliographic roots. (CQL originated as a query language for library resources.) Spatial and date searches are mentioned specifically.

alex

The implementation is part of the geotools project.

There are some examples here (including dates):
- uDig : Confluence

On 24/04/2010, at 12:03 AM, Alex Dean wrote:

On Apr 23, 2010, at 8:49 AM, Joseph Wolter wrote:

I'm trying to use a cql_filter for an Ajax request to access table data.

var myrequest = "http://xxxxxx.xxxx:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter=&quot;\+myFilter;

myFilter attempts
"bm_end>='2010-04-23'" OR
"bm_end>='2010-04-23' && owner_id<>1" OR
"bm_end>='2010-04-23' && owner_id!=1"

Neither of the filters above seem to be working properly - no errors but not the correct results either.

Is the date format correct?

Where is this stuff documented including date comparisons?

What am I doing wrong?

Thanks,
Joe

I'm not very familiar with GeoServer's implementation of CQL, but there's a good description of the basic CQL language itself at ZING - A Gentle Introduction to CQL.

I think that GeoServer uses CQL-Java, ZING - CQL-Java: a free CQL compiler for Java. You'd probably have to dig in more there to find out about what kinds of date operations it supports.

There's also some interesting discussion at ZING - CQL - Profiling New Relations and Modifiers about extending CQL outside of its bibliographic roots. (CQL originated as a query language for library resources.) Spatial and date searches are mentioned specifically.

alex
alex
------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Jody,

I've been to that site and tried that format but it generates an error.

This Generates and error:
http://biomap.wisc.edu:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter=bm_end AFTER '2010-04-23' AND owner_id<>7

This works in the URL and returns FIVE records all with the owner id equal to 1 - which is correct.
http://biomap.wisc.edu:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter=bm_end&gt;=&#39;2010\-04\-23&#39; AND owner_id<>7

When I use the same URL for an AjaxRequest in javascript it fails.
   StartAjaxRequest("loadBiomassVectorLayer");
   ajaxRequest.open("GET", theWFS + encodeURIComponent(myrequest), true);
   ajaxRequest.send(null);

if I display an alert in loadBiomassVectorLayer() for ajaxRequest.readyState == 1 I usually get the exception:
--> loadBiomassVectorLayer() parse failed:
--> e.message: parseJSON
--> ajaxRequest.responseText: Some unexpected error occurred. Error text was: HTTP Error 400: Bad Request

If I do NOT display the alert then most of the time the parser generates an uncaught exception. If the parser does succeed the result is only ONE record where owner_id=7 (the filter was owner_id<>7)

The other problem I'm having is that it gets to loadBiomassVectorLayer() three times where ajaxRequest.readyState == 4

Do you know what is going on here?

Thanks,
Joe

On 04/26/10, Jody Garnett <jody.garnett@anonymised.com> wrote:

The implementation is part of the geotools project.

There are some examples here (including dates):
- http://udig.refractions.net/confluence/display/EN/Common+Query+Language

On 24/04/2010, at 12:03 AM, Alex Dean wrote:

Format is cql_filter=bm_end AFTER 2010-04-23T00:00:00Z

You also may need to escape the parameter value string for the HTTP server to correctly interpret it:

var myFilter = escape("bm_end AFTER 2010-04-23T00:00:00Z");

var myrequest = "http://xxxxxx.xxxx:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter=&quot;\+myFilter;

hope that helps.
Gabriel

On 4/26/10 3:53 PM, Joseph Wolter wrote:

Jody,

I've been to that site and tried that format but it generates an error.

This Generates and error:
http://biomap.wisc.edu:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter=bm_end AFTER '2010-04-23' AND owner_id<>7

This works in the URL and returns FIVE records all with the owner id equal to 1 - which is correct.
http://biomap.wisc.edu:8080/geoserver/wfs?&outputformat=json&request=GetFeature&version=1.1.0&typeName=Biofuels:bm_user&extractfields:true&cql_filter=bm_end&gt;=&#39;2010\-04\-23&#39; AND owner_id<>7

When I use the same URL for an AjaxRequest in javascript it fails.
    StartAjaxRequest("loadBiomassVectorLayer");
    ajaxRequest.open("GET", theWFS + encodeURIComponent(myrequest), true);
    ajaxRequest.send(null);

if I display an alert in loadBiomassVectorLayer() for ajaxRequest.readyState == 1 I usually get the exception:
--> loadBiomassVectorLayer() parse failed:
--> e.message: parseJSON
--> ajaxRequest.responseText: Some unexpected error occurred. Error text was: HTTP Error 400: Bad Request

If I do NOT display the alert then most of the time the parser generates an uncaught exception. If the parser does succeed the result is only ONE record where owner_id=7 (the filter was owner_id<>7)

The other problem I'm having is that it gets to loadBiomassVectorLayer() three times where ajaxRequest.readyState == 4

Do you know what is going on here?

Thanks,
Joe

On 04/26/10, Jody Garnett<jody.garnett@anonymised.com> wrote:

The implementation is part of the geotools project.

There are some examples here (including dates):
- http://udig.refractions.net/confluence/display/EN/Common+Query+Language

On 24/04/2010, at 12:03 AM, Alex Dean wrote:

------------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.