Google Suggest API : make a query with a prefix - google-suggest

I am playing with http://suggestqueries.google.com/complete/search to make some google suggest queries.
It works fine with "mykeyword" & "mykeyword a" or "mykeyword b". I got good results.
But I would like to make some queries with a prefix, eg : "a mykeyword" in order to get some suggests that start with a 'a" & contains "mykeywords. It works on the google page but not via the API
Any suggestions?

To separate words use %20 or + between them. For a mykeyword:
http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=a%20mykeyword
or
http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=a+mykeyword

Related

Google Cloud, compute.instances.aggregatedList with filter fails

The google cloud API for compute.instances.aggregatedList includes filter argument.
https://cloud.google.com/compute/docs/reference/rest/beta/instances/aggregatedList
I use (status eq "RUNNING") as a filter to view all my running instances.
I would like to have a more elaborate criteria, such as one that uses labels and or other terms, however even the Google documentation terms (that use OR operator) returns an error, For example - even Google documentation example:
(cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell")
fails with error 400:
"message": "Invalid value for field 'filter': ' (cpuPlatform = \"Intel
Skylake\") OR (cpuPlatform = \"Intel Broadwell\")'. Invalid list
filter expression."
it looks as if the '=' signs are not accepted, and AND/OR operators are not accepted.
What is the correct format for this API.
I had the same issue when I used "=" instead of "eq" in google-api-python-client. I required to use labels to filter the aggregated instances list. At first I used
filter="labels.projectid=test-project"
which returned 400 error in aggregated list but was successful if it was queried for instances of specific zone.
I achieved the list successfully when I used filter as
filter="labels.projectid eq \"test-project\""
or
filter = "labels.projectid eq test-project"
I even tested it using REST-Client provided by google and it worked.
Reference: https://issuetracker.google.com/80238913
Even 3 years later Google haven't fixed the bug: OR and AND operators are not supported even it is advertised:
https://cloud.google.com/compute/docs/reference/rest/v1/instances/aggregatedList
Google API is famous for inconsistency and false promises. Just relax and do 2 queries to emulate OR.
For AND operator just omit AND and quote comparison expressions into parentheses:
(name eq 'stage-.*') (labels.env ne "SKIP")
Note I use eq / ne with regex instead of operators =, !=, :.
I ran into a similar error message calling a GCP API. I finally got it to work by making the filter look like this:
fmt.Sprintf("selfLink = \"%s\"", networkLink)
Compute instances list api filter param should work with
(labels.<label_name_1>=<label_value_1>) OR (labels.<label_name_2>=<label_value_2>)
I have found that this string works as a filter within Python:
test_filter = '((labels.test="test-value") AND (labels.test-second="test-second-value")) OR ((labels.test="test-other-value"))'
This filter worked for me:
name eq my-service-v.*
Will return groups like my-service-v112 etc' (even though the name field is nested inside).

Mediawiki: Pages with & and + in Name not working

I discovered a bug in my mediawiki.
When I try to open a page with a + or a & in the name, it end up in a "The Site can't be reached"-Error. In the logs i can see, that i get a high number of HTTP 301 Codes when reaching such a Page. It also translates the characters:
+ into %2B
& into %26
But is does seem like it's not getting translated back? I'm also not using any mod_rewrite Code, well atleast none that I know of.
https://www.mediawiki.org/wiki/Manual%3aShort_URL#URL_like_-_example.com.2FPage_title
This describes my Problem (under Troubleshooting), but / works fine. But as I mentiond, I don't use any URL rewriting.
I would appreciate some help, thanks :)
Edit: I've just tested some more characters that are legal for pagetitles, seems like = isn't working either.
It's translated from = into %3D

How to use the PubMed API to search for an article with an exact title?

