0

I made a simple pnp search in SPFx by Querytext, now I need to make search by managed properties.

I have text managed property RefinersTextListOWSTEXT

So far I made this:

const _results: ISearchResult[] = [];
    return new Promise<ISearchResult[]>((resolve, reject) => {
        pnp.sp.search({
            Querytext: query,
            RowLimit: 20,
            StartRow: 0,
            SelectProperties: ["Title","Author","Path","FileType","RefinersTextList"]
        })
            .then((results) => {
                results.PrimarySearchResults.forEach((result) => {
                    _results.push({
                        title: result.Title,
                        description: result.HitHighlightedSummary,
                        link: result.Path,
                        author: result.Author,
                        filetype: result.FileType
                    });
                });
            })
            .then(
                () => { resolve(_results); }
            )
            .catch(
                () => { reject(new Error("Error")); }
            );
    });
3
  • Use this which shows how to query based on managed property and then you just need to pass this query in QueryText Commented Dec 28, 2022 at 5:49
  • Now it's working! I get rid of all properties in SelectProperties and left only RefinersTextList. Now I get search only by managed properties
    – Ann
    Commented Dec 28, 2022 at 7:14
  • 1
    Great. Can I ask you to put how you did it in the "Your Answer" section below, and mark your own answer as an answer? The idea is to let everyone know too if they face the same issue like yours. Commented Dec 28, 2022 at 8:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.