Monday, October 20, 2014

Look up item based on the Item’s ID

If you kick off a search query you get some default properties with a document. One of these are DocId.

image

The managed property DocId is of type text and marked as searchable, and you would assume you a search like DocId=123456 will bring back a result back.

image

For some reason this does not work. The workaround however is easy.

There exists a managed property called WorkId which is also returned per result, but it’s not visible in the search schema. This property is of type integer with the same value as DocId and you can bring back one item with the following query:

WorkId:123456 or WorkId=123456

You can also do WorkId<>123456 or -WorkId:123456 if you want all items except one item in particular.

Alternatively you can map the crawled property ows__dlc_DocId to a managed property of your choice and use that instead, but no reason to do that since another solution exists.

6 comments:

  1. Hello .
    Very nice tip (big information :))
    I wanted to know ,where you found this precious information to check if this best practice
    Thanks

    ReplyDelete
    Replies
    1. Just looked at the data available and used deduction :) Helps being curious.

      Delete
    2. Data available ?
      If in search schema not visible,where :
      :-) sql tables fields index? Special ssa or ssp schema ;).

      In my project ,before to use solution : new managed property searchble that map crawling pro ows__dlc_DocId ,i found your blog with excelent solution .
      But in my work ,good and true decisions ,not like solutions without documentation because this is maybe corrupted solution for future incompatible dev, or simple not supported by microsoft license.
      Sorry for my english in advance.
      in any case thank you !!

      Delete
    3. WorkID was there in FAST and in FS4SP, and also nownin 2013 etc.....so not a hard find. All results returned from FS4SP had workid in the returned xml.

      Delete
  2. I know .
    My unique question , not is difficulte ,but how to know that always workid equal docid. If exist microsoft documents that define this ?
    If not , not very important .
    Good job and thanks for your help

    ReplyDelete
    Replies
    1. No documentation. Which is how it is with SharePoint and FAST a lot of times.

      Delete