Showing posts with label Content Query. Show all posts
Showing posts with label Content Query. Show all posts

Sunday 6 August 2017

Common KQL Search Helper


Overview: I am forever forgetting the intricacies of using search and this post is a short note for common searches I use.  Ensure the search is working against "Everything":

Find items under a specific url (Path)
path:https://www.radimaging.com/sites/*

To only see team site (webtemplate)
webtemplate:STS

To see Content Types e.g. task list items
spcontenttype:Task

Example used in a search box for using a wildcard on the title
ClientSector:Finance AND Title:*Paul*

You can use the query approach for any Managed property to refine your search.  Example:
http://radimaging.net/sites/healthcare/_api/search/query?querytext='ClientSector:Finance*'&startrow=2&rowlimit=500

ClientSector is a Managed Property (property bag) at the root site collection level of each site collection.
startrow is telling my query to skip the first 2 results
rowlimit is telling the search to return up to 500 results (max is 500, default is 50 if not specified).

Similar querying can be done using the search results page in the browser:
https://radimaging.net/Pages/results.aspx#k=ClientSector%3AFinance*#s=105
Client Sector MP search equivalant in the browser
s = startrow

It is a good idea to have a query tool (SharePoint Search Query Tool V2.7) to help build up queries and validate query logic.  I have built consoles to do this in CSOM in the past or used PowerShell with CSOM which is pretty good.
https://github.com/SharePoint/PnP-Tools/tree/master/Solutions/SharePoint.Search.QueryTool (PNP Tools GitHub)  as of 10 Dec 2018 version 2.8.2 is the latest version.

Examples:
querytext='SharePoi*'
querytext='ManagedPropertyCreated:Test*'&startrow=10&rowlimit=500&sortlist='created:descending'&clienttype='ContentSearchRegular'


Read More:
https://gallery.technet.microsoft.com/office/Query-SharePoint-2013-373ff97a
http://nikcharlebois.com/get-search-results-in-sharepoint-2013-using-powershell/


Wednesday 14 July 2010

SP2010 CQWP customisation

Overview: Content Query Web Part (CQWP) in SP2010 is similar to in MOSS. This post walks thru using the CQWP to display a custom list and custom columns while outputting custom html via a custom xslt.
CQWP (need the publishing feature enabled, this creates the styles library and add the CQWP) by default uses the xslt /Style Library/XSL Style Sheets/ItemStyle.xsl.

Steps:
  1. Don't write over ItemStyle.xsl as this si supplied by SP2010 OOTB. Rather create a new xslt and put it into the styles library. Build up the xslt, I based my file on the itemstyle.xsl file, see rules for getting the output you are looking for using How to: Customize XSL for the Content By Query Web Part
  2. Custom xslt formatting, I always add the following code in case I want to see what the available fields are:
  3. Deploy the custom style sheet via a feature.
  4. Create a new Custom list called "Pets" and add columns for Title, Age & Status (choice):
  5. Edit your custom xslt to display for "Pets" as shown below:
  6. Add a new CQWP to your page. Configure it to display items from your new list (Pets).
  7. Change the "Presentation" section, "Item Style" to Show "Pets". Apply the Changes:
  8. CQWP displays as:
  9. Edit the CQWP "Age" property to "Age"
  10. Edit the CQWP "Age" property to "Status"