Hi there.
I am building a Sharepoint custom search webpart using C# and ASP.net with .Net 3.5.
I am using the KeywordQuery search types so that the user can use the wildcard (*) function and we display the results using a custom results screen.
After sharepoint has returned it's results, we do some additional filtering based on some other criterias that arent accessible/usable through sharepoint.
All of this works great
My problem comes in when the user searches for a blank string. I get the error:
"Your query is malformed. Please rephrase your query.", which makes complete sense as Sharepoint doesn't understand what to search for.
But unfortunately, because of the other filtering that we are doing, we sometimes need the users to be able to search on a blank/empty string.
If anyone has any idea on how to do this, it would be much Appreciated.
Regards
Francois
UPDATE on behalf of OP (moved from answer):
This was my code:
SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.GetContext(SPContext.Current.Site));
KeywordQuery query = new KeywordQuery(proxy);
query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
query.QueryText = TextBox1.Text;
query.ResultTypes = ResultType.RelevantResults;
query.EnablePhonetic = true;
query.TrimDuplicates = false;
query.RowLimit = 1000;
query.KeywordInclusion = KeywordInclusion.AllKeywords;
query.SelectProperties.Add("Field1");
query.SelectProperties.Add("Field2");
query.SelectProperties.Add("Field3");
ResultTableCollection searchResults = query.Execute();
But all I did was when the user enters an epty string i forced the query string to the following:
"Isdocument:1"
Which then returns all my documents.