Daniel Little
Daniel Little

Reputation: 17273

Sitecore search with custom index

I'm attempting to use Sitecore Search with a custom index to filter and search items.

The items are product reviews and are all stored in a single folder with a ProductReview template.

+ Reviews
    - Sample Review 1
    - Sample Review 2
    - Sample Review 3

The users will be able to filter items by category, subcategory and search by product name. So the form will look similar to this:

Category:     [ Drop Down ]
Sub Category: [ Drop Down ]
Product name: [ Single line of Text ]

[ Search Button ]

I'm finding the documentation for defining indexes very thin. I'm trying to setup the index with the following properties.

I'm not sure if I need a custom Analyzer or DatabaseCrawler and I haven't looked into making one at all.

This is what I have so far, however I haven't produced a working index yet:

<index id="reviews" type="Sitecore.Search.Index, Sitecore.Kernel">

    <param desc="name">$(id)</param>
    <param desc="folder">reviews</param>
    <Analyzer ref="search/analyzer" />

    <include hint="list:IncludeField">
        <!-- Category -->
        <fieldId>Category</fieldId>

        <!-- Sub Category -->
        <fieldId>Sub Category</fieldId>

        <!-- Product Name -->
        <fieldId>Product Name</fieldId>

    </include>

    <locations hint="list:AddCrawler">
        <web type="Sitecore.Search.Crawlers.DatabaseCrawler, Sitecore.Kernel">
            <Database>web</Database>

            <!-- {GUID} -->
            <Root>{GUID}</Root>

            <Tags>web reviews</Tags>
            <IndexAllFields>false</IndexAllFields>

            <templates hint="list:AddTemplate">

                < !-- Product Review -- >
                <reviews>Product Review</reviews>

            </templates>
        </web>
    </locations>

</index>    

Any pointers would be greatly appreciated.

Edit

The two main things I'm looking for is:

Upvotes: 1

Views: 1662

Answers (1)

nickwesselman
nickwesselman

Reputation: 6890

Using the SitecoreSearchContrib (aka Advanced Database Crawler) library will make this much easier for you, both in indexing and searching. The library includes example configs that will make it more obvious to you how you should set things up.

Some initial pointers, even if you don't use SitecoreSearchContrib:

  • You'll want to index master as well, so that this functionality works in Preview mode. The above library will automatically search the correct database, based on the context the code is running in.
  • Your template inclusion in the index should be a template GUID.
  • Your field inclusions should be GUIDs as well.

Upvotes: 4

Related Questions