Regarding Cursor Problem in SEARCH API

123 views
Skip to first unread message

Ananthakrishnan Venkatasubramanian

unread,
May 15, 2012, 3:50:34 PM5/15/12
to google-a...@googlegroups.com
Hi,

I am using SEARCH API to perform text search in my application developed using Google AppEngine (Platform: JAVA). I am facing problems with the cursor.

Initially I won't have the cursor string and so by using following codes I am able to get first set of records that I needed along with the cursor string.

Code:

query = Query.newBuilder()

        .setOptions( QueryOptions.newBuilder().setLimit( limit ).setCursor( Cursor.newBuilder().build() ).build() )

        .build( queryString );

searchResults = getIndex( accountPin ).search( query );

nextCursor = searchResults.getCursor().toWebSafeString();

Result Cursor (nextCursor):

false:CqADCuUBCswB9wUnngv/////c35zdGFnaW4tY21zAP//AIuSX19mdHNfXwD//wCiYXBwZW5naW5lAP//AIyLkmluZGV4AP//AKJNUDUwVlYA//8AjIuSZG9jX2lkAP//AKI4UUk3NDQA//8AjIA4UUk3NDQA//8AAP8B//6MgYyLnpiWkdKckoz/AHRtoKCZi4ygoP8AXZ6Pj5qRmJaRmv8Ac3RtlpGbmof/AF2yr8rPqan/AHN0bZuQnKCWm/8AXceutsjLy/8Ac3/HrrbIy8v/AP/+EAohwwIDw+6dfww5AAAAAPRh2PpIARINRG9jdW1lbnRJbmRleBqfAShBTkQgKElTICJjdXN0b21lcl9uYW1lIiAiYXBwZW5naW5lIikgKElTICJncm91cF9uYW1lIiAic35zdGFnaW4tY21zIikgKElTICJuYW1lc3BhY2UiICIiKSAoSVMgImluZGV4X25hbWUiICJNUDUwVlYiKSAoT1IgKFFUICJ0ZXN0IikgKElTICJfX2dhdG9tX18iICJ0ZXN0IikpKUoFCABA6Ac=

Is the result cursor which I showed above is a websafestring? I don't think so.

If it is a websafestring, I should be able to put as parameter in URL and get the subsequent records.

For the subsequent requests, I will use the following query.

CODE: 

query = Query

        .newBuilder()

        .setOptions(

         QueryOptions.newBuilder().setLimit( limit ).setCursor( Cursor.newBuilder().build( nextCursor ) ).build() )

        .build( queryType + queryString );

But when I try with the cursor what I have showed, its giving me an exception.

SAMPLE URL: http://example.appspot.com/?queryType=all&queryString=test&limit=10&cursor=false:CqADCuUBCswB9wUnngv/////c35zdGFnaW4tY21zAP//AIuSX19mdHNfXwD//wCiYXBwZW5naW5lAP//AIyLkmluZGV4AP//AKJNUDUwVlYA//8AjIuSZG9jX2lkAP//AKI4UUk3NDQA//8AjIA4UUk3NDQA//8AAP8B//6MgYyLnpiWkdKckoz/AHRtoKCZi4ygoP8AXZ6Pj5qRmJaRmv8Ac3RtlpGbmof/AF2yr8rPqan/AHN0bZuQnKCWm/8AXceutsjLy/8Ac3/HrrbIy8v/AP/ EAohwwIDw 6dfww5AAAAAPRh2PpIARINRG9jdW1lbnRJbmRleBqfAShBTkQgKElTICJjdXN0b21lcl9uYW1lIiAiYXBwZW5naW5lIikgKElTICJncm91cF9uYW1lIiAic35zdGFnaW4tY21zIikgKElTICJuYW1lc3BhY2UiICIiKSAoSVMgImluZGV4X25hbWUiICJNUDUwVlYiKSAoT1IgKFFUICJ0ZXN0IikgKElTICJfX2dhdG9tX18iICJ0ZXN0IikpKUoFCABA6Ac=

Exception:

at com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:115)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:42)
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:418)
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:297)

I have used URLEncoder and URLDecoder for the cursor string.....But that will not work....Since it will replace '+' sign with empty space.

Please suggest me a solution to fix this problem.





Ioannis Antonellis

unread,
May 15, 2012, 4:12:08 PM5/15/12
to Google App Engine
There is an open issue on this
http://code.google.com/p/googleappengine/issues/detail?id=7489&q=Component%3DFullTextSearch&sort=component&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log
that has been acknowledged as defect

Please flag it too...