I'm trying to use the PubMed API to search for articles with an exact title. As an example, I want to search for the title: The cost-effectiveness of mirtazapine versus paroxetine in treating people with depression in primary care.
I want up to 1000 results in JSON format, so I know that the first part of my URL should look like this:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=
How do I add a title search as a GET parameter?
I've been using the Pubmed advanced search constructor, and that suggests that the query should look like The cost-effectiveness of mirtazapine versus paroxetine in treating people with depression in primary care[Title].
But if I try just adding that to the URL term=, PubMed tries to break down the title into all kinds of peculiar queries:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=The%20cost-effectiveness%20of%20mirtazapine%20versus%20paroxetine%20in%20treating%20people%20with%20depression%20in%20primary%20care[Title]
How can I specify an exact title as a GET param?
Use field=title
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=The%20cost-effectiveness%20of%20mirtazapine%20versus%20paroxetine%20in%20treating%20people%20with%20depression%20in%20primary%20care&field=title
Check out ESearch API for more information:
http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ESearch_
Use + instead of %20 (space).
For example:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=cost+effectiveness+of+mirtazapine[title]

How to use wild cards in FT search

I have the following:
tmpArray[cTerms++] = "[sclenka] CONTAINS \"*" + sessionScope.sclenka +"*\"";
(With the help of Per Henrik Lausten)
Which should result in: "*term*"
But it doesn't, I get this instead: "term"
So, my question is how do I use wildcard full text search?
Thank you!
If you want to use a wildcard search, then generate the following query string:
tmpArray[cTerms++] = "[sclenka] = \"*" + sessionScope.sclenka +"*\"";
This should generate a search on "*search query*".
In general, this is a good way of performing a search since the user probably expect your search to work like that.
Source: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Searching_for_Documents#Full-text+Search
If your string is correct and you are getting no results, then test the same string in the Notes client FTI search.
You can also use the following debug on the server.
DEBUG_FTV_SEARCH=1
Then check the output on the domino console when you do a search.
So if I understand you, the result is an escaped form of the search term in which the asterisks have been removed?
Could you use the construct:
tmpArray[cTerms++] = "[sclenka] CONTAINS \"" + String.fromCharCode(42) + sessionScope.sclenka + String.fromCharCode(42) + "\"";
At least that should avoid escaping?
I think you have missed a bit of escaping characters in the String you are generating.
tmpArray[cTerms++] = "[sclenka] CONTAINS \"" + sessionScope.sclenka +"\"";
leyrer, is it possible -- just possible -- that you're doing this in a browser and your session is not authenticated? If so, you may be searching the database as "anonymous" where when you test from the browser you're searching as "leyrer".
It's just a thought - but I used to see that all the time when people would start using my NCT Search tools. They'd swear they were getting no results, and when I'd dig I'd always find that they were using the browser as anonymous rather than as a logged in session.
#GKIDD
I just tested this on my own site. I have NCTSearch setup. I accepts the search term from the the web and runs database.ftsearch() as part of its job from within lotuscript.
I searched on "data*" and got at least as many results as when I searched on "database".
Based on that, I think something else is going on.
From my earlier comment on other answer, try this: Create another agent that does JUST the search. Have it grab the search term from agent context as if it were a docid. Call the agent from the first agent using "agent.runonserver(searchterm)" see if you can fool it
Andrew, I'm getting the results with Anonymous user, but not with the wildcard. Here goo.gl/YVtXm on the first line, it says that CONTAINS or contains or = does not work when searching from the web.

ComplexPhraseQueryParser

I would like to implement for my website a fuzzy phrase search using Hibernate Search. I've read from some people that ComplexPhraseQueryParser is ok for this.
But the thing is that I have some missunderstandings or issues related to it.
So for instance let's consider a test title like this (I have a lot of this and I need to let users search whatever they like):
"Do you know how to be in shape?"
If someone will type
"do you cnow how to be in shape?" my ComplexPhraseQueryParser will not find anyting. But if I put a "~" character after the misspeled word like "cnow~" it will work and return a result.
What is the reason of this? Doesn't ComplexPhraseQueryParser support such situations?
I would like to make my search deal with few misspelled words and return results (similar to google search).
ComplexPhraseQueryParser quizTitlePhraseQuery = new ComplexPhraseQueryParser(Version.LUCENE_30, "title", new StandardAnalyzer(
Version.LUCENE_30)) ;
quizTitlePhraseQuery.setPhraseSlop(100);
quizTitlePhraseQuery.setDefaultOperator(Operator.AND);
quizTitlePhraseQuery.setFuzzyMinSim(0.1f);
Thank you in advance!

Resources