More in this section

Forums / Developing with Sitefinity / Define Search Criteria

Define Search Criteria

4 posts, 1 answered
  1. Roland
    Roland avatar
    12 posts
    Registered:
    07 Apr 2009
    29 Dec 2009
    Link to this post
    Hi,

    I have read through many posts and have not found a clear answer for defining search criteria, nor is it in the User manual.

    Here are the steps I have taken to set up my search...
    Step 1: Create a Search index, and define what will be indexed - i.e. All pages, News, etc.
    Step 2: Open App_Data -> Search -> IndexName -> fieldsInfoProvider.xml
    Step 3: Define your fields and save
    Step 4: Go back to Seach index in Admin and click on "Start Indexing" - this will update the index
    Step 5: Create a Search Results page and drop a "Search Results" control within the content placeholder
    Step 6: Add the Search box to the page (this can be added direclty to a user control that resides within the master page (Template) - I use this method)
    Step 7: Launch the site and test the Search

    Issue: Everything on the page is showing up - nav, header, footer

    Step 3 above is what I would like clarification on... perhaps some solid examples of how to define what will be indexed.

    My scenario:
    I have a main master page (with header, footer, and nav) and child master pages (with varying content placeholders).  

     

    How can I set the filters so that only specified tags are searched?

    Example:
    Within a user control there is a <div id="nav">
    To exclude this I can put the following in my fieldsinfoProvider.xml: 

     
    <field name="nav" weight="-1" filterTag="div" filterAttributes="id:nav" indexAttribute="" /> 
     
    Note the weight is -1 to omit.

    However, I want to be able to index only specific elements - like divs and contentplaceholders.
     
     
    <field name="mycontent" weight="1" filterTag="div" filterAttributes="id:mydiv" indexAttribute="content" /> 
     

    1. Can you tell it what tags to explicitly target for indexing? - is the example above incorrect?
    2. If you can, how would you identify a ContentPlaceholder? - using the runtime div id?

    In my scenario it would be easier to define a few content areas rather than omit a bunch of other elements.

    It looks like you can filter OUT elements using filters, but cannot define what parts to filter IN.

    Thanks,
    Roland
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Dec 2009
    Link to this post
    Hi Roland,

    The crawler looks for the html of your pages. When you have a fields weights set to -1 this element is not indexed. Below is a sample declaration that illustrates how to hide all controls located in a holder

    page HTML

    <div id="Main">
    <table id="ctl00_Content_ctl00_Search1" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;">

    fieldsInfoProvider.xml

    <field name="hide" weight="-1" indexAttribute="" filterTag="div" filterAttributes="id:Main" />

    name = some name
    weight = -1 will not be indexed
    weight = 1 will be indexed
    filterTag = we are getting the div
    filterAttributes - we are getting the ID ot the div

    To hide only our control ctl00_Content_ctl00_Search1 from the crawler we should have the following configuration.

    <field name="hide" weight="-1" indexAttribute="" filterTag="table" filterAttributes="ctl00_Content_ctl00_Search1" />


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  3. Roland
    Roland avatar
    12 posts
    Registered:
    07 Apr 2009
    30 Dec 2009
    Link to this post
    Thanks again Ivan for the excellent information.

    It makes sense.
    The index starts with everything, and you can then filter out what is not wanted.

    Cheers,
    Roland
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Dec 2009
    Link to this post
    Hello Roland,

    Always glad to help to the community.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 1 answered