Need help on SPFX web part properties search issue

%3CLINGO-SUB%20id%3D%22lingo-sub-73027%22%20slang%3D%22en-US%22%3ENeed%20help%20on%20SPFX%20web%20part%20properties%20search%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-73027%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20need%20help%20on%20SharePoint%20SPFX%20implementation.%20We%20have%20created%20one%20sample%20web%20part%20and%20one%20description%20property%20in%20it.%3CBR%20%2F%3EWhen%20we%20are%20trying%20to%20search%20that%20property%20we%20are%20not%20able%20to%20search%20it.%3CBR%20%2F%3EWe%20have%20tried%20adding%20this%20web%20part%20to%20classic%20and%20modern%20pages.%3CBR%20%2F%3EIn%20Modern%20Page%20we%20found%20that%20it%20is%20crawling%20properties%20with%20webpart%20id%20%2B%20property%20content.%3CBR%20%2F%3EIn%20Classic%20Page%20it%20is%20not%20searching.%3C%2FP%3E%3CP%3EWe%20have%20added%20below%20code%20for%20making%20property%20searchable%20but%20it%20is%20not%20working.%3C%2FP%3E%3CP%3Eprotected%20get%20propertiesMetadata()%3A%20IWebPartPropertiesMetadata%20%7B%3CBR%20%2F%3Ereturn%20%7B%3CBR%20%2F%3E'spfxcrawl'%20%3A%20%7BisHtmlString%3A%20true%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-73027%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-107814%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20SPFX%20web%20part%20properties%20search%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-107814%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20Guys%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20another%20more%20recent%20source%20to%20take%20a%20look%20at%20as%20well.%20Please%20have%20a%20look%20at%20this%20video%20from%20Vesa%20and%20Waldek%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DiB8PBs8RH-E%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DiB8PBs8RH-E%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-107755%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20SPFX%20web%20part%20properties%20search%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-107755%22%20slang%3D%22en-US%22%3E%3CP%3EAs%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F44548%22%20target%3D%22_blank%22%3E%40Velin%20Georgiev%3C%2FA%3E%26nbsp%3Bsays%2C%20the%20official%20reference%20doc%20might%20help%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20does%20mention%20that%2C%20indeed%2C%20SPFx%20WebPart%20properties%20metadata%20are%20not%20handled%20in%20classic%20pages.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%3CSTRONG%3E%22Important%3A%3C%2FSTRONG%3E%26nbsp%3BThe%20following%20guide%20applies%20only%20to%20SharePoint%20Framework%20client-side%20web%20parts%20placed%20on%20modern%20SharePoint%20pages.%20Capabilities%20described%20in%20this%20article%20don't%20apply%20to%20classic%20web%20parts%20or%20SharePoint%20Framework%20client-side%20web%20parts%20placed%20on%20classic%20pages%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMoreover%2C%20the%20content%20has%20to%20be%20crawled%20before%20appearing%20in%20search%20results.%20It%20might%20take%20several%20minutes.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-107753%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20SPFX%20web%20part%20properties%20search%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-107753%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EisSearchablePlainText%3C%2FSTRONG%3E%20is%20not%20needed%20if%26nbsp%3B%3CSTRONG%3EisHtmlString%3C%2FSTRONG%3E%20is%20specified%2C%20both%20flag%20the%20property%20as%20searchable.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-104137%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20SPFX%20web%20part%20properties%20search%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-104137%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F222%22%20target%3D%22_blank%22%3E%40Wictor%20Wilen%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EWe%20did%20this%20code%20changes%20also%20but%20then%20we%20found%20another%20issue%20guid%20of%20webpart%20always%20get%20padded%20with%20text%20which%20causes%20search.%3C%2FP%3E%3CP%3EAlso%20we%20have%20seen%20search%20will%20not%20work%20with%20classic%20pages.%20We%20got%20confirmation%20from%20MS%20team%20this%20SPFx%20web%20part%20content%20will%20not%20be%20searchable%20in%20classic%20pages%20due%20to%20existing%20search%20architecture%20for%20Classic%20Pages.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20reply.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103133%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20SPFX%20web%20part%20properties%20search%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103133%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20need%20to%20add%20%3CSTRONG%3EisSearchablePlainText%3C%2FSTRONG%3E%26nbsp%3Bthe%20parameter%20to%20your%20return%20value%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Eprotected%20get%20propertiesMetadata()%3A%20IWebPartPropertiesMetadata%20%7B%0A%20%20%20%20return%20%7B%0A%20%20%20%20%20%20'spfxcrawl'%3A%20%7B%20isSearchablePlainText%3A%20true%20%7D%0A%20%20%20%20%7D%3B%0A%20%20%7D%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103031%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20SPFX%20web%20part%20properties%20search%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103031%22%20slang%3D%22en-US%22%3EMaybe%20this%20article%20can%20help%3A%20%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fsharepoint%2Fdocs%2Fspfx%2Fweb-parts%2Fguidance%2Fintegrate-web-part-properties-with-sharepoint%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.office.com%2Fsharepoint%2Fdocs%2Fspfx%2Fweb-parts%2Fguidance%2Fintegrate-web-part-properties-with-sharepoint%3C%2FA%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

We need help on SharePoint SPFX implementation. We have created one sample web part and one description property in it.
When we are trying to search that property we are not able to search it.
We have tried adding this web part to classic and modern pages.
In Modern Page we found that it is crawling properties with webpart id + property content.
In Classic Page it is not searching.

We have added below code for making property searchable but it is not working.

protected get propertiesMetadata(): IWebPartPropertiesMetadata {
return {
'spfxcrawl' : {isHtmlString: true}
}
}

 

Thanks in advance.

6 Replies

You need to add isSearchablePlainText the parameter to your return value:

 

protected get propertiesMetadata(): IWebPartPropertiesMetadata {
    return {
      'spfxcrawl': { isSearchablePlainText: true }
    };
  }

Thanks @Wictor Wilen,

We did this code changes also but then we found another issue guid of webpart always get padded with text which causes search.

Also we have seen search will not work with classic pages. We got confirmation from MS team this SPFx web part content will not be searchable in classic pages due to existing search architecture for Classic Pages.

 

Thanks for your reply.

Hi

 

isSearchablePlainText is not needed if isHtmlString is specified, both flag the property as searchable.

As @Velin Georgiev says, the official reference doc might help you.

 

It does mention that, indeed, SPFx WebPart properties metadata are not handled in classic pages.

 

"Important: The following guide applies only to SharePoint Framework client-side web parts placed on modern SharePoint pages. Capabilities described in this article don't apply to classic web parts or SharePoint Framework client-side web parts placed on classic pages"

 

Moreover, the content has to be crawled before appearing in search results. It might take several minutes.

Hey Guys, 

 

There is another more recent source to take a look at as well. Please have a look at this video from Vesa and Waldek: https://www.youtube.com/watch?v=iB8PBs8RH-E

 

PnP Webcast around how to integrate client-side web part properties with SharePoint - Description on the covered topics and additional resources from https:/...