Simple Bing News Search Api - Search for Phrase - bing

I want to search for a phrase and not the collection of words How can I do this?
For instance
"&Query= Widget Foo"
I only want to return results with the phrase 'Widget Foo' and not widget separate from foo.

Wrap your search term in quotes. Here is an example that is already url encoded:
http://www.bing.com/search?q=%22widget+foo%22

Same principle applies to phrases searched for with the Bing API's subscription model at:
https://datamarket.azure.com/dataset/bing/search
So if you're looking for the news phrase:
"Palin mocks Obama and Rove in CPAC speech"
..wrap your query in quotes and URL encode the quotes as well:
https://api.datamarket.azure.com/Bing/Search/v1/News?Query=%27%22Palin%20mocks%20Obama%20and%20Rove%20in%20CPAC%20speech%22%27

Related

Mongo conditional find

So I have this article page and I need to place related articles below the current article body.
There are certain attributes that I use to find similar articles but in case there isn't any, or if there is less than 2 found, I need to add just some other articles to the result.
So if a given article has a tag "Development", I need to search for 2 other articles with that tag, and if there is less than 2 that have this tag, I need to pull just some other articles.
Right now the flow is:
I make a request to get an article using query
I make request for related articles using the result of the first request.
But now I have difficulty understand how to make another request or put a condition into the second request to optimally get another article(s).
I appreciate any help
const article =await "your collection". find({tag:"Development"}).limit(2);
const x=2 - article.length
while(x>0){
var y=await "your collection". findOne();
article.push(y);
x--;
}

Facebook Graph API - Searching in public posts

Is there a way to search for 2 keywords in a public post? I want to do a full text search in all public posts.
Right now I am doing it as "https://graph.facebook.com/search?q=A+B&type=post&fields=link,message&access_token=<>.
Current Behavior: fetching posts having A or B.
Required Behavior: Fetch post have both A & B.
I have also tried POST method in Graph API Explorer. Please suggest what should I do to get results.
Other things I tried :
facebook graph api search rules. But it also seems not working, even when I tried with q=A&q=B. Only second query word is getting searched.
Use the '|' operator. In your note, 'q=A&q=B' you are reassigning the value of 'q'. The API parses the string set as the value for 'q' and uses the '|' operator to parse between. Either way you will have a tough time finding a lot of results because the 'search/post' API is now deprecated.

Cannot use REST comments in Swagger

I have downloaded swagger ui and experimenting it locally. It works fine in scenarios like "path", "body" , and "query" . But most of my use cases use rest comments.
i.e /resourcePath/;tags
URI to retrieve the tags of a specific resource.
When I try this the the UI gets jumbled when adding the semi colon and malformed the sorted UI and cannot go beyond this.
So is this a known limitation ? Is there a workaround to accomplish this target ?
Appreciate any input to this..
Swagger is expecting you to specify path params in curly-brackets like {tags} and query params as comma-delimited, such as id=1,2,3,4. Some frameworks use semi-colons as delimiters but swagger likes commas.
Can you describe more what you're looking to do, with a more concrete example? Per design, comments on the api belong in the description and notes fields for operations, please see swagger-core wiki for details.
The Swagger codegen project has a validator which can be used to verify that your spec is properly formatted.

Play Framework: How to bind a complex REST request to a Controller method

Working on a REST API with Play Framework.
I have a requirement to support a RESTful request containing the "order" with multiple "line items".
In terms of the "POST data", I see it like: (split into multi-lines for clarity)
OrderId=123&OrderType=regular&
ItemNum=1&ItemID=78&quantity=2&discount=20&
ItemNum=2&ItemID=70&quantity=1&
ItemNum=3&ItemID=75&quantity=1&discount=10
Note that I have an issue to require all the "line items" to come with a full set of data. In the example above, the 2nd item has no discount. Since I cannot "force" developers using the API to work with my own "wrapper", I want to leave some flexibility.
I would like to map it to something like:
method(int orderID, string orderType, Item[] items)
However, I failed to find something appropriate in the docs.
What's the right way?
Should I build my own parser of the HTTP request data?
Any alternative way to format the POST data - as long as it is ok with REST guidelines - is also acceptable.
Thanks
Max
To map an array of Pojo objects, then you need to put item. in front of the item object. Just like you map an object in a form. Then, you should specify that it is an array using the standard array syntax.
I would do something like the following
orderId=123&orderType=regular&
item[0].ItemNum=1&item[0].ItemID=78&item[0].quantity=2&item[0].discount=20&
item[1].ItemNum=2&item[1].ItemID=70&item[1].quantity=1&
item[2].ItemNum=3&item[2].ItemID=75&item[2].quantity=1&item[2].discount=10

How to get exact phrase match out of Graph API search

Looking for a way to get an exact phrase match out of the Graph API's search endpoint. For example, all activities with "dogs and cats" in them. Putting the phrase in quotes doesn't seem to work, the API will return activities containing those words, but in any order.
curl -v "https://graph.facebook.com/search?q=%22dogs%20and%20cats%22&type=post&limit=75&access_token=&since=Wed+Jan+25+20%3A59%3A30&until=Wed+Jan+25+20%3A59%3A40"
returns and activity whose text is:
"Ohhh man it's raining dogs cats lobsters crab birds and horses up here. I'm scared!"
"dogs" "cats" and "and" are all in that post, but not in order.
Yeah I faced the same problem. There's a similar question that might help Using the Facebook Graph API to search for an exact string
Facebook doesnt allow exact phrasal matching drectly, atleast not at the API level, You would have to fetch the entire data and programmically check for exact matches (too slow though).