SharePoint – Advanced search box autocomplete preoperty restrictions

When adding properties to the Advanced search web part you are bound to know exactly which metadata is included and how it’s spelled. This could be frustrating.

For some reason MS has decided not to help us spell like every other search component would do nowadays.

Consider you have 3 different metadata tags which is all choice or lookup fields. Now, you might want to autocomplete those fields in the Advanced search property restrictions to make sure that the spelling is correct or just to show the users which choices they have.

I implemented this with jQuery-UI which has jQuery-autocomplete included. I also decided to do all the gets by using the SharePoint client OM.

I will not tell you how to define your metadata properties in the search service or how to make them appear in the Advanced search webpart, you can google that :)

Here is the javascript. You will have to refer to jQuery js, jQuery-UI js and jQuery-UI css.

You can put this in your masterpage, a content editor or likewise.

So, I will give you one example. I have a loopkup field called “City” which is looking at a custom list called “Cities” which contains names of cities.

Since the autocomplete source was created when the property dropdown changed the suggestions will show directly, in this case when i type the letter “n”.

If I would change the property in the dropdown to “Country” the autcomplete source in textbox will refresh with a new source from the “Countries” list, same goes for “Type”.


About Tobias Eriksson