If you are a second type person this Article for you ..................
Why ....... ???
There was a requirement, to filter documents based on their meta data (Columns) by using the default SharePoint search. Eg. if a document library has a column Called Customer or Bar-code ,.. etc, then User should be able to search as Customer:<Search text>, Search results appear ,only contain the <Search Text> words in the Customer Column not others. That's the basic Idea.
Before How ...... ??
In this Article I'm not going to cover the theories behind the SP search specially the new Search introduce from 2013 version, Including Content Sources, Crawl schedules Services and Typologies.
Will write an another Article to explain the mechanism behind the SP search where I'll cover above mentioned topics.
How........ ???
The most important factor to achieve the above requirement is the way you play with Term called "crawl properties"
Note: Crawled properties are generated automatically by SharePoint while crawling published content that has the corresponding fields populated. For example, in order to get a CrawledProperty for "MyColumn", you need to have at least one item that has a value in that column. After the next "Full Crawl", a Crawled Property for "MyColumn" will be created with a kind of Hungarian notation naming convention, typically something like "ows_MyColumn" or "ows_TEXT_MyColumn", etc. depending on the data type.
~ (https://sharepoint.stackexchange.com/questions/130712/crawled-properties-vs-managed-properties)
in Simple words, When indexer passes and crawls your content and its metadata it adds the columns as crawled properties only. This means it has passed over your columns and the metadata assigned to each element. You do not have any control over the creation of “Crawled Properties”.
Enough theories, Let's get into the business.
Step 1 - Plan your Data layer ( library or list )
there are two main ways of creating a list of library, Either by creating it from the scratch using list columns or Create a list of library based on a Content type which consist or Site columns.
We are going with second option since, List columns cannot be bind with content type and cannot be used as a Crawl properties.
Create site columns. go to the Site settings and Chose "Site Column" option under, Web Designer Galleries.
Create a Column Called "DemoCustomer", "DemoSerialNo", "DemoStatus" Make sure you Create them under a separate group where it's easy to filter
Create a Content type, called "DemoDocument", since we are going to use it for Document library, make sure the type of the content type is Document.
Then add site Columns to the Content type.
Now Create a document library, and bind the created content type to that. Once you create the Document library go to the library setting , chose advance settings and allow content type to be bind.
Then Bind the newly created Content type and remove the General Document content type.
Then Add sample Documents for demo purpose and Set relevant meta data as follows.
Let's do some search . If we search "DM-980" you'll see that results will appear as follows.
SP will give you results which match DM-980 in any field , in this case either "DemoSerialNo" or "DemoCustomer" matches the search term, will appear in results.
As I mentioned as a 'Note', Crawl properties are automatically created by SP so as a theory we should be able to find a crawl property for a DemoCustomer or DemoSerialNo as both are treat as Site columns. To find that Let's go the site Settings, click Search schema , under the Site Collection Administration.
There you can search as Demo where you will get all the Managed properties contain "Demo"
Note: Managed Properties are sometimes automatically created by SharePoint based on the Crawl properties, mapping a specific crawled property to the Managed Property. For example: In the above scenario a Managed Property may be created with a name like "OWSMyColumn" and have a mapping to the "ows_MyColumn" Crawled Property.
~ (https://sharepoint.stackexchange.com/questions/130712/crawled-properties-vs-managed-properties)
In simple words, For us Manage property is the one which can be controlled =. Crawl properties we do not have any control over it .
Go to the Crawl properties and search "Demo"
You see those are automatically mapped. now If you search something by Crawl Property such as ows_q_TEXT_DemoCustomer then, you need to use the mapped Manage property name (DemoCustomerOWSTEXT).
Then you get only the Results which matches only Customer column. But here you see the issue we cannot as users to remember these odd words such as DemoCustomerOWSTEXT rather We can as them to use DemoCustomer which is more user friendly . so how we can do that.
The way of doing it, is create a Manage property with a friendly name and mappe it with related Crawl property .
there are two way of doing it
1) Through Site collection level (Recommended).
2) Farm Level
Here will show how it done in both level.
Site collection Level.
go to Site settings click Search Schema under Site collection Administration and click New Managed Property.
Add a friendly name, then select Searchable, Queryable, Retrievable and Safe .
Then click Add mapping to make a mapping with Crawl property.
Search as Demo to find the required crawl property and make the mapping.
Save it .
Farm Level.
Go to Admin Center then select SharePoint. Under that Go to the Search section.
Then go to the "Manage Search Schema" where You can do the same as Site collection level as follows.
When you search the Newly added Manage property in Farm level you don't see the Site collection level Properties. However when you search it in Site Collection level. you will see the property created in Farm level.
Farm Level
Site Collection Level
Now it's all done. All you need either wait for few hours by hoping things will index again or you can go to the library setting and chose advance settings then do Re-index
Show time ...................
Now search as DemoCustomer:DM-980 ... Boom you will get Data which based on customer field.
Same as for DemoSerialNo
with KQL you can get data which contain DM-980 as a Custome and as a Serial Number
ok That's It ...
HAPPY CODING