There is a frequent requirement for business users to search for the documents/contents based on the custom metadata information being managed for their business documents.  To facilitate the user for selecting the values for the search properties, the OOTB advanced search web part provides only a plain text box, for the selected property.  Hence, the user needs to know or remember the value of the property they are looking for, which is a kind of usability issue for the business users.  Hence, to provide a effective UI for the users to search based on the custom metadata values, the OOTB advanced search web part can be customized to an extent thro’ which this can be achieved.

Limitations in the OOTB advanced search web part:

  • Only, the plain text box inputs available to specify the values for the metadata property.
  • The property search doesn’t allow the users to specify more than 5 property filters.

Solution:

  • Custom Advanced Search Web Part with custom rendering of metadata field controls, based on the field type.
  • Reuse the OOTB Advanced Search UI’s hidden controls that determines the search attributes (ASB_PS_…)

Approach:

  • Develop custom web part with the custom tool part, for configuring the list of metadata fields need to be displayed in the custom advanced search web part
  • In the custom tool part, populate all the site columns available, with the selection slider controls.
  • The application admin/user can select the metadata columns to be available in the custom advanced search web part, based on which the metadata fields with their native field controls will be rendered.
  • The SPFieldLookup and SPFieldChoice field types are rendered with multi-select listbox, displaying all the reference values in the UI, enabling the user to submit the search query with the values selected for the metadata property.
  • The metadata field value controls are rendered with the IDs ending with ASB_PS_… search attribute names.  Please refer below the table, speficies the usage of these search query attributes.

Screenshots:
1.  Custom Advanced Search Web Part UI  customadvancedsearchwebpartui4

 2.  Tool Part for the above web part   customadvancedsearchtoolpart6
 Search Attribute Reference

Advanced Search UI constructs and the passes the keyword and property filters using the following attributes:

Attribute NameDescriptionExample
ASB_TextDT_Props Attribute used to specify the text based property names being used in the search. The value should be specified with #;# delimeters for multiple property names <input type=”hidden” name=”ASB_TextDT_Props” value=”Company#;#EntityType” />
ASB_DateTimeDT_Props Attribute used to specify the datetime based property names being used in the search. The value should be specified with #;# delimeters for multiple property names <input type=”hidden” name=”ASB_DateTimeDT_Props” value=”SubmissionDate” />
ASB_ResType_Query This attribute used to specify the query for the search. The query can be specified using the keyword property filter syntax or the fulltext query <input type=”hidden” name=”ASB_ResType_Query” value=”Company=’xxxx’” />
ASB_TQS_AndQ_tb The attribute used to specify the keyword, which will be used as “All of these words” search box <input type=”text” name=”ASB_TQS_AndQ_tb”/>
ASB_TQS_PhraseQ_tb The attribute used to specify the keyword, which will be used as “exact phrase” search box <input type=”text” name=”ASB_TQS_PhraseQ_tb”/>            

 

 

ASB_TQS_OrQ_tb The attribute used to specify the keyword, which will be used as “Any of these words” search box <input type=”text” name=”ASB_TQS_OrQ_tb“/>
ASB_TQS_NotQ_tb The attribute used to specify the keyword, which will be used as “Exclude words” search box.  It can only be used if another search term is also specified <input type=”text” name=”ASB_TQS_NotQ_tb“/>
ASB_SS_scb_0_<scope_Id> This attribute used to specify the scope of the search.  The scope_Id should be replaced with the corresponding Id of the search scope.  The scope Id can be obtained from the URL of the Edit Scope properties screen. <input type=”text” name=”ASB_SS_scb_0_1“/>
ASB_PS_plb_<index> This attribute used to specify the internal name of the property to be searched. <input type=”hidden” name=”ASB_PS_plb_0” value=”Company”/>
ASB_PS_olb_<index> This attribute used to specify the operator to be applied for the property values. <input type=”hidden” name=”ASB_PS_olb_0” value=”Contains”/>
ASB_PS_pvtb_<index> This attribute used to specify the value of the property name specified using ASB_PS_plb_<index> <input type=”hidden” name=”ASB_PS_pvtb_0″ value=”xxxx” />The above 2 attributes including this one, forms the definition of one property filter.  In this example, the search willl query for the contents with the metadat field Comapny with the value “xxxx”Note:  The index and the prefix of this attribute name should be the same for one set of property definition.  The index can go upto any numbers, as I’ve tested upto 10 property filters.
ASB_PS_lolb_<index> The logical operator between the property fields.  If more than one property filter is being specified, then the logical operator between the property filters should be specified using this attribute. The <n> should be substituted with the index thro’ 0 to x. <input type=”hidden” name=”ASB_PS_lolb_0″ value=”And” />
ASB_BS_SRCH_1 The name of the submit button in the search query page should be this attribute <input type=”submit” name=”ASB_BS_SRCH_1″/>

 

The property filters can be specified using the ASB_PS_… attributes and along with the ASB_ResType_Query attribute,  in which both conjuncts and forms the search query.  The limitation with using the ASB_PS_… attributes are, the multiple values for the same property is not supported by single occurrence of this property.  Hence, either it needs to be a different occurrence of the ASB_PS_… attribute with the same property filter name.  The alternate way of achieving the support for multiple values is using the ASB_ResType_Query to form the whole property query.  But, the datetime values being passed in the property query using ASB_ResType_Query, expects a special format, which I’m still struggling to find out.  Will update this post, once when I find the format.

Thanks to Tom Clarkson, from whose blog I got to know about the Search Query Attributes.

Tom Clarkson’s Blog on Custom Advanced Search

http://www.tqcblog.com/archive/2007/10/26/creating-a-custom-advanced-search-box-in-moss-2007.aspx?id=6