3

I need search people profile by Birthday field using KeywordQuery. The field is indexed correctly, when I search for REST, /_api/search/query?querytext='*'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&rowlimit=6&selectproperties='PreferredName,Birthday'&refinementfilters='Birthday:range(datetime("2000-11-20"),%20datetime("2000-11-24"))', works fine. But when I try search using KeywordQuery, returns error: "The research found a problem that prevents the return of results. If the problem persists, contact your administrator."

My code:

KeywordQuery keywordQuery = new KeywordQuery(SPContext.Current.Site);
keywordQuery.SourceId = new Guid("B09A7990-05EA-4AF9-81EF-EDFAB16C4E31");
keywordQuery.HiddenConstraints = "scope:\"People\"";                                        
keywordQuery.TrimDuplicates = true;
keywordQuery.EnableStemming = true;
keywordQuery.SelectProperties.Add("Birthday");
keywordQuery.SelectProperties.Add("LastModifiedTime");
**keywordQuery.QueryText = "Birthday:November 21";**
keywordQuery.RowLimit = 200;
SearchExecutor searchExecutor = new SearchExecutor();
ResultTableCollection results = searchExecutor.ExecuteQuery(keywordQuery);

My filter tests:

Works:

keywordQuery.QueryText = "LastModifiedTime:2013-11-21";
keywordQuery.QueryText = "PreferredName:Someone*";

Don't work:

keywordQuery.QueryText = "Birthday:November 21";
keywordQuery.QueryText = "Birthday:datetime(\"11-21-2000T00:00:00Z\")";
keywordQuery.QueryText = "Birthday:range(datetime(\"11-01-2000T00:00:00Z\"), datetime(\"11-30-2000T00:00:00Z\"))";
keywordQuery.QueryText = "Birthday:2000-11-21";
keywordQuery.QueryText = "Birthday:2000-21-11";
keywordQuery.QueryText = "Birthday:11-21";
keywordQuery.QueryText = "Birthday:21-11";

Does anyone know how to filter the search for the birthday field?

2 Answers 2

2

In your example you search for * in the fulltextindex in the rest api, and apply refinement filter for a date range on birthday field. Did the rest api return any refinement results for birthday? I assume you have already verified that your search schema is correct, birthday is queriable and refineable. In your c# example you don't perform the same query as in the rest example. For trouble shooting I recommended the SharePoint 2013 Search Query Tool on codeplex.

Have you tried the fielded search in the rest api? Without refinement

2
  • My REST url returns OK. My problem is with the KeywordQuery.
    – Willian
    Nov 25, 2013 at 21:34
  • 1
    What I was trying to say is that none of your c# examples use the same query as your rest example. Try keywordQuery.QueryText = "*"; and add your birthday refiner using keywordQuery.RefinementFilters.Add(...) Nov 27, 2013 at 5:22
0

Sorry for my english. just now i see your post, after to you checked all details of Petter Skodvin-Hvammen and check if you are permission to the files that you search , and this propbleme persist , you can try to test it directly to searchbox webpart and not must to write code and check it face to debugger . you can try to write "Birthday:\"November 21\"" (for c#) or Birthday:"November 21" for searchbox webpart and not "Birthday:November 21" because space between two word in kql can problematicaly .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.