Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Lamphere 6 posts 75 karma points
    Feb 22, 2017 @ 16:46
    Tom Lamphere
    0

    Site search on subdomain?

    I recently created a subdomain for my site. Is there a way to have that subdomain use the full text search, and only that subdomain. I don't want the pages to show up on the main domain.

    Thanks.

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Feb 23, 2017 @ 12:15
    Marc Goodson
    0

    Hi Tom

    Depending a little bit on the way your subdomain is structured in your Umbraco Tree (is it within the main site, or at the same level ?). You could create a separate index for the subdomain, and on this specific index use the option to set the IndexParentId which causes only content beneath the page with this id to be indexed, eg

    <IndexSet  SetName="mySubdomainIndex"  IndexPath="~/App_Data/TEMP/ExamineIndexes/mysubdomainindex/"  IndexParentId="1234">
    

    or alternatively

    Every document in Umbraco has a Path property, which is a comma delimited string of the ids of the documents above the document in the tree eg

    -1, 1234, 2533, 56333

    would be the path to the document with Id 56333, it's parent id is 2533 etc etc up to -1 (the root of the site)

    This path is available in examine, so you could still have one index for your sites, but when querying the index filter on the path of your subdomain.

    It follows that if your subdomain has an id of 1234 then all pages within the subdomain would have a path beginning -1, 1234 ...

    The only slight problem with this is the comma delimited messes up the lucene syntax to do the query, but there is a workaround with adding a custom 'SearchPath' entry to the index with the commas removed.

    There is quite an old blog post by AttackMonkey here, which explains the concept well:

    http://www.attackmonkey.co.uk/blog/2011/12/limiting-an-examine-search-to-the-current-site

    the indexing part of this article is still relevant but the way events are wired up has changed in the latest version of Umbraco:

    https://our.umbraco.org/Documentation/Reference/Events/Application-Startup

    Hope that makes sense!

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft