google custom search api complex search terms
google-custom-search, parameters
Solution
The parameters are described here.
q (string) The search expression.
exactTerms (string) Identifies a phrase that all documents in the search results must contain.
excludeTerms (string) Identifies a word or phrase that should not appear in any documents in the search results.
orTerms (string) Provides additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms.
And the different Boolean Operators are described here.
AND includeTerms=(phrase%20one).(phrase%20two)
NOT q=key1%20(-key2)
OR excludeTerms=key1|key2 orTerms=key1|key2
() lr=-(lang_fr|lang_it)
By that you could call `q=john%20doe&orTerms=wikipedia|imdb` and this will result documents containing `john AND doe AND ( wikipedia OR imbd )`.
Something what I did not expect was `q=&exactTerms=(john).(doe).(wikipedia)` (46 results) returns the same as `q="john%20doe%20wikipedia"` (46 results). I thought it would result the same as `q="john"%20"doe"%20"wikipedia"` (153000 results). So it is sometimes more a CONCAT than an AND operator or `exactTerms` is simply not able to support multiple keywords.
Problem
The program I am writing needs to execute complex search queries. An example would be (blue AND jeans AND NOT (cheap || expensive)) . How can I do this. I know there are parameters such as hq and exclude and orTerms (or just the boolean operator), but I don't know how to combine them, or if they can be combined for that matter. Thanks a bunch