0

I'm using the PnP Modern Search SPFX web parts to build a staff directory. The web part configuration accepts a KQL query and allows you to specify the query template. I have specified a query template to control the fields that the search is performed against, but when the user initially loads the page I just want it to load everything. However a default search of * seems to conflict with my query template.

So for example,if my query template is:

FirstName:"{searchTerms*}" OR LastName:"{searchTerms*}"

This will search anything entered against all of the first or last names just fine.

But if I put in * it becomes an invalid query:

FirstName:"**" OR LastName:"**"

Ideally I want to do something like:

IIf({searchTerms} == "*", {searchTerms}, FirstName:"{searchTerms*}" OR LastName:"{searchTerms*}")

but I can't seem to get this to work. Can you do an IIf like this in KQL? If so, is there something wrong with my syntax? Note that {searchTerms} refers to the search box on the page, which has a default value of * if nothing is entered.

Your Answer

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

Browse other questions tagged or ask your own question.