Interacting with Search Service

advertisement
Microsoft
Course
MicrosoftOfficial
SharePoint
2013
®
Interacting with the Search Service
SharePoint Practice
Module Overview
• Understanding the SharePoint 2013 Search Service
• Building Search Queries with KQL and FQL
• Executing Search Queries from Code
Lesson 1: Understanding the SharePoint 2013
Search Service
• Search Architecture
• Demonstration: Exploring the Search Architecture
• The Search Index
• Crawled Properties
• Managed Properties
• Demonstration: Exploring Crawl and Managed
Properties
• Search Schema
• Demonstration: Exploring the Search Schema
Search Architecture
• SharePoint Architecture has six roles
• Administration
• Crawling
• Content Processing
• Analytics Processing
• Query Processing
• Index
• Core services are run in following processes
• NodeRunner.exe
• HostControllerService.exe
• Mssmdm.exe
Demonstration: Exploring the Search
Architecture
• In this demonstration your instructor will
demonstrate the Search Architecture and the
search index
The Search Index
• Search index resides on the file system
• Broken into partitions for improved performance
• Default
• Security
• Link
• Usage
• People
• Redundancy provided by creating index
partitions and replicas
•
Similar to columns and rows in FAST Search
Crawled Properties
• Crawl property is data about an item from its
content source or within the item
• Example:
A metadata column in a list (source)
• The createdate from the filesystem (source)
• The title from a word document (item)
•
• Crawl properties are retrieved from the crawler
and the content processing components
• Crawl properties are grouped into categories
Managed Properties
• Managed properties are single or aggregated
crawl properties that are configured for specific
search purposes
•
Mapped order matters for single value properties
• Only managed properties are included in search
index
• Example:
Crawl property name is not user friendly
• Multiple crawl properties from different sources need
to be mapped to same managed property
• Can be used as a refiner
• Can be searchable
•
Demonstration: Exploring Crawl and Managed
Properties
• In this demonstration your instructor will explore
crawled and managed properties
Search Schema
• SharePoint Search Schema defines several search
configuration specific details
Result Sources
• Result Types
• Managed Properties
•
• 2013 Search Schema is multi-leveled
• Service Application
• Site Collection
• Site
• Allows customizations that are appropriate for
each level’s use cases
Demonstration: Exploring the Search Schema
Lesson 2: Building Search Queries with KQL and
FQL
• SharePoint Query Languages
• Keyword Query Language (KQL) Queries
• KQL Operators
• Advanced KQL
• FAST Query Language (FQL) Queries
SharePoint Query Languages
• SharePoint supports two types of query
languages
Keyword Query Language (KQL)
• FAST Query Language (FQL)
•
• KQL is the default query language
• FQL must be enabled manually
• SQL Syntax (FullTextSqlQuery) queries no longer
supported
•
Any older applications will break when moving to
SharePoint 2013
Keyword Query Language (KQL) Queries
• KQL queries can be up to 2048 characters
• Programmatically you can increase this limit
• Simple keyword queries are run against the full
text index
They are not case sensitive
• Includes any crawled property with the Include in fulltext index checked
•
• Phrases are designated with double quotes
(“SharePoint”)
KQL Operators
• KQL allows the use of various operators to allow
advanced query capabilities
• Queries with no operator specified are implicitly AND
operators
• Available operators include
• Wildcard
• Comparison (<,>,<=,>=,<>)
• Contains (:)
• Proximity (NEAR, ONEAR)
• Ranking (XRANK)
• Synonym (WORDS)
• All operators are case sensitive and must be in uppercase
Advanced KQL
• Simple keyword searches tend to present two
common issues
Never any results
• Too many results
•
• Advanced queries resolve this
FAST Query Language (FQL) Queries
• FAST Query Language (FQL) is a developer’s
search query language
Originally part of FAST Search engine
• Syntax has changed slightly from 2010
•
• Disabled by default, must be enabled in code
and on a result source
•
Use KeywordQuery.EnableFQL property
• Three main elements
• Token expressions
• Property specification
• Operators
Lesson 3: Executing Search Queries from Code
• Search APIs
• Executing Web Service Queries
• Executing Server-Side Queries
• Demonstration: Server Side Object Model
• Executing Client Side Queries
• Demonstration: Client Side Object Model
• Executing Representational state transfer (REST)
Queries
• Demonstration: Executing FQL Queries
Search APIs
• There are several ways to submit a query to
SharePoint Search
User Interface (UI)
• Web Services
• Server Object Model
• Client Side Object Model
• REST
•
• Based on industry standards
• Web services, HTTP, REST, .NET
• Easily integrate search into legacy applications
Executing Web Service Queries
• Web Services are deprecated in 2013
• Still work, but you should migrate to different API
• Uses the /_vti_bin/spsearch.asmx end point
• Query and QueryEx methods require a specially
xml formatted query parameter
Executing Server-Side Queries
• Server side object model must be run on a
SharePoint server
•
Must be run in x64 application
• Use KeywordQuery class to build queries
• Execute method is deprecated
• Use new SearchExecutor class to execute single and
multiple queries
Demonstration: Server Side Object Model
• In this demonstration your instructor will
demonstrate how to make search server side
object model calls
Executing Client Side Queries
• Client side object model is a .NET API that can
run from any .NET client
•
App does not have to run on SharePoint server
• Calls are proxied to the server side object model
• Similar to Server Side, use the KeywordQuery
class to construct queries
SearchExecutor class is also used to send multiple
queries at once
• Results are returned in a ResultTableCollection
• Iterate through all ResultTable objects to get the full
result set (Promoted Results, Main Results)
•
• QueryAsUserIgnoreAppPrincipal permission
scope
Demonstration: Client Side Object Model
• In this demonstration your instructor will show
you how to make client-side service object model
Executing Representational state transfer (REST)
Queries
• Representation state transfer (REST) is a simple
HTTP based protocol
•
GET, POST, MERGE
• REST Search requests utilizes the
http://server/_api/search/query end point
Result format can be in XML or JSON
• Based on Accept header
•
•
•
Application/atom+xml
Application/json
• REST Query Suggestions requests utilize the
http://server/_api/search/suggest end point
•
Helpful for autocomplete controls
Demonstration: Executing FQL Queries
• In this demonstration your instructor will
demonstrate how to execute FAST Query
Language (FQL) queries
Lab: Executing Search Queries from SharePoint
Apps
• Exercise 1: Submitting Search Queries from Client-
Side Code
• Exercise 2: Using a Custom Action to Launch A
Search App
Lab Scenario
The management team at Contoso is concerned
about the proliferation of duplicate content across
the new intranet portal. The team wants to
provide a way for users to check, given a particular
document, whether similar content exists
elsewhere on the portal. To implement this
functionality, you will create an app that uses
client-side search APIs to query the search index
for similar content. In addition to using the client
applications, they would also like to be able to
find items based on metadata but without having
to type the queries. They would like you to add a
custom action to the menu items to redirect to the
Lab Scenario
• client app.
Module Review and Takeaways
Download