This project has moved and is read-only. For the latest updates, please go here.

Changing the default Operator in property picker in Advanced Search SharePoint

Mar 17, 2010 at 8:56 PM

How do you change the default operator 'Equals' into 'Contains' in the section 'Add properties restriction' in a Moss 2007 advanced Search page?

To go to this situation, please follow the next steps:

If you go to a clean Moss environment, Go to the search center and click on the Advanced Search Link. For example: look at the http://<sitecollection>/SearchCenter/Pages/advanced.aspx

The last section is the 'add properties restriction' section. The default values are 'Equals' and 'Does not Equal'. If you go to the web part settings -> Properties -> and change the XSLT value on the top from <Option Name="AllowOpContains" Value="False"/> into <Option Name="AllowOpContains" Value="True"/> you get 2 more options available. These are the 'Contains' and 'Does not contain' option. The default value still is 'Equals'. I want the default value to be set to 'Contains'. How can you change this?

I think it can be done with Jquery through a content editor webpart, but how?


Mar 18, 2010 at 4:55 AM
Edited Mar 18, 2010 at 5:07 AM


Thanks for posting the details here. 140 chars wasn't getting it into my thick skull.

When I look at the markup for the control, it looks like this:

<TD class="ms-advsrchText">
  <SELECT id=ctl00_m_g_fcf16705_97ab_4f7b_8ca6_1daf5e2ef6dc_ASB_PS_olb_0-advsrchOperatorDDL title="Inclusion Operator" class="ms-advsrchOperatorDDL" name=ctl00$m$g_fcf16705_97ab_4f7b_8ca6_1daf5e2ef6dc$ASB_PS_olb_0>
    <OPTION selected value="Equals">Equals</OPTION>
    <OPTION value="Does not equal">Does not equal</OPTION>
    <OPTION value="Contains">Contains</OPTION>
    <OPTION value="Does not contain">Does not contain</OPTION>

So the jQuery to set the "Contains" option to be selected should be:

$("select[Title='Inclusion Operator'] option[Value='Contains']").attr("selected", "selected");

This works in my VM, so hopefully it'll work for you as well. Let me know how it goes.


Mar 18, 2010 at 8:11 PM

Hi Marc,

Thanx again for your help and your input. To complete the answer you gave, here's the complete code for fixing this issue. In my situation I have put the latest version of the jquery-1.4.2.min.js in the document library that also contains the advanced.aspx. But be welcome to put in in any library of your choice. In the code underneath I make a reference to this jquery-1.4.2.min.js. BTW, always use the minified version in a production environment.

On the advanced.aspx page I have put a hidden Content editor webpart. In the source editor I put the following code, which results in setting the 'contains' operator as the default value:

<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("select[Title='Inclusion Operator'] option[Value='Contains']").attr("selected", "selected");   
This does the trick!

Skudoes to Marc for you quick responses and help. I really like Jquery :-)


Mar 18, 2010 at 8:17 PM

Glad to help, Peter!


Mar 5, 2013 at 2:36 PM
This sounded like exactly what i needed to do also, but when I implement this script, the "Contains" operator displays when the page loads, but when i select a property, the operator changes back to Equals. Do either of you have any suggestions about how to change this so that the Operator value does not reset?

FYI, I'm using jQuery 1.8.3.