I have a requirement to makes an SPFX search webpart that can be searched by content type and also partial item url but it has to only return a specific content type from all sites accept root.
The content type is a list item and I'm using urldepth>1 to exclude root. However it returns no results when I try to search for site name or other parts of the url
I cant share all the code unfortunately due to the nature of the project.
Here it the basic query that the search object uses to generate the initial result set...
testQuery = "contentTypeId:0x0100BB00A852FB374E4FA11A71309A944B75* urldepth>1";
let _search: Search = new Search(this.props.wpContext.pageContext.web.absoluteUrl);
let _results = await _search.execute({
Querytext: testQuery,
EnablePhonetic: true,
TrimDuplicates: false,
RowsPerPage: itemLimit,
RowLimit: itemLimit,
EnableSorting: true,
StartRow: currentStartRow,
SelectProperties: [ Constants.fieldName_Title, Constants.fieldName_SiteUrl, Constants.fieldName_ProjectStatus, Constants.fieldName_ProjectProposer, Constants.fieldName_Created, Constants.fieldName_SiteRelativeUrl ],
SortList: [
{
'Property': Constants.fieldName_Created,
'Direction': 1
}
]
});
And in addition they can type into a text box to append keywords to the query. However it didnt work in the webpart so I took it to the modern search page to figure out if I'd made an error in my webpart somewhere
https://tenent.sharepoint.com/sites/testsite/_layouts/15/search.aspx?q="contentTypeId:0x0100BB00A852FB374E4FA11A71309A944B75* urldepth>1 project1"
This returns no results but when searched for separately it seems to work. I just cant seem to get them working togeather in a single query.
Appreciate any help you can give on this one.
Cheers!