Become a SharePoint Search Power User: Keyword Query Operators

Posted Thursday, September 15, 2011 11:29 PM by CoreyRoth

At this point, SharePoint 2010 has been out about a year and a half more or less and you might have forgotten some of those new features that came along with it.  Since I am often one to talk about SharePoint search solutions, one of my favorite new features we got with SharePoint 2010 was Keyword Query operators.  They are all kinds of awesome.  Someone coming from a T-SQL background may be far from impressed, but in the search engine world, this is a BIG deal.  I’ve written about Search keywords in the past, but I thought this was worth some additional coverage, especially since I am speaking on the topic at SPC11 and it applies to both SharePoint 2010 and SharePoint Online (Office 365).

Since I am talking about getting more out of search with SharePoint Online, I’ll use my Office 365 account for today’s examples. The Keyword Query language for Search was expanded to include operators such as >,>=, <, <=, and <>.  These operators are great for comparison against built-in managed properties such as Size and Write (Modified Date).

For example, to see all documents modified since the beginning of this month (September), issue a query like this:

Write>=”9/1/2011”

image

Note, that the spacing (or lack there of) is important.  If you put spaces between the operator, property, and value, it won’t work.    Remember you can always put the value of the query inside quotes like you see above. This is especially important for values that have spaces in them.  Size can be used in the same way to ensure that files are of a certain size.  For example, to ensure files are greater than 100,000 bytes, use the following:

Size>100000

image

This returns files greater than 100,000 bytes (not to be confused by 100k like hard drive manufacturers would like Smile ).  Notice, that we are getting an image preview in the search results with SharePoint Online.  That’s interesting.  We’ll explore it later.

It also supports the “NOT” operator using “<>”.  For example, to see everything that is NOT written by me, you could issue the following query.

image

After all, if I didn’t write it, the content must be good. :)  As a reminder, you can combine any of the terms together to get more restrictive results.  A space in between terms is the equivalent of the word “AND”.  You can also use the keyword OR if desired.

image

For more information on operators, see this MSDN post.  Interested in seeing more that you can do with Keyword queries?  Come to my talk (#SPC364) at SharePoint Conference 2011 this October in Anaheim.  We’ll cover many way that you can use Keyword queries to get more out of Search.

Comments

# Fresh From SharePoint &#8211; Google Blog Search=facebook - Women Meet Solutions

Pingback from  Fresh From SharePoint &#8211; Google Blog Search=facebook - Women Meet Solutions

# re: Become a SharePoint Search Power User: Keyword Query Operators

Monday, November 28, 2011 4:34 AM by maf

Hi corey,

i am using SP 2010 enterprise edition with Enterprise Search center.

But as you shown, i am not getting author<>"corey roth"   reasults.

It is simply showing nothing.

Whay this all?

Do i need to install FAST search also.

necessarily.

Any help appriciated :-)

Thanks

# re: Become a SharePoint Search Power User: Keyword Query Operators

Wednesday, December 7, 2011 8:47 PM by CoreyRoth

@maf That should work.  You don't need FAST Search to issue that query.

# re: Become a SharePoint Search Power User: Keyword Query Operators

Thursday, January 19, 2012 10:36 AM by Jens

Hi Corey,

In our Search Centre (Sharepoit Enterprise) we get different results (amount and rank), when using the NOT or the "-" Operator. It is the same problem with the AND and "+" search.

sun NOT rain  !=    sun -rain

Do you have an explanation for that behavior?

Thanks

# re: Become a SharePoint Search Power User: Keyword Query Operators

Tuesday, February 7, 2012 12:07 AM by CoreyRoth

@Jens Interesting.  I have never noticed that before.  I'll have to run some tests.

# re: Become a SharePoint Search Power User: Keyword Query Operators

Monday, March 25, 2013 5:23 AM by Satya

Hi Corey,

I want to use time in my query for ex. datecolumn<="2013-03-14 03:45:00PM", when i am using this query the time part is ignored (I guess) and i am getting all the results for that including the results of 14-03-2013 5.00PM date. please help me how can i do the same?

# re: Become a SharePoint Search Power User: Keyword Query Operators

Thursday, April 11, 2013 10:15 PM by CoreyRoth

@Satya Sorry, Search does not recognize times in queries.  Nothing you can do about this.

Leave a Comment

(required)
(required)
(optional)
(required)