iI have been making a CAML query search webPartwebpart, which already provides the cascaded searchsearch on the documents through out the directory using CAML on Columns as metadata to search.
For now iI have the dropdown to make cascading search work.
but
Now i But now I want it to behave like GOOGLEGoogle Search no criteria defined just a text box to search --> type:
Type anything relevant and the CAML should be so that it searches all the columns against the documents in the library and return those which matches anywhere. somewhereSomewhere we call it "full"full text search", mind it iI am not desiring Content Search for now and not using sharePointSharePoint Search Services.
Solution Approach 1: Just a thought I concatenate all the metadata values against each document and apply pattern matching logic (somewhat like KMP algorithm) on this concatenated set with the search statement entered in the search text box. I dont know should iI go for it or not and how will iI achieve it cozbecause it might need permutation and combination of the concatenated metadata values?
any Solutions??Any solutions? Plz help
CURRENT CODE FOR CASCADING
private string GetCamlQuery() { string queryString = string.Empty; string searchQueryString = string.Empty; string sortQueryString = string.Empty; StringBuilder querySB = new StringBuilder(); List searchCriteriaList = null;Current code for cascading:
private string GetCamlQuery()
{
string queryString = string.Empty;
string searchQueryString = string.Empty;
string sortQueryString = string.Empty;
StringBuilder querySB = new StringBuilder();
List<SearchCriteria> searchCriteriaList = null;
if (ViewState["SearchCriteriaList"] != null)
{
searchCriteriaList = ViewState["SearchCriteriaList"] as List<SearchCriteria>;
}
else
{
searchCriteriaList = new List<SearchCriteria>();
searchCriteriaList.Add(new SearchCriteria("ContentType", "Document"));
}
if (ddlDocument.SelectedIndex > 0 && txtSearchTag.Text.Trim() != string.Empty)
{
if (ddlDocument.SelectedItem.Text == "Area" || ddlDocument.SelectedItem.Text == "Document Type" || ddlDocument.SelectedItem.Text == "Tags" || ddlDocument.SelectedItem.Text == "Document Category" || ddlDocument.SelectedItem.Text == "Customer")
searchCriteriaList.Add(new SearchCriteria(ddlDocument.SelectedItem.Text, txtSearchTag.Text.Trim()));
}
List<string> conditions = new List<string>();
foreach (SearchCriteria item in searchCriteriaList)
{
if (item.Key == "ContentType")
conditions.Add("<Eq><FieldRef Name='ContentType'/><Value Type='Text'>" + item.Values + "</Value></Eq>");
else if (item.Key == "Area")
conditions.Add("<Contains><FieldRef Name='Area'/><Value Type='Text'>" + item.Values + "</Value></Contains>");
else if (item.Key == "Document Type")
conditions.Add("<Contains><FieldRef Name='TypeOfDoc' /><Value Type='Text'>" + item.Values + "</Value></Contains>");
else if (item.Key == "Tags")
{
conditions.Add("<Contains><FieldRef Name='Tags' /><Value Type='Text'>" + item.Values + "</Value></Contains>");
}
else if (item.Key == "Document Category")
{
conditions.Add("<Contains><FieldRef Name='Category' /><Value Type='Text'>" + item.Values + "</Value></Contains>");
}
else if (item.Key == "Customer")
{
conditions.Add("<Contains><FieldRef Name='CustomerName' /><Value Type='Text'>" + item.Values + "</Value></Contains>");
}
}
querySB.Append("<Where>");
string merged = MergeCAMLConditions(conditions, MergeType.And);
querySB.Append(merged);
querySB.Append("</Where>");
searchQueryString = querySB.ToString();
ViewState["SearchCriteriaList"] = searchCriteriaList;
ViewState["SearchQueryString"] = searchQueryString;
queryString = searchQueryString;
ViewState["queryString"] = queryString;
return queryString;
}