Skip to main content

spo search

Executes a search query

Usage

m365 spo search [options]

Options

-q, --queryText <queryText>

Query to be executed in KQL format

-p, --selectProperties [selectProperties]

Comma-separated list of properties to retrieve. Will retrieve all properties if not specified and json output is requested.

-u, --webUrl [webUrl]

The web against which we want to execute the query. If the parameter is not defined, the query is executed against the web that's used when logging in to the SPO environment.

--allResults

Set, to get all results of the search query in batches of 500.

--rowLimit [rowLimit]

The number of rows to be returned. When the allResults option is used, the specified value will define the size of retrieved batches

--sourceId [sourceId]

The identifier (GUID) of the result source to be used to run the query.

--trimDuplicates

Set, to remove near duplicate items from the search results.

--enableStemming

Set, to enable stemming.

--culture [culture]

The locale for the query.

--refinementFilters [refinementFilters]

The set of refinement filters used when issuing a refinement query.

--queryTemplate [queryTemplate]

A string that contains the text that replaces the query text, as part of a query transformation.

--sortList [sortList]

The list of properties by which the search results are ordered.

--rankingModelId [rankingModelId]

The ID of the ranking model to use for the query.

--startRow [startRow]

The first row that is included in the search results that are returned. You use this parameter when you want to implement manual paging for search results.

--properties [properties]

Additional properties for the query.

--sourceName [sourceName]

Specified the name of the result source to be used to run the query.

--refiners [refiners]

The set of refiners to return in a search result.

--hiddenConstraints [hiddenConstraints]

The additional query terms to append to the query.

--clientType [clientType]

The type of the client that issued the query.

--enablePhonetic

Set, to use the phonetic forms of the query terms to find matches. (Default = false).

--processBestBets

Set, to return best bet results for the query.

--enableQueryRules

Set, to enable query rules for the query.

--processPersonalFavorites

Set, to return personal favorites with the search results.

--rawOutput

Set, to return the unparsed, raw results of the REST call to the search API.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

When using the --allResults option, you cannot use the --startRow option. Only use --startRow for manual paging purposes.

Examples

Execute search query to retrieve all Document Sets (ContentTypeId = 0x0120D520) for the English locale

m365 spo search --queryText "ContentTypeId:0x0120D520" --culture 1033

Retrieve all documents. For each document, retrieve the Path, Author and FileType.

m365 spo search --queryText "IsDocument:1" --selectProperties "Path,Author,FileType" --allResults

Return the top 50 items of which the title starts with Marketing while trimming duplicates.

m365 spo search --queryText "Title:Marketing*" --rowLimit=50 --trimDuplicates

Return only items from a specific result source (using the source id).

m365 spo search --queryText "*" --sourceId "6e71030e-5e16-4406-9bff-9c1829843083"

Response

[
{
"Title": "Document",
"OriginalPath": "https://contoso.sharepoint.com/Shared Documents/Document.docx"
}
]
CTRL + M