问题
With google custom search, one can refine results to a label by using the more: operator like so:
searchterm more:blog
But how can one restrict results to more than one label? It seems like this should work:
searchterm more:blog,articles
.. but it does not appear to - instead it is ignored as if I had specified an invalid label.
回答1:
Based on my research, you cannot use the more:
operator in a Google query string for the following reasons:
First, Google Custom search documentation on search refinement never provides a query string example. Also, custom search is performed via APIs and XML requests not via a straight query.
Secondly, sites that detail (examples below) how to customize a Google query string don't contain examples with the more:
tag. So, I don't think it's possible to create labels using the more:
operator.
- http://jwebnet.net/advancedgooglesearch.html
- http://www.blueglass.com/blog/google-search-url-parameters-query-string-anatomy/
- http://en.wikipedia.org/wiki/Google_Search#Search_options
- http://support.google.com/websearch/bin/answer.py?hl=en&p=adv_operators&answer=136861
Another find from Automatic refinements.
Your second option is to append the
more:
operator (followed by the label name) automatically to your users' queries in order to trigger one of your labels. You can do this by altering the search form from which users submit their queries.
So, the use of the more:
operator is possible but only referencing labels you have already created.
UPDATE
Also, I recommend using Google's site to Test and troubleshoot your Linked CSE. You can define your own context for a search engine and accomplish your requirements.
<Facet>
<FacetItem title="Blogs">
<Label name="more:blog" mode="FILTER" weight="0.8">
</Label>
</FacetItem>
</Facet>
<Facet>
<FacetItem title="Articles">
<Label name="more:articles" mode="FILTER" weight="0.8">
</Label>
</FacetItem>
</Facet>
Here are some more resources:
- http://www.google.com/cse/ - Google has a wizard to help create and customize the search
- Google Help articles › Learn more › Search results > Refinements
From the Developer's Guide: Getting Started page:
Refinements
Refinements are a way for you to categorize sites by topics. For example, if you have a bicycling search engine, you can have categories of, say, bike maintenance, bike reviews, bike stores, biking skills, and so on and so forth. You can create refinement labels that you associate with the sites you listed in the Sites tab. The refinement links appear at the top of your search results page, and users can click them to narrow down their searches. A search page can have as many as 16 refinement links.
To create a refinement label, click Add Refinement, and define the settings. To tag websites with labels, go to the Sites tab, select check boxes next to the sites, and select the label from the Label actions drop-down list. You can tag sites with more than one label.
Before you create your labels, you might want to check out existing labels and pool your resources with Google and other users.
- If you want to filter the results via the API, the Programmer's Guide: Filtering and sorting search results has everything you need.
回答2:
I found a way to search in many refinements label. While it's not possible to add several "more" parameters, we can add several "less" parameters in the query.
Let's say we have these refinements labels defined: blogs, articles, news, documents
doing +more:blogs +more:articles will fail.
BUT +less:news +less:documents will do the work and find only results in blogs and articles!
So it's possible to play with the less parameter and get only the categories you want ;)
Only strange is that actually the less parameter seems not to be in the google API documentation... I would be glad to have your feedback when its working for you
来源:https://stackoverflow.com/questions/13690014/google-custom-search-using-multiple-search-labels-refinements