0

After the defult search web part with refiners is loaded, i need to execute the same query in a second moment.

I have a complex url to interpret (decoded yet), like this:

...#/Default={"k":"b*","r":[{"n":"owsStar0Country","t":["\"ǂǂ4672616e636961\""],"o":"and","k":false,"m":null}]}#Default={"k":"b*","r":[{"n":"owsStar0ReferenceMarket","t":["\"ǂǂ726566206d61726b657433\""],"o":"and","k":false,"m":null},{"n":"owsStar0Sectors","t":["\"ǂǂ736563746f7231\""],"o":"and","k":false,"m":null}]}

How to extract properties and properties value to execute query in the same way the original web part do?

In other words... how to populate keywordQuery.Refiners and/or keywordQuery.RefinementFilters ?

Thanks !

2

First of all, I'm not sure why you have multiple hash # groups in your URL, you have both #/Default and #Default= parts. This might be because there were multiple steps (actions) when you performed the query, I'm not sure to be honest.

But in general, here's how you can extract the needed information from the query string: the r parameter in the json-formatted URL represents the refinement filters that have been applied. All the values in the r array are the refinement filters you need to apply. The n parameter is the refiner name, while the t parameter is the refinement token. You need to add the refinement filter in the format n:"t". So, for example, with the following URL:

...##Default={"k":"b*","r":[{"n":"owsStar0ReferenceMarket","t":["\"ǂǂ726566206d61726b657433\""],"o":"and","k":false,"m":null},{"n":"owsStar0Sectors","t":["\"ǂǂ736563746f7231\""],"o":"and","k":false,"m":null}]}

you would apply refinement filters like this:

keywordQuery.RefinementFilters.Add("owsStar0ReferenceMarket:\"ǂǂ726566206d61726b657433\"");
keywordQuery.RefinementFilters.Add("owsStar0Sectors:\"ǂǂ736563746f7231\"");

More information: https://msdn.microsoft.com/en-us/library/office/ff394639.aspx?f=255&MSPPError=-2147217396

  • i just checked for multiple hash groups in the URL... it's only a BUG! :-l – nlllrt9 Sep 6 '16 at 12:07
  • what if i have selected multiple values for the same property ? for example: {"n":"owsReferenceMarket","t":["\"ǂǂ726566206d61726b657431\"","\"ǂǂ726566206d61726b657433\""],"o":"and","k":false,"m":null} ... would be like this: keywordQuery.RefinementFilters.Add("owsReferenceMarket:\"ǂǂ726566206d61726b657431\", "\"ǂǂ726566206d61726b657433\""); – nlllrt9 Sep 6 '16 at 12:22
  • @nlllrt9 I believe you just make multiple calls with the same refinement name: keywordQuery.RefinementFilters.Add("owsReferenceMarket:\"ǂǂ7‌​26566206d61726b65743‌​1\"); keywordQuery.RefinementFilters.Add("\"ǂǂ726566206d61726b657433\"");, but I haven't tested that – Justas Černiauskas Sep 7 '16 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.