There are two ways to restrict the search to a certain area of your site
With Site Areas settings you can define which sections of your website are indexed. For example, if you want to leave the News section (domain.com/news/) out from the search, create a Site area setting /news/ EXCLUDE. If you want to index only News section, create two Site area rules:
/news/ 100%
/ EXCLUDE
This would leave URLs with “/news/” in the index. For the full documentation of Site area settings, see Site Areas instructions. For other ways to exclude content from AddSearch, see Including and Excluding content.
If you want to restrict the search only on certain pages, you can do it by using category filters. The category is a property of an indexed page determined by its domain and each path segment. For example, a page with URL www.example.org/some/path would have a category property “0=www.example.org, 1=some, 2=path”. You can configure the search script to limit its results to pages that for example have a certain domain or first path segment.
Maybe you have a forum section, and would like it to have its own search that would only return forum posts, and have those results excluded from the main site’s search. Here are some examples of how this could be accomplished:
Search script snippet on the main site:
<script src="https://addsearch.com/v5/addsearch-ui.min.js?key=####&categories=0xwww.example.com"></script>
Search script snippet on forum:
<script src="https://addsearch.com/v5/addsearch-ui.min.js?key=####&categories=0xforum.example.com"></script>
Search script snippet on the main site, excluding forums:
<script src="https://addsearch.com/v5/addsearch-ui.min.js?key=####&categories=!1xforum,!1xanother-forum"></script>
Search script snippet on forum:
<script src="https://addsearch.com/v5/addsearch-ui.min.js?key=####&categories=1xforum,1xanother-forum"></script>
To limit search results to a subpath, use slash instead of a comma to define the nested category. For example “categories=1xpublic/2xforum” would limit the search path “/public/forum”.
If you have multiple widgets on a single page use data-addsearch-categories attributes to define field-specific filters:
<input class="addsearch" data-addsearch-categories="1xsupport" ... >
You can filter search to a certain type of documents. Here is an example of the category filter to show PDFs only: categories=doctype_pdf. The whole list of options:
We’re always happy to help with code or other questions you might have. Search our documentation, contact support, or connect with our sales team.