0

I'm doing a SharePoint search and I need specifically select Title field, but, some times the result is the title of the document and not the Title field of the library or list

I'm using PnP-Js-Core

My code

return new Promise((resolve, reject) => {
  let listName = encodeURIComponent(this.listName);
  let query: string = `contentclass:STS_ListItem OR IsDocument:True path:${this.siteUrl}/${listName}/ ${text}`;
  pnp.sp.search(<SearchQuery>{
    Querytext: query,
    SelectProperties: ['Title'],
  })
    .then((r: SearchResults) => {
      resolve(r.PrimarySearchResults);
    })
    .catch((err) => {
      console.log(err);
      reject(null);
    });
});

Thanks.

1

1 Answer 1

1

The Title managed property is mapped, by default, to more than just the Title column in SharePoint and SharePoint Online. So, in your query for "Title", in addition to ows_Title, you are also getting values from Basic:displaytitle, TermTitle, MetadataExtractorTitle, and Title. If you want only your List or Library Item Title field you may want to configure your own queryable Managed Property and map it to ows_Title.

2
  • Thanks for your help, I already got the title field of the list, but it is only shown for some documents, for example for pdf and images, the title is not shown greetings and thanks Commented Sep 15, 2017 at 14:16
  • In the document library, you have to expressly set the Title field it is not the same as the Filename field. Ensure that the property value correctly. Commented Sep 15, 2017 at 15:58

Your Answer

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

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