SOLVED

SharePoint provisioning with script; crawled property question (only available after item in list?)

Highlighted
Regular Contributor

I want to do a scripted site-collection provisioning. So I create everything by script, like:

- Managed metadata

- Crawled properties

- Managed properties

- Content types

- Lists

- Etc

 

It looks like I am facing a challenge creating  managed properties. This is what I do:

 

- I create custom content types

- add the to a list

 

I assume the crawled properties are generated by SharePoint but they are not.

It looks like they are only generated when I add an item to the list.

Only then they appear in the crawled properties. After that I can create Managed properties.

 

Am I right? Or do I miss something here? 

If so, is there some kind of workaround?

 

Thanks, Mike

10 Replies
Highlighted
Solution

HI @Mike Jansen,

 

Yes that is right. As a workaround I quite often provisioned a test list with al of my columns included and then create one list item through my provisioning scripts. 

Highlighted

Hi @Pieter Veenstra,

That's a quick answer ;) Thanks.

In case of SharePoint online, you wait for 24 hours so the crawl ran?

Highlighted

Hi @Mike Jansen,

Continuous crawl seems to do the job, sometimes it would fail though. Then forcing the updated crawls by going to the list's advanced settings and force the re-index works.

Highlighted

@Pieter Veenstra

I try to script the whole provisioning so want to avoid any manual actions. Maybe I can script the re-index. I'll do some testing.

Highlighted

@Pieter Veenstra

I'm working with the PnP powershell. Looks like this does the same: 

https://msdn.microsoft.com/en-us/pnp_powershell/requestpnpreindexweb

 

Highlighted
Highlighted

One additional question though.

 

I try to put everything into one script. So after the "Request-PnPReindexWeb" or "Request-PnPReindexList" I need to pause the script to wait for the incremental crawl to finish.

 

What would be a safe margin? 5 minutes?

Highlighted

The straight answer is that here isn't a safe margin. By default continuous crawls run every 15 minutes so it is theoretically possible for the update to take 29 minutes, if you were just too late.

Highlighted

As I would do a provisioning of an initial site collection it will not be a problem to wait for half an hour. I just take the safe margin.