Thursday 15 January 2009

Adding a Lookup List column to a SharePoint Content Type and adding this new Lookup List to the site's Search

In SharePoint, if you want to add a new field to a Content Type, for example a Lookup List of data from a List within SharePoint itself, and also search on this Field from the Advanced Search screen, follow these steps:
  1. Go to the root of the site >> "Site Actions" >> "View All Site Content"
  2. Click "Create"
  3. Click "Custom List"
  4. Type in a name for the new list, e.g. "File Keywords", and select "No" to exclude it from the Quick Launch. Click the "Create" button to save the list.
  5. Add the items to your list.
  6. Go to the root of the site >> "Site Actions" >> "Site Settings" >> "Modify All Site Settings" >> "Site Columns"
  7. Click "Create" to create a new Column.
  8. Type in a name for the new Column, e.g. "File Keywords"
  9. Select "Lookup" as the Type.
  10. Select "File Keywords" from the "Get information from" drop down list.
  11. Select "Title" from the "In this column" drop down list.
  12. Tick the "Allow multiple values" checkbox to allow more than one value to be chosen.
  13. Go back to "Site Settings", and select "Site Content Types"
  14. Select the Content Type you wish to add your new column to.
  15. Click the "Add from existing site columns" link
  16. Choose your new Column from the "Available Columns" list and click the "Add Button".
  17. Click "OK" to assign the new Column to the Content Type.
  18. If you now go to the "Edit Properties" screen for an item of the changed content type, your new column will appear:



  19. To now configure the new column to be included in the site's Search, go to Central Administration, then select the Shared Service.
  20. Under "Search" click on "Search settings"
  21. Click on "Metadata property mappings"
  22. Click on "New Managed Property"
  23. Type in a Property Name of "FileKeywords"
  24. Select "Text"
  25. Click the "Add Mapping" button
  26. Search for part of your column name, e.g. "keyword". The item will probably be called "ows_File_x0020_Keywords"
  27. Tick the "Allow this property to be used in scopes"
  28. Click "OK" to save the changes.
  29. Navigate to your Search page, and click on "Advanced Search".
  30. Go to "Site Actions" >> "Edit Page"
  31. On the "Advanced Search Box" web part, go to "Edit" >> "Modify Shared Web Part"
  32. Under "Properties", edit the "Properties" attribute which contains the XML schema.
  33. Under the "All Results" node, add a new "PropertyRef" node titled "FileKeywords".
  34. Under the "PropertyDefs", add a new "PropertyDef" node with a Name of "FileKeywords", DataType of "text" and DisplayName of "File Keywords":

  35. Save the changes to the web part
  36. Publish the "Advanced Search" page, and you should now be able to search on your new column from the Advanced Search, within the "Add Property Restrictions" section, and by performing a normal search of: FileKeywords:"keyword"
  37. Results may not be displayed straight away in the Search - you might need to wait until the next search crawl.

3 comments:

  1. Great! Thank you!!
    That is exactly that client wants to use

    ReplyDelete
  2. Hello Dan.

    In step 26 I am searching for my column name (Photo Keyword" but not comming up with a match. Seaching either word in the column name doesn't return a result to add a mapping. Any idea?

    ReplyDelete
  3. Hello Dan, I am assuming we are adding a managed property based off of a lookup column because in the advanced search box when the user selects FileKeywords, instead of having a textbox they see a listbox with all the values to choose from. This is what I am trying to accomplish and I dont seem to be able to do that. If I add a regular text column I can search fine by entering the text but the lookup column throws me an error while searching and also does not show the values to pick from in advanced search, which is something I really want to do. Any thoughts? Thanks.

    ReplyDelete