Skip to main content
Tweeted twitter.com/StackSharePoint/status/659195794176786432

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;

    }

i have been making a CAML query search webPart, which already provides the cascaded search on the documents through out the directory using CAML on Columns as metadata to search.

For now i have the dropdown to make cascading search work.

but

Now i want it to behave like GOOGLE Search no criteria defined just a text box to search --> 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. somewhere we call it "full text search", mind it i am not desiring Content Search for now and not using sharePoint 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 i go for it or not and how will i achieve it coz it might need permutation and combination of the concatenated metadata values?

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;

        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;

    }

I have been making a CAML query search webpart, which already provides the cascaded search on the documents through out the directory using CAML on Columns as metadata to search.

For now I have the dropdown to make cascading search work. But now I want it to behave like Google Search no criteria defined just a text box to search:

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. Somewhere we call it "full text search", mind it I am not desiring Content Search for now and not using SharePoint 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 I go for it or not and how will I achieve it because it might need permutation and combination of the concatenated metadata values?

Any solutions?

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;

    }
added the function through which cascading search is working
Source Link
ankit
  • 51
  • 8

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;

        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;

    }

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;

        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;

    }
Source Link
ankit
  • 51
  • 8

search on (google like) SharePoint document library

i have been making a CAML query search webPart, which already provides the cascaded search on the documents through out the directory using CAML on Columns as metadata to search.

scree for cascading search

For now i have the dropdown to make cascading search work.

but

Now i want it to behave like GOOGLE Search no criteria defined just a text box to search --> 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. somewhere we call it "full text search", mind it i am not desiring Content Search for now and not using sharePoint 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 i go for it or not and how will i achieve it coz it might need permutation and combination of the concatenated metadata values?

any Solutions??? Plz help