In a previous post of mine I explained how to create managed properties and modify the search results page for a custom Protocol application. In this post I am going to continue from my previous example by modifying the advanced search tab.

The idea is to modify the search page in order to include some of my managed properties in the search query logic, add the “contains” and “does not contain” equation in my search expressions and limit the language query options to English an Greek only.

  • I navigate to the advanced search page and I go into edit page mode
    image[15]
  • I select the edit menu of the Advanced Search Box webpart and the Modify Shared Web part option
    image[18]
  • In the Advanced Search Box –> Properties –> I pres the … icon in the Properties field
    image_13
  • A new window appears with the XML format of the advanced search properties
    <root xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance%22>
    <Option Name=”AllowOpContains” Value=”False”/>
    <LangDefs>
    < LangDef DisplayName=”Arabic” LangID=”1″/>
    <LangDef DisplayName=”Bengali” LangID=”69″/>
    <LangDef DisplayName=”Bulgarian” LangID=”2″/>
    <LangDef DisplayName=”Catalan” LangID=”3″/>
    <LangDef DisplayName=”Chinese” LangID=”4″/>
    <LangDef DisplayName=”Croatian/Serbian” LangID=”26″/>
    <LangDef DisplayName=”Czech” LangID=”5″/>
    <LangDef DisplayName=”Danish” LangID=”6″/>
    <LangDef DisplayName=”Dutch” LangID=”19″/>
    <LangDef DisplayName=”Finnish” LangID=”11″/>
    <LangDef DisplayName=”French” LangID=”12″/>
    <LangDef DisplayName=”German” LangID=”7″/>
    <LangDef DisplayName=”Greek” LangID=”8″/>
    <LangDef DisplayName=”Gujrati” LangID=”71″/>
    <LangDef DisplayName=”Hebrew” LangID=”13″/>
    <LangDef DisplayName=”Hindi” LangID=”57″/>
    <LangDef DisplayName=”Hungarian” LangID=”14″/>
    <LangDef DisplayName=”Icelandic” LangID=”15″/>
    <LangDef DisplayName=”Indonesian” LangID=”33″/>
    <LangDef DisplayName=”Italian” LangID=”16″/>
    <LangDef DisplayName=”Japanese” LangID=”17″/>
    <LangDef DisplayName=”Kannada” LangID=”75″/>
    <LangDef DisplayName=”Korean” LangID=”18″/>
    <LangDef DisplayName=”Latvian” LangID=”38″/>
    <LangDef DisplayName=”Lithuanian” LangID=”39″/>
    <LangDef DisplayName=”Malay” LangID=”62″/>
    <LangDef DisplayName=”Malayalam” LangID=”76″/>
    <LangDef DisplayName=”Marathi” LangID=”78″/>
    <LangDef DisplayName=”Norwegian” LangID=”20″/>
    <LangDef DisplayName=”Polish” LangID=”21″/>
    <LangDef DisplayName=”Portugese” LangID=”22″/>
    <LangDef DisplayName=”Punjabi” LangID=”70″/>
    <LangDef DisplayName=”Romanian” LangID=”24″/>
    <LangDef DisplayName=”Russian” LangID=”25″/>
    <LangDef DisplayName=”Slovak” LangID=”27″/>
    <LangDef DisplayName=”Slovenian” LangID=”36″/>
    <LangDef DisplayName=”Spanish” LangID=”10″/>
    <LangDef DisplayName=”Swedish” LangID=”29″/>
    <LangDef DisplayName=”Tamil” LangID=”73″/>
    <LangDef DisplayName=”Telugu” LangID=”74″/>
    <LangDef DisplayName=”Thai” LangID=”30″/>
    <LangDef DisplayName=”Turkish” LangID=”31″/>
    <LangDef DisplayName=”Ukrainian” LangID=”34″/>
    <LangDef DisplayName=”Urdu” LangID=”32″/>
    <LangDef DisplayName=”Vietnamese” LangID=”42″/>
    </LangDefs>
    <Languages>
    <Language LangRef=”12″/>
    <Language LangRef=”7″/>
    <Language LangRef=”17″/>
    <Language LangRef=”10″/>
    </Languages>
    <PropertyDefs>
    <PropertyDef Name=”Path” DataType=”text” DisplayName=”URL”/>
    <PropertyDef Name=”Size” DataType=”integer” DisplayName=”Size”/>
    <PropertyDef Name=”Write” DataType=”datetime” DisplayName=”Last Modified Date”/>
    <PropertyDef Name=”FileName” DataType=”text” DisplayName=”Name”/>
    <PropertyDef Name=”Description” DataType=”text” DisplayName=”Description”/>
    <PropertyDef Name=”Title” DataType=”text” DisplayName=”Title”/>
    <PropertyDef Name=”Author” DataType=”text” DisplayName=”Author”/>
    <PropertyDef Name=”DocSubject” DataType=”text” DisplayName=”Subject”/>
    <PropertyDef Name=”DocKeywords” DataType=”text” DisplayName=”Keywords”/>
    <PropertyDef Name=”DocComments” DataType=”text” DisplayName=”Comments”/>
    <PropertyDef Name=”Manager” DataType=”text” DisplayName=”Manager”/>
    <PropertyDef Name=”Company” DataType=”text” DisplayName=”Company”/>
    <PropertyDef Name=”Created” DataType=”datetime” DisplayName=”Created Date”/>
    <PropertyDef Name=”CreatedBy” DataType=”text” DisplayName=”Created By”/>
    <PropertyDef Name=”ModifiedBy” DataType=”text” DisplayName=”Last Modified By”/>
    </PropertyDefs>
    <ResultTypes>
    <ResultType DisplayName=”All Results” Name=”default”>
    <Query/>
    <PropertyRef Name=”Author”/>
    <PropertyRef Name=”Description”/>
    <PropertyRef Name=”FileName”/>
    <PropertyRef Name=”Size”/>
    <PropertyRef Name=”Path”/>
    <PropertyRef Name=”Created”/>
    <PropertyRef Name=”Write”/>
    <PropertyRef Name=”CreatedBy”/>
    <PropertyRef Name=”ModifiedBy”/>
    </ResultType>
    <ResultType DisplayName=”Documents” Name=”documents”>
    <Query>IsDocument=1</Query>
    <PropertyRef Name=”Author”/>
    <PropertyRef Name=”DocComments”/>
    <PropertyRef Name=”Description”/>
    <PropertyRef Name=”DocKeywords”/>
    <PropertyRef Name=”FileName”/>
    <PropertyRef Name=”Size”/>
    <PropertyRef Name=”DocSubject”/>
    <PropertyRef Name=”Path”/>
    <PropertyRef Name=”Created”/>
    <PropertyRef Name=”Write”/>
    <PropertyRef Name=”CreatedBy”/>
    <PropertyRef Name=”ModifiedBy”/>
    <PropertyRef Name=”Title”/>
    <PropertyRef Name=”Manager”/>
    <PropertyRef Name=”Company”/>
    </ResultType>
    <ResultType DisplayName=”Word Documents” Name=”worddocuments”>
    <Query>FileExtension=’doc’ Or FileExtension=’docx’ Or FileExtension=’dot'</Query>
    <PropertyRef Name=”Author”/>
    <PropertyRef Name=”DocComments”/>
    <PropertyRef Name=”Description”/>
    <PropertyRef Name=”DocKeywords”/>
    <PropertyRef Name=”FileName”/>
    <PropertyRef Name=”Size”/>
    <PropertyRef Name=”DocSubject”/>
    <PropertyRef Name=”Path”/>
    <PropertyRef Name=”Created”/>
    <PropertyRef Name=”Write”/>
    <PropertyRef Name=”CreatedBy”/>
    <PropertyRef Name=”ModifiedBy”/>
    <PropertyRef Name=”Title”/>
    <PropertyRef Name=”Manager”/>
    <PropertyRef Name=”Company”/>
    </ResultType>
    <ResultType DisplayName=”Excel Documents” Name=”exceldocuments”>
    <Query>FileExtension=’xls’ Or FileExtension=’xlsx’ Or FileExtension=’xlt'</Query>
    <PropertyRef Name=”Author”/>
    <PropertyRef Name=”DocComments”/>
    <PropertyRef Name=”Description”/>
    <PropertyRef Name=”DocKeywords”/>
    <PropertyRef Name=”FileName”/>
    <PropertyRef Name=”Size”/>
    <PropertyRef Name=”DocSubject”/>
    <PropertyRef Name=”Path”/>
    <PropertyRef Name=”Created”/>
    <PropertyRef Name=”Write”/>
    <PropertyRef Name=”CreatedBy”/>
    <PropertyRef Name=”ModifiedBy”/>
    <PropertyRef Name=”Title”/>
    <PropertyRef Name=”Manager”/>
    <PropertyRef Name=”Company”/>
    </ResultType>
    <ResultType DisplayName=”Presentations” Name=”presentations”>
    <Query>FileExtension=’ppt'</Query>
    <PropertyRef Name=”Author”/>
    <PropertyRef Name=”DocComments”/>
    <PropertyRef Name=”Description”/>
    <PropertyRef Name=”DocKeywords”/>
    <PropertyRef Name=”FileName”/>
    <PropertyRef Name=”Size”/>
    <PropertyRef Name=”DocSubject”/>
    <PropertyRef Name=”Path”/>
    <PropertyRef Name=”Created”/>
    <PropertyRef Name=”Write”/>
    <PropertyRef Name=”CreatedBy”/>
    <PropertyRef Name=”ModifiedBy”/>
    <PropertyRef Name=”Title”/>
    <PropertyRef Name=”Manager”/>
    <PropertyRef Name=”Company”/>
    </ResultType>
    </ResultTypes>
    </root>

