I'm trying to get the ID of a lookup field when using search api.
My query looks something like this:


Where Company is the lookup field, in a specific list.

The result looks like this:

<d:element m:type="SP.KeyValue">
  <d:Value>Some company</d:Value>

I have created a managed property which looks like this: enter image description here

1 Answer 1


I don't think it's possible. However, you could add the ID as a "column to show" in the List:

enter image description here

after which you will have a corresponding crawled property:

enter image description here

which you then can map to a managed property

enter image description here

After this you can use that managed property to retrieve the id of the linked company:

  "__metadata": {
    "type": "SP.KeyValue"
  "Key": "companyid",
  "Value": "2",
  "ValueType": "Edm.String"

The column (Company:ID) could be removed from all Views and - using PowerShell even from the DisplayView.

  • Brilliant! It even works with multi lookup. Interesting note; I tested with several fields, the crawled properties was named after fields Title (not InternalName), one was called "SharePoint:ID". I'll leave the question open for a couple of days before you get the bounty, but so far I'd be surprised to find a better solution :)
    – eirikb
    Sep 5, 2016 at 19:34

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.