Showing posts with label Search. Show all posts
Showing posts with label Search. Show all posts

Friday, July 8, 2016

AngularJS Filter Exact match / Filter Strict search

I wanted to get results with exact match using filter property in AngularJS.

Let us assume I have JSON values;

$scope.languages = [
        {id:19, name:"German", available: false},    
        {id:119, name:"English", available: true},    
        {id:3, name:"French", available: false},  
        {id:4, name:"Italian", available: true},  
        {id:5, name:"Spanish", available: false}
    ];

I wanted to display only German using id. Then my AngularJS filter would be;

<li ng-repeat="language in languages | filter: {id: 19}">{{language.name}}</li>

Unfortunately, I got two results; German and English
I was confused and found the reason that it is searching the IDs with "contains" keyword.
German's ID is 19
English's ID is 119

Therefore the filter value 19 is present in both German and English.

How do I get results with exact match?
Answer: Mention :true in filter

<li ng-repeat="language in languages | filter: {id: 19}:true">{{language.name}}</li>


Here is the working example in jsfiddle;

Issue: http://jsfiddle.net/to7z06ma/65/

Fix: http://jsfiddle.net/to7z06ma/66/


Tuesday, February 23, 2016

SharePoint 2013 / SharePoint Online Search on custom columns

Requirement:
SharePoint Online search results should display results even if user typed keyword matches custom column value.

My Action:
I told business users, "Yes, we can do it". All were happy. Once I implemented the solution, I could not see the results. :( Very bad.

What I tried:
- I went to Site settings, under Site Collection Administration -> Search Schema
- I searched for managed properties which are created by SharePoint.
  ["SharePoint creates one when we create a column" - I believe so]
- In my case, I was looking for "Document Category" and it showed me  "DocumentCategoryOWSTXT"
- I edited that property and mapped my custom column
- Since it is SharePoint Online, I waited for one day to see the results.
- Next day i tried search items but no luck. Surprised !

I have went with so many alternate approaches but failed.

The Fix:
Suddenly I got an idea and i tried it. It Worked !!!!! :) Here's it;
1. Create new managed property and map the custom column
   - Go to Root level site settings
   - Look for "Search Schema" under Site Collection Administration and click it
   - Create a new managed property for the column you want to map it
      [In my case, I created "DocumentCategoryCustom" and selected the checkboxes of Searchable,     Queryable and Retrievable]
   - Map the custom column
     [In my case, I want to map the sub site's custom column "DocumentCategory". The column name was showing as "ows_DocumentCategory" in root level. I mapped it.]

2. Reindex Site
    - Go to Site settings
    - Look for "Search and Offline Availability" under Search
    - Click on Reindex Site

That's it !!!!!

[Later I came to know that this is a known issue and Microsoft's backend team is working on it. ]

Wednesday, November 11, 2015

SharePoint 2013 / SharePoint Online Display Templates missing

Microsoft has introduced Display Templates in SharePoint 2013 which is very powerful.
I ran into an issue with it.

User: I could not find my search results. It is showing error on all my search terms

I looked into it. The error message was;

Display Error: The display template had an error. You can correct it by fixing the template or by changing the display template used in either the Web Part properties or Result Types.

Template '~sitecollection/_catalogs/masterpage/Display Templates/Search/Control_SearchBox.js' not found or has syntax errors. (LoadTemplate: )

I got a point after seeing this error. I went to Site collection feature and checked whether the feature "Search Server Web Parts and Templates" is activated or not.

It is Activated !!!!!
Then I went to Site settings -> Web designer galleries -> Master pages. I am surprised to find the folder "Display Templates" is missing.

This issue will be resolved if you Deactivate and Activate the feature.

But I fixed it by other way. ;) I copied the folder "Display Templates" from other site collection and pasted it in reported site. Boom ! It worked !