On May 15, 3:50 pm, Ananthakrishnan Venkatasubramanian
<ananthakrishnan.venkatasubraman...@a-cti.com> wrote:
> Hi,
>
> I am using SEARCH API to perform text search in my application developed
> using Google AppEngine (Platform: JAVA). I am facing problems with the
> cursor.
>
> Initially I won't have the cursor string and so by using following codes I
> am able to get first set of records that I needed along with the cursor
> string.
>
> *Code:*
>
> query = Query.newBuilder()
>
>             .setOptions( QueryOptions.newBuilder().setLimit( limit
> ).setCursor( Cursor.newBuilder().build() ).build() )
>
>             .build( queryString );
>
> searchResults = getIndex( accountPin ).search( query );
>
> nextCursor = searchResults.getCursor().toWebSafeString();
>
> *Result Cursor (nextCursor):*
>
> false:CqADCuUBCswB9wUnngv/////c35zdGFnaW4tY21zAP//AIuSX19mdHNfXwD//wCiYXBwZW5naW5lAP//AIyLkmluZGV4AP//AKJNUDUwVlYA//8AjIuSZG9jX2lkAP//AKI4UUk3NDQA//8AjIA4UUk3NDQA//8AAP8B//6MgYyLnpiWkdKckoz/AHRtoKCZi4ygoP8AXZ6Pj5qRmJaRmv8Ac3RtlpGbmof/AF2yr8rPqan/AHN0bZuQnKCWm/8AXceutsjLy/8Ac3/HrrbIy8v/AP/+EAohwwIDw+6dfww5AAAAAPRh2PpIARINRG9jdW1lbnRJbmRleBqfAShBTkQgKElTICJjdXN0b21lcl9uYW1lIiAiYXBwZW5naW5lIikgKElTICJncm91cF9uYW1lIiAic35zdGFnaW4tY21zIikgKElTICJuYW1lc3BhY2UiICIiKSAoSVMgImluZGV4X25hbWUiICJNUDUwVlYiKSAoT1IgKFFUICJ0ZXN0IikgKElTICJfX2dhdG9tX18iICJ0ZXN0IikpKUoFCABA6Ac=
>
> Is the result cursor which I showed above is a *websafestring*? I don't
> think so.
>
> If it is a *websafestring, *I should be able to put as parameter in URL and
> get the subsequent records.
>
> For the subsequent requests, I will use the following query.
>
> *CODE:*
>
> query = Query
>
>            .newBuilder()
>
>            .setOptions(
>
>             QueryOptions.newBuilder().setLimit( limit ).setCursor(
> Cursor.newBuilder().build( nextCursor ) ).build() )
>
>            .build( queryType + queryString );
>
> But when I try with the cursor what I have showed, its giving me an
> exception.
>
> *SAMPLE URL:*http://example.appspot.com/?queryType=all&queryString=**
> test&limit=10&cursor=false:**CqADCuUBCswB9wUnngv/////**c35zdGFnaW4tY21zAP//*
> *AIuSX19mdHNfXwD//**wCiYXBwZW5naW5lAP//**AIyLkmluZGV4AP//AKJNUDUwVlYA//**
> 8AjIuSZG9jX2lkAP//**AKI4UUk3NDQA//8AjIA4UUk3NDQA//**
> 8AAP8B//6MgYyLnpiWkdKckoz/**AHRtoKCZi4ygoP8AXZ6Pj5qRmJaRmv**
> 8Ac3RtlpGbmof/AF2yr8rPqan/**AHN0bZuQnKCWm/8AXceutsjLy/**8Ac3/HrrbIy8v/AP/<http://29.stagin-cms.appspot.com/services/data/v1.0/objects/search/?a...> EAohwwIDw
> 6dfww5AAAAAPRh2PpIARINRG9jdW1l**bnRJbmRleBqfAShBTkQgKElTICJjdX**
> N0b21lcl9uYW1lIiAiYXBwZW5naW5l**IikgKElTICJncm91cF9uYW1lIiAic3**
> 5zdGFnaW4tY21zIikgKElTICJuYW1l**c3BhY2UiICIiKSAoSVMgImluZGV4X2**
> 5hbWUiICJNUDUwVlYiKSAoT1IgKFFU**ICJ0ZXN0IikgKElTICJfX2dhdG9tX1**
> 8iICJ0ZXN0IikpKUoFCABA6Ac=
>
> *Exception:*
>
> at com.google.appengine.api.**urlfetch.URLFetchServiceImpl.**conver
> tApplicationException(**URLFetchServiceImpl.java:115)
> at com.google.appengine.api.**urlfetch.URLFetchServiceImpl.**fetch(
> URLFetchServiceImpl.**java:42)
> at com.google.apphosting.utils.**security.urlfetch.**URLFetchServic
> eStreamHandler$**Connection.fetchResponse(**URLFetchServiceStreamHandler.**
> java:418)
> at com.google.apphosting.utils.**security.urlfetch.**URLFetchServic
> eStreamHandler$**Connection.getInputStream(**URLFetchServiceStreamHandler.**
> java:297)*
> *
>
> *I have used URLEncoder and URLDecoder for the cursor string.....But that
> will not work....Since it will replace '+' sign with empty space.*
>
> *Please suggest me a solution to fix this problem.*
Reply all
Reply to author
Forward
0 new messages