0

I'm working on a project where there is a solution that allows users to click on the context menu for an item, and it will generate a link to the item. This solution also has an event receiver that creates a unique ID for the item. After upgrading to SharePoint 2013, we are going to take advantage using the Document Center features, and move away from the current solution.

My idea was to parse the url using a custom search query rule (regex), and passing this value to search.

here is a sample of the bookmarked Url:

http://intranet/Pages/UniqueIDSearch.aspx?k=UniqueObjectID:09002f7780053af3

I have created a managed property that maps to the Unique Object Id field (Legacy Item Id) The query rule is using the regex feature, and the regex value is

^UniqueObjectId:\d{16}

To display the results, I have customized a display template, and added the value for the managed property.

The regex rule is failing to return any results, even though there are items with that value. If I manually search for the Unique Object Id, I will get a value returned.

Going forward is this the best solution?

2 Answers 2

1

I don't quite understand what you are doing with the link, unless it is to "Find other items with this ID". If that is the case (and your RegEx is correct) I think your approach is fine.

Did you know that you can use the Query Rules page to test your query? This is very helpful, particularly with RegEx rules. Navigate to the Manage Query Rules page:

  1. Select a result source
  2. Leave the selector at "Test a query" and enter your query in the "find rules that fire for a query" box. I tested yours as "09002f7780053af3" and it appears that @Yandr is correct.
  3. An alternative is this RegEx using a capture group: (?<uniqueobjectid>([\d\w]{16})) it not only matches on your pattern but creates a token "uniqueobjectid" that you can then use in subsequent queries.

If you decide you really want to pass in the fully formatted query that you have above, you don't need to go to these extremes because you can make the changes directly in the search center. The key is how broad a scope do you need? If you want a broad scope then look at using Query Rules, if you don't then use a specially configured search results page.

I show some of this in my SPC Session: http://channel9.msdn.com/Events/SharePoint-Conference/2014/SPC322

2
  • Correct, I only need the ID from the link, and the values that it will return from a search. Going forward this has been removed, and we are only supporting links that users my have embedded in emails, documents, or bookmarks. I'm planning on watching you sessions today, and digging deeper into the search features. Commented Mar 22, 2014 at 16:16
  • Both your SPC Session, and Plural Site courses are excellent! Commented Mar 28, 2014 at 16:20
1

At the very least I can tell you that the regular expression is wrong, because it matched only numbers and your object id contains letters too.

[\d\w]{16}

Never tried what you are doing, so I do not know if this is the only problem.

1
  • I will give your suggestion a shot Commented Mar 22, 2014 at 16:16

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.