KQL AND

In the following code, KQL AND syntax is not working.

using(SPSite site = new SPSite("http://shpdev"))
using (KeywordQuery query = new KeywordQuery(site))
{

 query.SelectProperties.Add("ContentType");
 query.SelectProperties.Add("EntityComments");

 query.QueryText = "ContentType:Performance"; // Gets the result if i use only this statement
 query.QueryText = "EntityComments:excellent"; // Gets the result if i use only this statement

 query.QueryText = "ContentType:Performance AND EntityComments:excellent"; // No result if i use this statement
 
  SearchExecutor  executor = new SearchExecutor();
 var result = executor.ExecuteQuery(query);

 foreach(DataRow row in result.First().Table.Rows)
 {
  Response.write(row["Title"]); 
 }

}

How can I use AND operator in KQL When user select different content type properties for filtering the search result

January 23rd, 2015 10:18am

what if you just remove the word 'AND'?

when you search Bing/Google for SharePoint KQL, do you search for "SharePoint AND KQL", or just "SharePoint KQL" and assume that the search engine knows that when you include multiple terms/conditions, that they all need to be considered?

Free Windows Admin Tool Kit Click here and download it now
January 23rd, 2015 4:58pm

Please ignore the above code and it is not correct. There  was crawling issue.  I have new issues now

1) I have added the Query Culture.

query.Culture = System.Globilization.CultureInfo.CurrentCulture  // The result is ar-SA

2) AND & OR operators - Same result

I get the correct result if I use the following

contentype:performance AND EntityCommentsOWSMTXT:excellent (where EntityCommentsOWSMTXT is Managed Properties of EntityComments (Site Column - Multiline)

but if I use OR operator, I get the same result of AND which is not correct.

contentype:performance OR EntityCommentsOWSMTXT:excellent

please advise

3) Search result is not coming for Site Columns (Single Line of Text and Number)

Site Column Year (Number) result is not coming

contentype:performance AND YearOWSNMBR:2012 -  No result, where YearOWSNMBR is managed property

contentype:performance AND YearOWSNMBR=2012 - No result

Site Column Report (Single Line of Text) result is not coming

contentype:performance AND ReportOWSTEXT:Annual Report - No result, where ReportOWSTEXT is managed property.

I made Queryable and Searchable. Type of information stored in this property by default selected as Type = Text.

It is not changeable to Integer or Date and Time etc

4) Search Result

I am planning to show the search result in a grid. It is one option. Another option is redirecting to default search result page which is osssearchresult.aspx. This is possible right ?

January 24th, 2015 2:12am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics