Hello all.
I'm making requests to the GCS API, but the queries get run through a spell check and the search terms get changed. I've looked everywhere but it seems there's no way using the GCS API to avoid this?
Example:
If I search for "foobar," the spell check may change it to "foo bar" which isn't what I want to search for.
Any insights would be much appreciated.
J
Hi @jmckenna,
Welcome to Google Cloud Community!
Unfortunately, there is no way to directly disable spell check in the Google Custom Search API. However, there is a workaround that you can use to achieve the desired behavior.
You can use the "spell" parameter in the API request to specify the corrected query. This parameter will override the spell check and allow you to search for the exact terms that you want.
Here is an example of how to use the "spell" parameter:
https://www.googleapis.com/customsearch/v1?cx=YOUR_CX&key=YOUR_API_KEY&q=foobar&spell=foobar
In this example, the "spell" parameter is set to "foobar", which will force the search to use the exact term "foobar" even if the spell check suggests a different term.
Please note that the "spell" parameter is only available in the JSON API response. If you are using the XML API response, you will not be able to use the "spell" parameter to override the spell check.
You may also file a feature request in this link.
Thanks for the reply! That sounds like a satisfactory workaround, but when I tried adding a 'spell' parameter to my JSON query, I received the following:
TypeError: args: ('Got an unexpected keyword argument spell',)
Example query:
{'cx': '<custom_search_key>,
'exactTerms': None,
'q': 'johndoe@example.com',
'spell': 'johndoe@example.com',
'start': 1}
J