Let’s explore the XML in order to see how we can manipulate the advanced search box query properties:

  • To include the “contains” and “does not contain” equation in my search expressions I just need to edit the Option AllowOpContains (Red Text) from False to True.
  • To leave only the Greek and English language option in my languages search query, I have to edit the <Language LangRef=”Number”> tag (Orange Text) with the appropriate language definition number (Grey Text) .
  • I check the language definitions list for the Greek language and I notice that the Greek definition is equal to “8” (Grey Text) . I Remove all <Language LangRef=”Number”> tags and I leave only one; the one with the Greek language Definition <Language LangRef=”8”> (Orange Text) .
  • To include my managed properties in search terms I have to add a property definition for my managed property (Blue Text) and a Property Reference (Green Text) for the appropriate definition to appear in the properties dropdown list.
  • To create a property definition for my ProtOurPID managed property, I have to include a <PropertyDef Name=”ProtOurPID” DataType=”Text” DisplayName=”Our PID”/> tag (Blue Text) where Name=”My managed property name”, DataType=”Data type (Text, DateTime, etc)”, DisplayName=”The appearance in the pick property drop down menu
    <PropertyDef Name=”ProtOurPID” DataType=”text” DisplayName=”Our PID”/>
    <PropertyDef Name=”ProtSubject” DataType=”text” DisplayName=”Subject”/>
    <PropertyDef Name=”ProtINOUT” DataType=”text” DisplayName=”IN/OUT”/>
    <PropertyDef Name=”ProtDocumentDate” DataType=”datetime” DisplayName=”Document Date”/>
    <PropertyDef Name=”ProtINTOriginDestination” DataType=”text” DisplayName=”Internal Origin/Destination”/>
    <PropertyDef Name=”ProtEXTOriginDestination” DataType=”text” DisplayName=”External Origin/Destination”/>
    <PropertyDef Name=”ProtCommentsDescriptions” DataType=”text” DisplayName=”Protocol Comments / Description”/>
    <PropertyDef Name=”ProtTheirPID” DataType=”text” DisplayName=”Their PID”/>
  • Finally, I need to be able to query my custom managed properties. In order to do so, I have to create a Property Reference for my Property Definitions I created earlier. I have the option to create groupings of Property References called Result Types. Result Types can have their own groupings of Property References and filtering queries. For example, to create a Result Type for my Protocol Lists I can add the following markup just before the </ResultTypes> closing tag:
    <ResultType DisplayName=”Protocols” Name=”Protocol”>
    <Query>IsDocument=0</Query>
    <PropertyRef Name=”ProtOurPID”/>
    <PropertyRef Name=”ProtSubject”/>
    <PropertyRef Name=”ProtINOUT”/>
    <PropertyRef Name=”ProtDocumentDate”/>
    <PropertyRef Name=”ProtINTOriginDestination”/>
    <PropertyRef Name=”ProtEXTOriginDestination”/>
    <PropertyRef Name=”ProtTheirPID”/>
    </ResultType>
  • This result type will query the results that are not documents “<Query>IsDocument=0</Query>” and will allow you to query only the grouping of the managed properties referenced in that particular result type.

You can always create more complex queries by adding OR and AND statements. Like:

<Query>FileExtension=’xls’ Or FileExtension=’xlsx’ Or FileExtension=’xlt'</Query>
[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]