Dev Indexing

There are two ways to restrict the search to a certain area of your site

  1. Control what is indexed by our crawler
  2. Index everything, but control what is returned by the search

1. Site areas – Control what is indexed

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.

2. Category filters – Control what is shown

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.

restricting search to a certain area of your website

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:

Main site at www.example.com, forum at forum.example.com

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>

Main site at www.example.com, forums with combined search at www.example.com/forum and www.example.com/another-forum

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”.

Multiple search fields

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" ... >

Filter by file type

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:

  • doctype_html
  • doctype_pdf
  • doctype_doc
  • doctype_docx
  • doctype_ppt
  • doctype_pptx

 

Was this helpful?

Need more help?

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.