Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7984025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:08:17+00:00 2026-06-04T11:08:17+00:00

This is a cross-post of https://groups.google.com/d/topic/google-appengine/97LY3Yfd_14/discussion I’m working with the new full text search

  • 0

This is a cross-post of https://groups.google.com/d/topic/google-appengine/97LY3Yfd_14/discussion

I’m working with the new full text search service in gae 1.6.6 and I’m having trouble figuring out how to correctly escape my query strings before I pass them off to the search index. The docs mention that certain characters need to be escaped (namely the numeric operators), however they don’t specify how the query parser expects the string to be escaped.

The issue I’m having is two-fold:

  1. Failing to escape the crap out of many characters (more than those that are hinted at in the docs) will cause the parser to raise a QueryException.
  2. When I’ve escaped the query to the point it won’t raise, the numeric operators (>, <, >=, <=) no longer parse correctly (not factored into the search).

I setup a test where I feed string.printable into my_index.search() and found that it would raise QueryException on each of the “printable” control characters, which I’m now stripping out, as well as things that would seem innocent like asterisk, comma, parenthesis, braces, tilde. None of these are mentioned in the docs as needing to be escaped.

So far I’ve tried:

  • cgi.escape()
  • saxutils.escape() with a mapping of ascii to urlencoded equivalents (eg , -> %2C)
  • saxutils.escape() with a mapping of ascii to html entity encoded ascii codes (eg &#123;)
  • urllib.quote_plus()

I’ve gotten the best results so far using url-style(%NN) replacements, but >, <, >=, and <= continue to fail to yield the expected results from the index.
Also, and this doesn’t really seem to have anything to do with the escaping issue, but using NOT in front of a field = value type query seems to not be working as advertised either.

tl;dr

How should I be escaping my queries before sending them to the search service so that the parser doesn’t raise QueryException and my query yields expected results?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:08:18+00:00Added an answer on June 4, 2026 at 11:08 am

    As briefly explained in the documentation, the query parameter is a string that should conform our query language. Which we should document better.

    For now, I recommend you to wrap your queries (or at least some of the words/terms) in double quotes. In that way you would be able to pass all printable characters, but " and \. The following example shows the result.

    import string
    from google.appengine.api.search import Query
    Query('"%s"' % string.printable.replace('"', '').replace('\\', ''))
    

    and you could even pass non printable characters

    Query('"%s"' % ''.join(chr(i) for i in xrange(128)).replace('"','').replace('\\', ''))
    

    EDIT:
    Note that anything that is enclosed in double quotes is an exact match, that is “foo bar” would match against …foo bar… but no …bar foo..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set a property across threads before and I found this post Cross-thread
I built some cross fade rollovers in IE7 using this single image technique: http://jqueryfordesigners.com/image-cross-fade-transition/
I am using this AJAX proxy for cross-domain AJAX requests: http://www.daniweb.com/code/snippet494.html . It works
I am getting this error in chrome XMLHttpRequest cannot load ttp://www.officeyoganyc.com/lists/?p=subscribe. Cross origin requests
I am using this page - http://ecmazing.com/cors.html - to make a cross-origin Ajax request
This is a cross-post from the Mozilla Crypto Dev ML. Hoping that someone on
There is an interesting post over here about this, in relation to cross-application flow
I just came a cross this nice code that makes this scatter matrix plot:
httpd = make_server('', 80, server) webbrowser.open(url) httpd.serve_forever() This works cross platform except when I
This isn't cross-platform code... everything is being performed on the same platform (i.e. endianess

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.