Pnp-modern-search: react-search-refiners: issue with multi-value managed metadata token replacement

Created on 19 Dec 2019  路  3Comments  路  Source: microsoft-search/pnp-modern-search

Forgive me - I originally posted this in the old github repo.

Expected or Desired Behavior

The token replacement should act like the SharePoint search token replacement by OR-ing the query such as translating this:

ContentTypeId:0x0101009D1CB255DA76424F860D91F20E6C411800E6AC0A08EAEEBF4FB7A1CD01XXXXXXXX* AND {|owstaxidmetadataalltagsinfo:{User.SubscriptionsMMDUserProfileField}}

into what OOB SharePoint search turns into this:

ContentTypeId:0x0101009D1CB255DA76424F860D91F20E6C411800E6AC0A08EAEEBF4FB7A1CD01XXXXXXXX* AND ((owstaxidmetadataalltagsinfo:#008466174-8d23-47de-af95-71f99bd88396) OR (owstaxidmetadataalltagsinfo:#0ec0eccb9-dcf1-45e2-9f75-1cd70494401c) OR (owstaxidmetadataalltagsinfo:#05f287ce5-796c-408c-afd1-a569cd19ba42))

Observed Behavior

Token replacement adds commas in between the separate terms so the resulting query does not return the expected results (and is possibly an incorrect query)

Source query:
{searchTerms} ContentTypeId:0x0101009D1CB255DA76424F860D91F20E6C411800E6AC0A08EAEEBF4FB7A1CD01XXXXXXXX* AND owstaxIdTopic:{Page.Topic.TermID}

Translates to:
{searchTerms} ContentTypeId:0x0101009D1CB255DA76424F860D91F20E6C411800E6AC0A08EAEEBF4FB7A1CD01XXXXXXXX* AND owstaxIdTopic:c52662de-76a9-4b63-af33-5c96801a6bf7--->,<---e5937827-fbf1-4a71-b41a-310195f46314--->,<---55f30609-524e-4934-bf77-d0d57cb1c98b

Please note: --->,<--- was just added for visibility of the comma

Steps to Reproduce

Add a field called Topic (or anything) that is a multi-value managed metadata field
Create 3 pages
2a) Page A has Topic value of: Topic 1, Topic 2, Topic 3
2b) Page B has Topic value of: Topic 1, Topic 2
2c) Page C has topic value of: Topic 1
Add a search results component with the following query in the Query Template:
{searchTerms} AND owstaxIdTopic:{Page.Topic.TermID}
the query could also use label, it still results in unintended results (or no results):

{searchTerms} AND RefinableString00:{Page.Topic.Label}

If you look at the response of the /postquery in QueryModification field, the result is a comma separated list of the terms rather than a grouped list of OR statements for the list of terms

I would expect that on pages A, B and C all 3 results would be returned for each page because they all are tagged with Topic 1. This would be the case if they were OR'd together in parens.

Most helpful comment

@RichG82 Should be resolved by #66. Feel free to checkout the develop branch and see if updates suit your requirements. Thanks!

All 3 comments

Hi @RichG82, thank you for your feedback. You're right, I'll update the token translation to use 'OR' conditions instead of a comma to make more sense regarding the search behavior.

@FranckyC Thank you!

@RichG82 Should be resolved by #66. Feel free to checkout the develop branch and see if updates suit your requirements. Thanks!

Was this page helpful?
0 / 5 - 0 ratings