Google custom search using multiple search labels - refinements?

懵懂的女人 提交于 2019-12-05 18:51:52

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.

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!