How do I delimit Property bag values so search treats them as individual searchable words?
-
10-12-2019 - |
Question
Currently I am using the property bag with values that are comma separated something like:
web.AllProperties["fruits"] = "bananas, apples, oranges, tomatoes";
Currently search is treating them as one search word and I am wondering which delimiter I am using for search to use them as individual searchable words when indexed or if it is even possible this way ?
Solution
If you have a complete list of the different types of fruit (or whatever object) you want to search then you could use managed metadata and set up a custom termset.
OTHER TIPS
The property bag is simply a hash table. You could start with an array and iterate it in order to add a property for each item. Then add a property for Fruit:
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
$fruitsArray = @("fruit","bannana","apple","orange");
foreach ($i in $fruitsArray)
{
web.AllProperties["MyFruitTerm" + [array]::IndexOf($fruitsArray,$i)] = $i;
web.IndexedPropertyKey.Add($i);
}
web.Update();
web.AllowUnsafeUpdates = false;
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange