2

I created a custom item display template for my search center:

....
    <span class="title">_#=ctx.CurrentItem.Title=#_</span>
....

The goal is to show the title of each document in the document library. The strange thing is that it isn't returning a title for every document. Even when the doc types and document library are exactly the same.

Sharepoint Search

3
  • 1
    Are you sure that the documents have titles? Files always get their filenames stored in the name column in a document library, while the title field is optional until changed to mandatory manually. Jan 22 '16 at 13:28
  • @user19952 All documents have titles. It seems to be related to something else. See my comment under Dylans answer,
    – Citizen SP
    Jan 22 '16 at 14:39
  • is the title field added in header, please check once? <mso:ManagedPropertyMapping msdt:dt="string">&#39;Title&#39;:&#39;Title&#39;, Oct 31 '17 at 14:55
2

On the OOB Document content type, Name is the required field that is the name of the file, Title is optional. Is it possible that the Title field was never filled out for the documents in question?

enter image description here

I believe the internal name of the Name column is FleLeafRef, so if you change your display template to use

<span class="title">_#=ctx.CurrentItem.FileLeafRef=#_</span>

you should start seeing the behavior you expect. (Of course, remember to add FileLeafRef to the section at the top of the display template that tells it what metadata to bring in.)

2
  • Thanks for your answer. I found out that the Sharepoint field ctx.CurrentItem.Title is not always looking to the title field of your item, but also to a title field within a Word document. This is not what I want. It should always look to the SP field. Is there a way to solve this?
    – Citizen SP
    Jan 22 '16 at 14:36
  • If you are trying to make it always look at the SP Title field and not also look at the internal "Title" metadata of a Word document, the only way I can think of offhand is to maybe create your own managed property that looks at the SP Title field only. However, Title is still optional on the Document content type, so if you want to ensure that you always show the file name, you should use FileLeafRef. Jan 22 '16 at 14:47
1

You can set this is the Search Schema. Go to Site Settings -> Search Schema Put "title" in the filter box Click on Title and go to the Mapped Crawled Properties and make "Title" the top item , not MetadataExtractorTitle.

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.